Skip to content

Commit 4042fb2

Browse files
authored
Merge pull request MicrosoftDocs#3656 from MicrosoftDocs/master
7/12/2021 AM Publish
2 parents 3ff70ef + 13a89f6 commit 4042fb2

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

docs/build/cmakesettings-reference.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ The following macros can be used in *CMakeSettings.json*:
257257
- `${workspaceRoot}` – the full path of the workspace folder
258258
- `${workspaceHash}` – hash of workspace location; useful for creating a unique identifier for the current workspace (for example, to use in folder paths)
259259
- `${projectFile}` – the full path of the root CMakeLists.txt file
260-
- `${projectDir}` – the full path of the folder of the root CMakeLists.txt file
260+
- `${projectDir}` – the full path of the folder containing the root CMakeLists.txt file
261+
- `${projectDirName}` – the name of the folder containing the root CMakeLists.txt file
261262
- `${thisFile}` – the full path of the `CMakeSettings.json` file
262263
- `${name}` – the name of the configuration
263264
- `${generator}` – the name of the CMake generator used in this configuration

docs/cpp/template-specialization-cpp.md

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: Template Specialization (C++)"
33
title: "Template Specialization (C++)"
4-
ms.date: "11/04/2016"
4+
ms.date: 07/09/2021
55
helpviewer_keywords: ["partial specialization of class templates"]
66
ms.assetid: f3c67c0b-3875-434a-b8d8-bb47e99cf4f0
77
---
@@ -17,6 +17,8 @@ Class templates can be partially specialized, and the resulting class is still a
1717

1818
```cpp
1919
// partial_specialization_of_class_templates.cpp
20+
#include <stdio.h>
21+
2022
template <class T> struct PTS {
2123
enum {
2224
IsPointer = 0,
@@ -40,24 +42,25 @@ template <class T, class U> struct PTS<T U::*> {
4042

4143
struct S{};
4244

43-
extern "C" int printf_s(const char*,...);
44-
4545
int main() {
46-
printf_s("PTS<S>::IsPointer == %d PTS<S>::IsPointerToDataMember == %d\n",
46+
printf_s("PTS<S>::IsPointer == %d \nPTS<S>::IsPointerToDataMember == %d\n",
4747
PTS<S>::IsPointer, PTS<S>:: IsPointerToDataMember);
48-
printf_s("PTS<S*>::IsPointer == %d PTS<S*>::IsPointerToDataMember ==%d\n"
48+
printf_s("PTS<S*>::IsPointer == %d \nPTS<S*>::IsPointerToDataMember == %d\n"
4949
, PTS<S*>::IsPointer, PTS<S*>:: IsPointerToDataMember);
50-
printf_s("PTS<int S::*>::IsPointer == %d PTS"
50+
printf_s("PTS<int S::*>::IsPointer == %d \nPTS"
5151
"<int S::*>::IsPointerToDataMember == %d\n",
5252
PTS<int S::*>::IsPointer, PTS<int S::*>::
5353
IsPointerToDataMember);
5454
}
5555
```
5656
5757
```Output
58-
PTS<S>::IsPointer == 0 PTS<S>::IsPointerToDataMember == 0
59-
PTS<S*>::IsPointer == 1 PTS<S*>::IsPointerToDataMember ==0
60-
PTS<int S::*>::IsPointer == 0 PTS<int S::*>::IsPointerToDataMember == 1
58+
PTS<S>::IsPointer == 0
59+
PTS<S>::IsPointerToDataMember == 0
60+
PTS<S*>::IsPointer == 1
61+
PTS<S*>::IsPointerToDataMember == 0
62+
PTS<int S::*>::IsPointer == 0
63+
PTS<int S::*>::IsPointerToDataMember == 1
6164
```
6265

6366
## Example: Partial specialization for pointer types
@@ -159,6 +162,7 @@ int main() {
159162
xp.add(&j);
160163
xp.add(p);
161164
xp.add(p + 1);
165+
delete[] p;
162166
p = NULL;
163167
xp.add(p);
164168
xp.print();
@@ -285,23 +289,23 @@ public:
285289
};
286290

287291
int main() {
288-
Dictionary<char*, char*>* dict = new Dictionary<char*, char*>(10);
289-
dict->print();
290-
dict->add("apple", "fruit");
291-
dict->add("banana", "fruit");
292-
dict->add("dog", "animal");
293-
dict->print();
294-
295-
Dictionary<int, char*>* dict_specialized = new Dictionary<int, char*>(10);
296-
dict_specialized->print();
297-
dict_specialized->add(100, "apple");
298-
dict_specialized->add(101, "banana");
299-
dict_specialized->add(103, "dog");
300-
dict_specialized->add(89, "cat");
301-
dict_specialized->print();
302-
dict_specialized->sort();
292+
Dictionary<const char*, const char*> dict(10);
293+
dict.print();
294+
dict.add("apple", "fruit");
295+
dict.add("banana", "fruit");
296+
dict.add("dog", "animal");
297+
dict.print();
298+
299+
Dictionary<int, const char*> dict_specialized(10);
300+
dict_specialized.print();
301+
dict_specialized.add(100, "apple");
302+
dict_specialized.add(101, "banana");
303+
dict_specialized.add(103, "dog");
304+
dict_specialized.add(89, "cat");
305+
dict_specialized.print();
306+
dict_specialized.sort();
303307
cout << endl << "Sorted list:" << endl;
304-
dict_specialized->print();
308+
dict_specialized.print();
305309
}
306310
```
307311

0 commit comments

Comments
 (0)