Skip to content

Commit 87e490f

Browse files
authored
Add part on alignof
1 parent b25507b commit 87e490f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎docs/error-messages/compiler-errors-1/compiler-error-c2061.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The following sample generates C2061:
2020

2121
```cpp
2222
// C2061.cpp
23-
// compile with: /c /std:c++17
23+
// compile with: /std:c++17
2424
template <A a> // C2061
2525
// Replace identifier `A` with `typename`:
2626
// template <typename a>
@@ -32,6 +32,13 @@ class C2 {
3232
using Type1 = T::Type; // C2061
3333
using Type2 = typename T::Type; // OK
3434
};
35+
36+
int main() {
37+
int x;
38+
unsigned a1 = alignof(x); // C2061
39+
unsigned a2 = alignof(int); // OK
40+
unsigned a3 = alignof(decltype(x)); // OK
41+
}
3542
```
3643
3744
C2061 can occur if you pass an instance name to [typeid](../../extensions/typeid-cpp-component-extensions.md):

0 commit comments

Comments
 (0)