Skip to content

Commit 184e520

Browse files
committed
Tweak sample code
1 parent edef397 commit 184e520

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

docs/build/reference/permissive-standards-conformance.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,38 @@ void func(int default); // Error C2321: 'default' is a keyword, and
5252
5353
```cpp
5454
template <typename T>
55-
struct B {
56-
void f();
55+
struct B
56+
{
57+
void f() {}
5758
template <typename U>
58-
struct S {};
59+
struct S { void operator()(){ return; } };
5960
};
6061
6162
template <typename T>
6263
struct D : public B<T> // B is a dependent base because its type
6364
// depends on the type of T.
6465
{
65-
// One possible fix for member functions is to uncomment
66-
// the following line:
66+
// One possible fix for non-template members and function
67+
// template members is a using statement:
6768
// using B<T>::f;
6869
// If it's a type, don't forget the 'typename' keyword.
6970
70-
void g() {
71+
void g()
72+
{
7173
f(); // error C3861: 'f': identifier not found
72-
// Another fix is to change it to 'this->f();'
74+
// Another fix is to change the call to 'this->f();'
7375
}
7476
75-
void h() {
76-
S<int> s; // C2065 'S': undeclared identifier
77-
// Since template S is dependent, D::template S isn't enough.
78-
// The type must be qualified with the `typename` keyword.
79-
// To fix, replace the above with this uncommented line:
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:
8085
// typename D::template S<int> s;
86+
s();
8187
}
8288
};
8389

0 commit comments

Comments
 (0)