Skip to content

Structure error references in range [C2671, C2700] #5618

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-c2671.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2671"
title: "Compiler Error C2671"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2671"
ms.date: 11/04/2016
f1_keywords: ["C2671"]
helpviewer_keywords: ["C2671"]
ms.assetid: fc0ee40f-c8f3-408f-b89d-745d149c4169
---
# Compiler Error C2671

'function' : static member functions do not have 'this' pointers
> 'function' : static member functions do not have 'this' pointers

## Remarks

A **`static`** member function tried to access **`this`**.

The following sample generates C2671:
## Example

The following example generates C2671:

```cpp
// C2671.cpp
Expand Down
7 changes: 4 additions & 3 deletions docs/error-messages/compiler-errors-2/compiler-error-c2672.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---
description: "Learn more about: Compiler Error C2672"
title: "Compiler Error C2672"
ms.date: "10/24/2017"
description: "Learn more about: Compiler Error C2672"
ms.date: 10/24/2017
f1_keywords: ["C2672"]
helpviewer_keywords: ["C2672"]
ms.assetid: 7e86338a-2d4b-40fe-9dd2-ac6886f3f31a
---
# Compiler Error C2672

> '*function*': no matching overloaded function found

## Remarks

The compiler could not find an overloaded function that matches the specified function. No function was found that takes matching parameters, or no matching function has the required accessibility in context.

When used by certain standard library containers or algorithms, your types must provide accessible members or friend functions that satisfy the requirements of the container or algorithm. For example, your iterator types should derive from `std::iterator<>`. Comparison operations or use of other operators on container element types may require the type be considered as both a left-hand and a right-hand operand. Use of the type as a right-hand operand can require implementation of the operator as a non-member function of the type.
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2673.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2673"
title: "Compiler Error C2673"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2673"
ms.date: 11/04/2016
f1_keywords: ["C2673"]
helpviewer_keywords: ["C2673"]
ms.assetid: 780230c0-619b-4a78-b01d-ff5886306741
---
# Compiler Error C2673

'function' : global functions do not have 'this' pointers
> 'function' : global functions do not have 'this' pointers

## Remarks

A global function tried to access **`this`**.

The following sample generates C2673:
## Example

The following example generates C2673:

```cpp
// C2673.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2674.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2674"
title: "Compiler Error C2674"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2674"
ms.date: 11/04/2016
f1_keywords: ["C2674"]
helpviewer_keywords: ["C2674"]
ms.assetid: 7cbd70d8-d992-44d7-a5cb-dd8cf9c759d2
---
# Compiler Error C2674

a generic declaration is not allowed in this context
> a generic declaration is not allowed in this context

## Remarks

A generic was declared incorrectly. For more information, see [Generics](../../extensions/generics-cpp-component-extensions.md).

## Example

The following sample generates C2674.
The following example generates C2674.

```cpp
// C2674.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2675.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2675"
title: "Compiler Error C2675"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2675"
ms.date: 11/04/2016
f1_keywords: ["C2675"]
helpviewer_keywords: ["C2675"]
ms.assetid: 4b92a12b-bff8-4dd5-a109-620065fc146c
---
# Compiler Error C2675

unary 'operator' : 'type' does not define this operator or a conversion to a type acceptable to the predefined operator
> unary 'operator' : 'type' does not define this operator or a conversion to a type acceptable to the predefined operator

## Remarks

C2675 can also occur when using a unary operator, and the type does not define the operator or a conversion to a type acceptable to the predefined operator. To use the operator, you must overload it for the specified type or define a conversion to a type for which the operator is defined.

## Example

The following sample generates C2675.
The following example generates C2675.

```cpp
// C2675.cpp
Expand Down
7 changes: 3 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c2676.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: Compiler Error C2676"
title: "Compiler Error C2676"
description: "Learn more about: Compiler Error C2676"
ms.date: 06/03/2022
f1_keywords: ["C2676"]
helpviewer_keywords: ["C2676"]
ms.assetid: 838a5e34-c92f-4f65-a597-e150bf8cf737
---
# Compiler Error C2676

Expand All @@ -16,7 +15,7 @@ To use the operator, you must overload it for the specified type or define a con

## Examples

The following sample generates C2676.
The following example generates C2676.

```cpp
// C2676.cpp
Expand Down Expand Up @@ -50,7 +49,7 @@ C2676 can also occur if you attempt to do pointer arithmetic on the **`this`** p

The **`this`** pointer is of type handle in a reference type. For more information, see [Semantics of the `this` pointer](../../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Semantics_of_the_this_pointer).

The following sample generates C2676.
The following example generates C2676.

```cpp
// C2676_a.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2677.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2677"
title: "Compiler Error C2677"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2677"
ms.date: 11/04/2016
f1_keywords: ["C2677"]
helpviewer_keywords: ["C2677"]
ms.assetid: 76bc0b65-f52a-45a6-b6d6-0555f89da9a8
---
# Compiler Error C2677

binary 'operator' : no global operator found which takes type 'type' (or there is no acceptable conversion)
> binary 'operator' : no global operator found which takes type 'type' (or there is no acceptable conversion)

## Remarks

To use the operator, you must overload it for the specified type or define a conversion to a type for which the operator is defined.

The following sample generates C2677:
## Example

The following example generates C2677:

```cpp
// C2677.cpp
Expand Down
13 changes: 7 additions & 6 deletions docs/error-messages/compiler-errors-2/compiler-error-c2678.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
---
description: "Learn more about: Compiler Error C2678"
title: "Compiler Error C2678"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2678"
ms.date: 11/04/2016
f1_keywords: ["C2678"]
helpviewer_keywords: ["C2678"]
ms.assetid: 1f0a4e26-b429-44f5-9f94-cb66441220c8
---
# Compiler Error C2678

binary 'operator' : no operator defined which takes a left-hand operand of type 'type' (or there is no acceptable conversion)
> binary 'operator' : no operator defined which takes a left-hand operand of type 'type' (or there is no acceptable conversion)

## Remarks

To use the operator, you must overload it for the specified type or define a conversion to a type for which the operator is defined.

C2678 can occur when the left-hand operand is const-qualified but the operator is defined to take a non-const argument.

## Examples

The following sample generates C2678 and shows how to fix it:
The following example generates C2678 and shows how to fix it:

```cpp
// C2678a.cpp
Expand All @@ -42,7 +43,7 @@ int main() {

C2678 can also occur if you do not pin a native member before calling a member function on it.

The following sample generates C2678 and shows how to fix it.
The following example generates C2678 and shows how to fix it.

```cpp
// C2678.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2679.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2679"
title: "Compiler Error C2679"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2679"
ms.date: 11/04/2016
f1_keywords: ["C2679"]
helpviewer_keywords: ["C2679"]
ms.assetid: 1a5f9d00-9190-4aa6-bc72-949f68ec136f
---
# Compiler Error C2679

binary 'operator' : no operator found which takes a right-hand operand of type 'type' (or there is no acceptable conversion)
> binary 'operator' : no operator found which takes a right-hand operand of type 'type' (or there is no acceptable conversion)

## Remarks

To use the operator, you must overload it for the specified type or define a conversion to a type for which the operator is defined.

The following sample generates C2679:
## Example

The following example generates C2679:

```cpp
// C2679.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2680.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2680"
title: "Compiler Error C2680"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2680"
ms.date: 11/04/2016
f1_keywords: ["C2680"]
helpviewer_keywords: ["C2680"]
ms.assetid: d6f7129e-dd17-4661-b680-18d6b925b1cc
---
# Compiler Error C2680

'type' : invalid target type for name
> 'type' : invalid target type for name

## Remarks

A casting operator tried to convert to a type that is not a pointer or reference. The [dynamic_cast](../../cpp/dynamic-cast-operator.md) operator can be used only for pointers or references.

The following sample generates C2680:
## Examples

The following example generates C2680:

```cpp
// C2680.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2681.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2681"
title: "Compiler Error C2681"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2681"
ms.date: 11/04/2016
f1_keywords: ["C2681"]
helpviewer_keywords: ["C2681"]
ms.assetid: eb42da6d-8d2c-43fd-986b-e73e2b004885
---
# Compiler Error C2681

'type' : invalid expression type for name
> 'type' : invalid expression type for name

## Remarks

A casting operator tried to convert from an invalid type. For example, if you use the [dynamic_cast](../../cpp/dynamic-cast-operator.md) operator to convert an expression to a pointer type, the source expression must be a pointer.

The following sample generates C2681:
## Example

The following example generates C2681:

```cpp
// C2681.cpp
Expand Down
15 changes: 9 additions & 6 deletions docs/error-messages/compiler-errors-2/compiler-error-c2682.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2682"
title: "Compiler Error C2682"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2682"
ms.date: 11/04/2016
f1_keywords: ["C2682"]
helpviewer_keywords: ["C2682"]
ms.assetid: 30c6a7c4-f5f7-4fe8-81a8-c48938521ab4
---
# Compiler Error C2682

cannot use casting_operator to convert from 'type1' to 'type2'
> cannot use casting_operator to convert from 'type1' to 'type2'

## Remarks

A casting operator tried to convert between incompatible types. For example, you cannot use the [dynamic_cast](../../cpp/dynamic-cast-operator.md) operator to convert a pointer to a reference. The **`dynamic_cast`** operator cannot be used to cast away qualifiers. All qualifiers on the types must match.

You can use the **`const_cast`** operator to remove attributes such as **`const`**, **`volatile`**, or **`__unaligned`**.

The following sample generates C2682:
## Examples

The following example generates C2682:

```cpp
// C2682.cpp
Expand All @@ -26,7 +29,7 @@ void g(A* pa) {
}
```

The following sample generates C2682:
The following example generates C2682:

```cpp
// C2682b.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2683.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2683"
title: "Compiler Error C2683"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2683"
ms.date: 11/04/2016
f1_keywords: ["C2683"]
helpviewer_keywords: ["C2683"]
ms.assetid: db605e4f-601b-4d05-92a1-c43ca24de08d
---
# Compiler Error C2683

'cast' : 'type' is not a polymorphic type
> 'cast' : 'type' is not a polymorphic type

## Remarks

You cannot use [dynamic_cast](../../cpp/dynamic-cast-operator.md) to convert from a non-polymorphic class (a class with no virtual functions).

You can use [static_cast](../../cpp/static-cast-operator.md) to perform conversions of non-polymorphic types. However, **`static_cast`** does not perform a run-time check.

The following sample generates C2683:
## Example

The following example generates C2683:

```cpp
// C2683.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2687.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2687"
title: "Compiler Error C2687"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2687"
ms.date: 11/04/2016
f1_keywords: ["C2687"]
helpviewer_keywords: ["C2687"]
ms.assetid: 1d24b24a-cd0f-41cc-975c-b08dcfb7f402
---
# Compiler Error C2687

'type' : exception-declaration cannot be 'void' or denote an incomplete type or pointer or reference to an incomplete type
> 'type' : exception-declaration cannot be 'void' or denote an incomplete type or pointer or reference to an incomplete type
## Remarks

For a type to be part of an exception declaration, it must be defined and not void.

The following sample generates C2687:
## Example

The following example generates C2687:

```cpp
// C2687.cpp
Expand Down
Loading