Skip to content

Structure error references in range [C2911, C2940] #5648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2911.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2911"
title: "Compiler Error C2911"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2911"
ms.date: 11/04/2016
f1_keywords: ["C2911"]
helpviewer_keywords: ["C2911"]
ms.assetid: 83c7c01a-ab6a-4179-9fb0-289a9ec8d44e
---
# Compiler Error C2911

'member' : cannot be declared or defined in the current scope
> 'member' : cannot be declared or defined in the current scope

## Remarks

Inside a namespace, class, or function, you can only define a member of the same namespace, class, or function or a member that is enclosed by the same namespace, class, or function.

The following sample generates C2911:
## Example

The following example generates C2911:

```cpp
// C2911.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2912.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2912"
title: "Compiler Error C2912"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2912"
ms.date: 11/04/2016
f1_keywords: ["C2912"]
helpviewer_keywords: ["C2912"]
ms.assetid: bd55cecd-ab1a-4636-ab8a-a00393fe7b3d
---
# Compiler Error C2912

explicit specialization 'declaration' is not a specialization of a function template
> explicit specialization 'declaration' is not a specialization of a function template

## Remarks

You cannot specialize a non-template function.

The following sample generates C2912:
## Examples

The following example generates C2912:

```cpp
// C2912.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2913.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2913"
title: "Compiler Error C2913"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2913"
ms.date: 11/04/2016
f1_keywords: ["C2913"]
helpviewer_keywords: ["C2913"]
ms.assetid: c6cf6090-02e8-49a5-913f-5bc6f864b769
---
# Compiler Error C2913

explicit specialization; 'declaration' is not a specialization of a class template
> explicit specialization; 'declaration' is not a specialization of a class template

## Remarks

You cannot specialize a non-template class.

The following sample generates C2913:
## Example

The following example generates C2913:

```cpp
// C2913.cpp
Expand Down
15 changes: 9 additions & 6 deletions docs/error-messages/compiler-errors-2/compiler-error-c2914.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2914"
title: "Compiler Error C2914"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2914"
ms.date: 11/04/2016
f1_keywords: ["C2914"]
helpviewer_keywords: ["C2914"]
ms.assetid: fc6a0592-f53e-4f5a-88cb-780bbed4acf2
---
# Compiler Error C2914

'identifier' : cannot deduce type argument as function argument is ambiguous
> 'identifier' : cannot deduce type argument as function argument is ambiguous

## Remarks

The compiler cannot determine which overloaded functions to use for a generic or template argument.

The following sample generates C2914:
## Examples

The following example generates C2914:

```cpp
// C2914.cpp
Expand All @@ -25,7 +28,7 @@ void h() { g(f); } // C2914
// void h() { g<int>(f); }
```

C2914 can also occur when using generics. The following sample generates C2914:
C2914 can also occur when using generics. The following example generates C2914:

```cpp
// C2914b.cpp
Expand Down
5 changes: 2 additions & 3 deletions docs/error-messages/compiler-errors-2/compiler-error-c2917.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: Compiler Error C2917"
title: "Compiler Error C2917"
description: "Learn more about: Compiler Error C2917"
ms.date: 06/01/2022
f1_keywords: ["C2917"]
helpviewer_keywords: ["C2917"]
ms.assetid: ec9da9ee-0f37-47b3-87dd-19ef5a14dc4c
---
# Compiler Error C2917

Expand All @@ -18,7 +17,7 @@ This error is obsolete in Visual Studio 2022 and later versions.

## Example

The following sample generates C2917.
The following example generates C2917.

```cpp
// C2917.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2918.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2918"
title: "Compiler Error C2918"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2918"
ms.date: 11/04/2016
f1_keywords: ["C2918"]
helpviewer_keywords: ["C2918"]
ms.assetid: e452f7ef-0590-45e6-9c7c-ee75dc014670
---
# Compiler Error C2918

'name': Indexed properties cannot be used on the published surface of a WinRT type
> 'name': Indexed properties cannot be used on the published surface of a WinRT type

## Remarks

Indexed properties are not supported on the published surface of a WinRT type.
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2919.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2919"
title: "Compiler Error C2919"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2919"
ms.date: 11/04/2016
f1_keywords: ["C2919"]
helpviewer_keywords: ["C2919"]
ms.assetid: 140a6db9-eb48-4c5e-84a7-a09d2653605b
---
# Compiler Error C2919

'type': Operators cannot be used on the published surface of a WinRT type
> 'type': Operators cannot be used on the published surface of a WinRT type

## Remarks

The Windows Runtime type system does not support operator member functions in the published surface of a type. This is because not all languages can consume operator member functions. You can create private or internal operator member functions that can be called from C++ code in the same class or compilation unit.

Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2920.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2920"
title: "Compiler Error C2920"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2920"
ms.date: 11/04/2016
f1_keywords: ["C2920"]
helpviewer_keywords: ["C2920"]
ms.assetid: 0a4cb2de-00a0-4209-8160-c7ce6ed7d9ab
---
# Compiler Error C2920

redefinition : 'class' : class template or generic has already been declared as 'type'
> redefinition : 'class' : class template or generic has already been declared as 'type'

## Remarks

A generic or template class has multiple declarations, which are not equivalent. To fix this error, use different names for different types, or remove the redefinition of the type name.

The following sample generates C2920 and shows how to fix it:
## Examples

The following example generates C2920 and shows how to fix it:

```cpp
// C2920.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2921.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2921"
title: "Compiler Error C2921"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2921"
ms.date: 11/04/2016
f1_keywords: ["C2921"]
helpviewer_keywords: ["C2921"]
ms.assetid: 323642a0-bfc4-4942-9f41-c3adf5c54296
---
# Compiler Error C2921

