Skip to content

Structure error references in range [C2941, C2980] #5649

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 5 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
5 changes: 3 additions & 2 deletions docs/error-messages/compiler-errors-2/compiler-error-c2941.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---
description: "Learn more about: Compiler Error C2941"
title: "Compiler Error C2941"
description: "Learn more about: Compiler Error C2941"
ms.date: 06/01/2022
f1_keywords: ["C2941"]
helpviewer_keywords: ["C2941"]
ms.assetid: 1bba94eb-5bf6-468d-8f84-96a6391a7048
---
# Compiler Error C2941

> '*class*' : type-class-id redefined as a local 'item'

## Remarks

You can't use a generic or template class as an item.

This error is obsolete in Visual Studio 2022 and later versions.
9 changes: 6 additions & 3 deletions docs/error-messages/compiler-errors-2/compiler-error-c2942.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2942"
title: "Compiler Error C2942"
description: "Learn more about: Compiler Error C2942"
ms.date: 06/01/2022
f1_keywords: ["C2942"]
helpviewer_keywords: ["C2942"]
ms.assetid: 13abf744-8fa1-450d-886d-e5717c04956e
---
# Compiler Error C2942

> '*class*' : type-class-id redefined as a formal argument of a function

## Remarks

You can't use a generic or template class as a formal argument. You cannot pass an argument directly to the constructor of a generic or template class.

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

The following sample generates C2942:
## Examples

The following example generates C2942:

```cpp
// C2942.cpp
Expand Down
9 changes: 6 additions & 3 deletions docs/error-messages/compiler-errors-2/compiler-error-c2943.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2943"
title: "Compiler Error C2943"
description: "Learn more about: Compiler Error C2943"
ms.date: 06/01/2022
f1_keywords: ["C2943"]
helpviewer_keywords: ["C2943"]
ms.assetid: ede6565e-d892-44c0-8eee-c69545f3be2e
---
# Compiler Error C2943

> '*class*' : type-class-id redefined as a type argument of a template

## Remarks

You can't use a generic or template class, instead of a symbol, as a generic or template type argument.

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

The following sample generates C2943:
## Example

The following example generates C2943:

```cpp
// C2943.cpp
Expand Down
9 changes: 6 additions & 3 deletions docs/error-messages/compiler-errors-2/compiler-error-c2944.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2944"
title: "Compiler Error C2944"
description: "Learn more about: Compiler Error C2944"
ms.date: 06/01/2022
f1_keywords: ["C2944"]
helpviewer_keywords: ["C2944"]
ms.assetid: f209e668-e72f-442a-a438-8c4ff43a404a
---
# Compiler Error C2944

> '*class*' : type-class-id redefined as a value argument of a template

## Remarks

You can't use a generic or template class, instead of a symbol, as a template value argument.

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

The following sample generates C2944:
## Examples

The following example generates C2944:

```cpp
// C2944.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2945.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2945"
title: "Compiler Error C2945"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2945"
ms.date: 11/04/2016
f1_keywords: ["C2945"]
helpviewer_keywords: ["C2945"]
ms.assetid: be640257-7017-45d1-986a-9fe8caab52f3
---
# Compiler Error C2945

explicit instantiation does not refer to a template-class specialization
> explicit instantiation does not refer to a template-class specialization

## Remarks

You cannot explicitly instantiate something that is not templated.
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2946.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2946"
title: "Compiler Error C2946"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2946"
ms.date: 11/04/2016
f1_keywords: ["C2946"]
helpviewer_keywords: ["C2946"]
ms.assetid: c86dfbfc-7702-4f09-8a53-d205710e99c2
---
# Compiler Error C2946

explicit instantiation; 'class' is not a template-class specialization
> explicit instantiation; 'class' is not a template-class specialization

## Remarks

You cannot explicitly instantiate a nontemplated class.

## Example

The following sample generates C2946.
The following example generates C2946.

```cpp
// C2946.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2947.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2947"
title: "Compiler Error C2947"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2947"
ms.date: 11/04/2016
f1_keywords: ["C2947"]
helpviewer_keywords: ["C2947"]
ms.assetid: 6c056f62-ec90-4883-8a67-aeeb6ec13546
---
# Compiler Error C2947

expecting '>' to terminate construct, found 'syntax'
> expecting '>' to terminate construct, found 'syntax'

## Remarks

A generic or template argument list may not have been terminated correctly.

C2947 can also be generated by syntax errors.

The following sample generates C2947:
## Example

The following example generates C2947:

```cpp
// C2947.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2948.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2948"
title: "Compiler Error C2948"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2948"
ms.date: 11/04/2016
f1_keywords: ["C2948"]
helpviewer_keywords: ["C2948"]
ms.assetid: 780c6ed3-43a0-4112-8d00-b7bf79086c05
---
# Compiler Error C2948

explicit instantiation; storage class specifier 'specifier' not permitted on specialization
> explicit instantiation; storage class specifier 'specifier' not permitted on specialization

## Remarks

You cannot use storage-class specifiers (such as **`extern`**) in a specialization of a template class that was previously explicitly instantiated.
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2951.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2951"
title: "Compiler Error C2951"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2951"
ms.date: 11/04/2016
f1_keywords: ["C2951"]
helpviewer_keywords: ["C2951"]
ms.assetid: c6f95aa2-c894-425b-a51c-d40d70c8daa1
---
# Compiler Error C2951

type declarations are only permitted at global, namespace, or class scope
> type declarations are only permitted at global, namespace, or class scope

## Remarks

You cannot declare a generic or template class outside global or namespace scope. If you make your generic or template declarations in an include file, make sure the include file is at global scope.

The following sample generates C2951:
## Examples

The following example generates C2951:

```cpp
// C2951.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2952.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2952"
title: "Compiler Error C2952"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2952"
ms.date: 11/04/2016
f1_keywords: ["C2952"]
helpviewer_keywords: ["C2952"]
ms.assetid: a40e18a2-d02c-4511-854f-6c6fd6789a1a
---
# Compiler Error C2952

