Skip to content

Commit aed3da7

Browse files
authored
Update compiler-error-c2993.md
Tried to make the flow easier to follow for the different errors that are emitted now vs. before.
1 parent 95dc0fb commit aed3da7

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

docs/error-messages/compiler-errors-2/compiler-error-c2993.md

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,49 @@ title: "Compiler Error C2993"
44
ms.date: "10/03/2023"
55
f1_keywords: ["C2993"]
66
helpviewer_keywords: ["C2993"]
7-
ms.assetid: 4ffd2b78-654b-46aa-95a6-b62101cf91c8
87
---
98
# Compiler Error C2993
109

1110
'identifier' : illegal type for non-type template parameter 'parameter'
1211

13-
You cannot declare a template with a structure, class or union argument. However, pointers can be used in place of those types as template parameters. Since C++20, structure, class or unions can be used as non-type template parameters.
12+
- Prior to C++20, you cannot declare a template with a structure, class, or union argument. Pointers can be used in place of these types as template parameters.
13+
- Since C++20, structure, class, or unions *can* be used as non-type template parameters. A non-type template parameter cannot be a rvalue reference type. Neither is a parameter pack of rvalue types allowed.
1414

1515
The following sample generates C2993:
1616

1717
```cpp
18-
// C2993.cpp
18+
// compile with: /c and /std:c++17
19+
template <int&& I> // C2993
20+
struct S1 {};
21+
22+
template <int&&... Is> // C2993
23+
struct S2 {};
24+
```
25+
26+
Before MSVC 19.26, the following code emitted C2993. It now emits C7582:
27+
28+
```cpp
1929
// compile with: /c /std:c++17
2030
struct MyStruct {};
2131
22-
template <class T, MyStruct S> // C2993
32+
template <class T, MyStruct S> // Was C2993 prior to MSVC 19.26. Now emits C7582.
2333
class MyClass1 {};
2434
2535
template <class T, MyStruct* S> // OK
2636
class MyClass2 {};
2737
```
2838

29-
> [!NOTE]
30-
> The sample above no longer emits C2993 since MSVC v19.26 and instead shows C7592.
31-
3239
With C++17 and earlier, you cannot have floating point non-type template parameters. Since C++20, floating point non-type template parameters are allowed as with literal class types.
40+
If it's a function template, use a function argument to pass the floating point non-type template parameter.
3341

34-
If it is a function template, use a function argument to pass in the floating point non-type template parameter.
42+
Before MSVC 19.26, the following code emitted C2993. It now emits C7582:
3543

3644
```cpp
3745
// C2993b.cpp
3846
// compile with: /c /std:c++17
39-
template<class T, float F> // C2993
47+
template<class T, float F> // Was C2993 prior to MSVC 19.26. Now emits C7592
4048
void func1(T t) {}
4149

4250
template<class T> // OK
4351
void func2(T t, float F) {}
4452
```
45-
46-
> [!NOTE]
47-
> The sample above no longer emits C2993 since MSVC v19.26 and instead shows C7592.
48-
49-
Non-type template parameters cannot be of rvalue reference type. Similarly, a parameter pack of such types are not allowed.
50-
51-
```cpp
52-
// C2993c.cpp
53-
// compile with: /c
54-
template <int&& I> // C2993
55-
struct S1 {};
56-
57-
template <int&&... Is> // C2993
58-
struct S2 {};
59-
```

0 commit comments

Comments
 (0)