redefinition : 'class' : class template or generic is being redeclared as 'type'
> redefinition : 'class' : class template or generic is being redeclared as 'type'

## Remarks

A generic or template class has multiple declarations that are not equivalent. To fix this error, use different names for different types, or remove the redefinition of the type name.

The following sample generates C2921:
## Examples

The following example generates C2921:

```cpp
// C2921.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2923.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2923"
title: "Compiler Error C2923"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2923"
ms.date: 11/04/2016
f1_keywords: ["C2923"]
helpviewer_keywords: ["C2923"]
ms.assetid: 6b92933b-13ef-4124-99d9-b89f9fdae030
---
# Compiler Error C2923

'type' : 'identifier' is not a valid template type argument for parameter 'param'
> 'type' : 'identifier' is not a valid template type argument for parameter 'param'

## Remarks

The argument list is missing a type needed to instantiate the template or generic. Check the template or generic declaration.

The following sample generates C2923:
## Examples

The following example generates C2923:

```cpp
// C2923.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2927.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2927"
title: "Compiler Error C2927"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2927"
ms.date: 11/04/2016
f1_keywords: ["C2927"]
helpviewer_keywords: ["C2927"]
ms.assetid: 3f75beec-ff5c-44e1-9085-990ecd55198d
---
# Compiler Error C2927

'function' : a function template must be called with at least one argument
> 'function' : a function template must be called with at least one argument

## Remarks

You cannot call a function template without arguments. The type of the template arguments determines what version of the function to generate.
7 changes: 4 additions & 3 deletions docs/error-messages/compiler-errors-2/compiler-error-c2928.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2928"
title: "Compiler Error C2928"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2928"
ms.date: 11/04/2016
f1_keywords: ["C2928"]
helpviewer_keywords: ["C2928"]
ms.assetid: 869e57f4-7024-4cbe-b47b-6e1e2a6005c5
---
# Compiler Error C2928

> explicit instantiation; '*identifier*' is not a function or static data member of template-class '*class-name*'

## Remarks

You cannot explicitly instantiate a member of *class-name* that is not a function or **`static`** variable.
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2929.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2929"
title: "Compiler Error C2929"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2929"
ms.date: 11/04/2016
f1_keywords: ["C2929"]
helpviewer_keywords: ["C2929"]
ms.assetid: 11134027-6adc-4733-b6bd-b94486bd1933
---
# Compiler Error C2929

'identifier' : explicit instantiation; cannot explicitly force and suppress instantiation of template-class member
> 'identifier' : explicit instantiation; cannot explicitly force and suppress instantiation of template-class member

## Remarks

You cannot explicitly instantiate an identifier while preventing it from being instantiated.

The following sample generates C2929:
## Example

The following example generates C2929:

```cpp
// C2929.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2930.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2930"
title: "Compiler Error C2930"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2930"
ms.date: 11/04/2016
f1_keywords: ["C2930"]
helpviewer_keywords: ["C2930"]
ms.assetid: f07eecd1-e5d1-4518-bd89-b1fd2a003a17
---
# Compiler Error C2930

'class' : type-class-id redefined as an enumerator of 'enum identifier'
> 'class' : type-class-id redefined as an enumerator of 'enum identifier'

## Remarks

You cannot use a generic or template class as a member of an enumeration.

This error can be caused if braces are improperly matched.

The following sample generates C2930:
## Examples

The following example generates C2930:

```cpp
// C2930.cpp
Expand Down
11 changes: 7 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2931.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
---
description: "Learn more about: Compiler Error C2931"
title: "Compiler Error C2931"
description: "Learn more about: Compiler Error C2931"
ms.date: 06/01/2022
f1_keywords: ["C2931"]
helpviewer_keywords: ["C2931"]
ms.assetid: 33430407-b149-4ba3-baf8-b0dae1ea3a5d
---
# Compiler Error C2931

'*class*' : type-class-id redefined as a member function of '*identifier*'
> '*class*' : type-class-id redefined as a member function of '*identifier*'

## Remarks

You can't use a generic or template class as a member function of another class.

This error is obsolete in Visual Studio 2022 and later versions.

This error can be caused if braces are improperly matched.

The following sample generates C2931:
## Examples

The following example generates C2931:

```cpp
// C2931.cpp
Expand Down
Loading