'declaration' : type declaration missing template parameter list
> 'declaration' : type declaration missing template parameter list

## Remarks

A template declaration was ill formed.

The following sample generates C2952:
## Examples

The following example generates C2952:

```cpp
// C2952.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2953.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2953"
title: "Compiler Error C2953"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2953"
ms.date: 11/04/2016
f1_keywords: ["C2953"]
helpviewer_keywords: ["C2953"]
ms.assetid: 8dbcfa24-8296-4e40-bdc4-5526c07d8892
---
# Compiler Error C2953

'identifier' : class template has already been defined
> 'identifier' : class template has already been defined

## Remarks

Check the source file and include files for other definitions.

The following sample generates C2953:
## Example

The following example generates C2953:

```cpp
// C2953.cpp
Expand Down
15 changes: 8 additions & 7 deletions docs/error-messages/compiler-errors-2/compiler-error-c2955.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2955"
title: "Compiler Error C2955"
ms.date: "03/28/2017"
description: "Learn more about: Compiler Error C2955"
ms.date: 03/28/2017
f1_keywords: ["C2955"]
helpviewer_keywords: ["C2955"]
ms.assetid: 77709fb6-d69b-46fd-a62f-e8564563d01b
---
# Compiler Error C2955

'identifier' : use of class template or alias generic requires template or generic argument list
> 'identifier' : use of class template or alias generic requires template or generic argument list

## Remarks

You cannot use a class template or class generic as an identifier without a template or generic argument list.

For more information, see [Class Templates](../../cpp/class-templates.md).

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

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

```cpp
// C2955.cpp
Expand Down Expand Up @@ -61,8 +64,6 @@ int main() {
}
```

## Example

**Visual Studio 2017 and later:** The compiler correctly diagnoses missing template argument lists when the template appears in a template parameter list (for example as part of a default template argument or a non-type template parameter). The following code compiles in Visual Studio 2015 but produces an error in Visual Studio 2017.

```
Expand Down
6 changes: 3 additions & 3 deletions docs/error-messages/compiler-errors-2/compiler-error-c2956.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: "Learn more about: Compiler Error C2956"
title: "Compiler Error C2956"
description: "Learn more about: Compiler Error C2956"
ms.date: 04/05/2022
f1_keywords: ["C2956"]
helpviewer_keywords: ["C2956"]
Expand All @@ -9,10 +9,10 @@ helpviewer_keywords: ["C2956"]

> usual deallocation function '*function*' would be chosen as placement deallocation function

The deallocation function found for the placement new expression matches one of the usual deallocation functions. Either an implicit compiler-generated deallocation or an explicit `delete` (or `delete[]`) would use the wrong deallocation function.

## Remarks

The deallocation function found for the placement new expression matches one of the usual deallocation functions. Either an implicit compiler-generated deallocation or an explicit `delete` (or `delete[]`) would use the wrong deallocation function.

Error C2956 indicates you used a *placement new expression* (a `new` expression that takes parameters) in a way that can cause a memory leak or runtime crash. It usually means the resulting value can't be deleted in a typical way. That is, either an explicit `delete` (or `delete[]`) expression in your code, or the implicit deallocation when a constructor throws an exception, could invoke the wrong `operator delete` or supply it with the wrong parameters.

The C++ standard specifies *usual deallocation functions* as overloads of `operator delete` or `operator delete[]` that take extra parameters of type `std::size_t` (C++14 or later), `std::align_val_t` (C++17 or later), and `std::destroying_delete_t` (C++20 or later). When you use a placement new expression, the compiler looks for a matching `operator delete` function that takes the same parameters (after the first one). If one is found and its signature matches a usual deallocation function, the compiler reports error C2956.
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2957.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2957"
title: "Compiler Error C2957"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2957"
ms.date: 11/04/2016
f1_keywords: ["C2957"]
helpviewer_keywords: ["C2957"]
ms.assetid: 9cb4526f-4af8-47e9-b786-56192627ca72
---
# Compiler Error C2957

'delim' : invalid left delimiter : expected '<'
> 'delim' : invalid left delimiter : expected '<'

## Remarks

A generic class was ill formed.

The following sample generates C2957:
## Example

The following example generates C2957:

```cpp
// C2957.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2958.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2958"
title: "Compiler Error C2958"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2958"
ms.date: 11/04/2016
f1_keywords: ["C2958"]
helpviewer_keywords: ["C2958"]
ms.assetid: 332bf6d3-7cd1-4b1a-8ddb-d4a8cbf01115
---
# Compiler Error C2958

the left delimiter found at 'location' was not matched correctly
> the left delimiter found at 'location' was not matched correctly

## Remarks

A delimiter is not properly matched.

Expand Down
Loading