Skip to content

Commit 28fd491

Browse files
author
Paul Dempsey
authored
Use cpp for C++ code samples
1 parent 8abe610 commit 28fd491

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

docs/cpp/templates-and-name-resolution.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ translation.priority.ht:
3131
- "zh-tw"
3232
---
3333
# Templates and Name Resolution
34+
3435
In template definitions, there are three types of names.
3536

3637
- Locally declared names, including the name of the template itself and any names declared inside the template definition.
@@ -45,52 +46,54 @@ In template definitions, there are three types of names.
4546

4647
- The template argument itself:
4748

48-
```
49+
```cpp
4950
T
5051
```
5152

5253
- A qualified name with a qualification including a dependent type:
5354

54-
```
55+
```cpp
5556
T::myType
5657
```
5758

5859
- A qualified name if the unqualified part identifies a dependent type:
5960

60-
```
61+
```cpp
6162
N::T
6263
```
6364

6465
- A const or volatile type for which the base type is a dependent type:
6566

66-
```
67+
```cpp
6768
const T
6869
```
6970

7071
- A pointer, reference, array, or function pointer type based on a dependent type:
7172

72-
```
73+
```cpp
7374
T *, T &, T [10], T (*)()
7475
```
7576

7677
- An array whose size is based on a template parameter:
7778

78-
```
79+
```cpp
7980
template <int arg> class X {
8081
int x[arg] ; // dependent type
8182
}
8283
```
8384

8485
- a template type constructed from a template parameter:
8586

86-
```
87+
```cpp
8788
T<int>, MyTemplate<T>
8889
```
8990

90-
## Type Dependence and Value Dependence
91+
## Type Dependence and Value Dependence
92+
9193
Names and expressions dependent on a template parameter are categorized as type dependent or value dependent, depending on whether the template parameter is a type parameter or a value parameter. Also, any identifiers declared in a template with a type dependent on the template argument are considered value dependent, as is a integral or enumeration type initialized with a value-dependent expression.
9294

9395
Type-dependent and value-dependent expressions are expressions that involve variables that are type dependent or value dependent. These expressions can have semantics that differ, depending on the parameters used for the template.
9496

95-
## See Also
96-
[Templates](../cpp/templates-cpp.md)
97+
## See Also
98+
99+
[Templates](../cpp/templates-cpp.md)

0 commit comments

Comments
 (0)