|
1 | 1 | ---
|
2 | 2 | title: "/permissive- (Standards conformance)"
|
3 | 3 | description: "Reference guide to the Microsoft C++ /permissive- (Standards conformance) compiler option."
|
4 |
| -ms.date: 06/29/2022 |
| 4 | +ms.date: 12/14/2022 |
5 | 5 | f1_keywords: ["/permissive", "VC.Project.VCCLCompilerTool.ConformanceMode"]
|
6 | 6 | helpviewer_keywords: ["/permissive compiler options [C++]", "-permissive compiler options [C++]", "Standards conformance compiler options", "permissive compiler options [C++]"]
|
7 | 7 | ms.assetid: db1cc175-6e93-4a2e-9396-c3725d2d8f71
|
@@ -52,27 +52,45 @@ void func(int default); // Error C2321: 'default' is a keyword, and
|
52 | 52 |
|
53 | 53 | ```cpp
|
54 | 54 | template <typename T>
|
55 |
| -struct B { |
56 |
| - void f(); |
| 55 | +struct B |
| 56 | +{ |
| 57 | + void f() {} |
| 58 | + template <typename U> |
| 59 | + struct S { void operator()(){ return; } }; |
57 | 60 | };
|
58 | 61 |
|
59 | 62 | template <typename T>
|
60 | 63 | struct D : public B<T> // B is a dependent base because its type
|
61 | 64 | // depends on the type of T.
|
62 | 65 | {
|
63 |
| - // One possible fix is to uncomment the following line. |
64 |
| - // If this is a type, don't forget the 'typename' keyword. |
| 66 | + // One possible fix for non-template members and function |
| 67 | + // template members is a using statement: |
65 | 68 | // using B<T>::f;
|
| 69 | + // If it's a type, don't forget the 'typename' keyword. |
66 | 70 |
|
67 |
| - void g() { |
| 71 | + void g() |
| 72 | + { |
68 | 73 | f(); // error C3861: 'f': identifier not found
|
69 |
| - // Another fix is to change it to 'this->f();' |
| 74 | + // Another fix is to change the call to 'this->f();' |
| 75 | + } |
| 76 | +
|
| 77 | + void h() |
| 78 | + { |
| 79 | + S<int> s; // C2065 or C3878 |
| 80 | + // Since template S is dependent, the type must be qualified |
| 81 | + // with the `typename` keyword. |
| 82 | + // To fix, replace the declaration of s with: |
| 83 | + // typename B<T>::template S<int> s; |
| 84 | + // Or, use this: |
| 85 | + // typename D::template S<int> s; |
| 86 | + s(); |
70 | 87 | }
|
71 | 88 | };
|
72 | 89 |
|
73 | 90 | void h() {
|
74 | 91 | D<int> d;
|
75 | 92 | d.g();
|
| 93 | + d.h(); |
76 | 94 | }
|
77 | 95 | ```
|
78 | 96 |
|
|
0 commit comments