Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/_breadcrumb/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Docs
tocHref: /
topicHref: /
Expand Down
1 change: 1 addition & 0 deletions docs/assembler/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Compiler intrinsics and assembly language
href: ../intrinsics/index.yml
- name: Compiler intrinsics
Expand Down
1 change: 1 addition & 0 deletions docs/atl-mfc-shared/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: ATL-MFC shared classes
href: ../atl-mfc-shared/atl-mfc-shared-classes.md
- name: ATL-MFC concepts
Expand Down
1 change: 1 addition & 0 deletions docs/atl/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Active Template Library (ATL)
href: atl-com-desktop-components.md
- name: Active Template Library (ATL) concepts
Expand Down
1 change: 1 addition & 0 deletions docs/build-insights/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: "C++ Build Insights"
href: ../build-insights/index.yml
- name: "Get started with C++ Build Insights"
Expand Down
1 change: 1 addition & 0 deletions docs/build/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Projects and build systems
href: ../build/projects-and-build-systems-cpp.md
- name: Visual Studio projects - C++
Expand Down
1 change: 1 addition & 0 deletions docs/c-language/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: C language documentation
href: ../c-language/index.yml
- name: C language reference
Expand Down
1 change: 1 addition & 0 deletions docs/c-runtime-library/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: C runtime library (CRT) reference
href: ../c-runtime-library/c-run-time-library-reference.md
- name: CRT library features
Expand Down
1 change: 1 addition & 0 deletions docs/code-quality/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Code analysis documentation
href: ../code-quality/index.yml
- name: Overview
Expand Down
9 changes: 3 additions & 6 deletions docs/cpp/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: C++ language documentation
href: ../cpp/index.yml
- name: C++ language reference
Expand Down Expand Up @@ -69,9 +70,9 @@
href: ../cpp/void-cpp.md
- name: bool
href: ../cpp/bool-cpp.md
- name: false
- name: "false"
href: ../cpp/false-cpp.md
- name: true
- name: "true"
href: ../cpp/true-cpp.md
- name: char, wchar_t, char8_t, char16_t, char32_t
href: ../cpp/char-wchar-t-char16-t-char32-t.md
Expand Down Expand Up @@ -419,8 +420,6 @@
href: ../cpp/special-member-functions.md
- name: Static members
href: ../cpp/static-members-cpp.md
- name: C++ classes as value types
href: ../cpp/value-types-modern-cpp.md
- name: User-defined type conversions
href: ../cpp/user-defined-type-conversions-cpp.md
- name: Mutable data members
Expand Down Expand Up @@ -481,8 +480,6 @@
href: ../cpp/how-to-create-and-use-weak-ptr-instances.md
- name: "How to: Create and use CComPtr and CComQIPtr instances"
href: ../cpp/how-to-create-and-use-ccomptr-and-ccomqiptr-instances.md
- name: Pimpl for compile-time encapsulation
href: ../cpp/pimpl-for-compile-time-encapsulation-modern-cpp.md
- name: Exception handling in C++
items:
- name: Exception handling in C++
Expand Down
1 change: 1 addition & 0 deletions docs/cppcx/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: UWP development
href: ../cppcx/universal-windows-apps-cpp.md
- name: C++/CX language reference
Expand Down
1 change: 1 addition & 0 deletions docs/cross-platform/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Cross-platform mobile development with C++
href: ../cross-platform/index.yml
- name: Overview
Expand Down
1 change: 1 addition & 0 deletions docs/data/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Data access in Visual C++
href: ../data/data-access-in-cpp.md
- name: Data access programming (MFC-ATL)
Expand Down
1 change: 1 addition & 0 deletions docs/dotnet/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: .NET programming with C++/CLI
href: ../dotnet/dotnet-programming-with-cpp-cli-visual-cpp.md
- name: "Walkthrough: Compile a C++/CLI program that targets the CLR"
Expand Down
48 changes: 47 additions & 1 deletion docs/error-messages/compiler-errors-2/compiler-error-c2666.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: Compiler Error C2666"
title: "Compiler Error C2666"
ms.date: "11/04/2016"
ms.date: 10/18/2021
f1_keywords: ["C2666"]
helpviewer_keywords: ["C2666"]
ms.assetid: 78364d15-c6eb-439a-9088-e04a0176692b
Expand Down Expand Up @@ -30,6 +30,52 @@ int main() {
}
```

This error can be generated as a result of compiler conformance work that was done for Visual Studio 2019 version 16.1:

- A conversion that promotes an enumeration whose underlying type is fixed to its underlying type is better than one that promotes to the promoted underlying type, if the two are different.

The following example demonstrates how compiler behavior changes in Visual Studio 2019 version 16.1 and later versions:

```cpp
#include <type_traits>

enum E : unsigned char { e };

int f(unsigned int)
{
return 1;
}

int f(unsigned char)
{
return 2;
}

struct A {};
struct B : public A {};

int f(unsigned int, const B&)
{
return 3;
}

int f(unsigned char, const A&)
{
return 4;
}

int main()
{
// Calls f(unsigned char) in 16.1 and later. Called f(unsigned int) in earlier versions.
// The conversion from 'E' to the fixed underlying type 'unsigned char' is better than the
// conversion from 'E' to the promoted type 'unsigned int'.
f(e);

// Error C2666. This call is ambiguous, but previously called f(unsigned int, const B&).
f(e, B{});
}
```

This error can also be generated as a result of compiler conformance work that was done for Visual Studio .NET 2003:

- binary operators and user-defined conversions to pointer types
Expand Down
1 change: 1 addition & 0 deletions docs/error-messages/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: C/C++ Compiler and build tools errors and warnings
href: compiler-errors-1/c-cpp-build-errors.md
- name: BSCMAKE errors and warnings
Expand Down
1 change: 1 addition & 0 deletions docs/extensions/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Component Extensions for .NET and UWP
href: ../extensions/component-extensions-for-runtime-platforms.md
- name: Tracking reference operator
Expand Down
1 change: 1 addition & 0 deletions docs/get-started/breadcrumb/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Docs
tocHref: /
topicHref: /
Expand Down
1 change: 1 addition & 0 deletions docs/ide/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Read and write C++ code in Visual Studio
expanded: true
items:
Expand Down
1 change: 1 addition & 0 deletions docs/intrinsics/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Compiler intrinsics and assembly language
href: ../intrinsics/index.yml
- name: Compiler intrinsics
Expand Down
1 change: 1 addition & 0 deletions docs/linux/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Linux with Visual Studio C++ documentation
href: ../linux/index.yml
- name: Download, install, and set up the Linux Development workload
Expand Down
1 change: 1 addition & 0 deletions docs/mfc/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: MFC desktop applications
href: mfc-desktop-applications.md
- name: MFC concepts
Expand Down
60 changes: 59 additions & 1 deletion docs/overview/cpp-conformance-improvements.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "C++ conformance improvements in Visual Studio 2019"
description: "Microsoft C++ in Visual Studio is progressing toward full conformance with the C++20 language standard."
ms.date: 06/11/2021
ms.date: 10/18/2021
ms.technology: "cpp-language"
---
# C++ Conformance improvements, behavior changes, and bug fixes in Visual Studio 2019
Expand Down Expand Up @@ -523,6 +523,58 @@ void f() {

[P0329R4](https://wg21.link/p0329r4) (C++20) *Designated initialization* allows specific members to be selected in aggregate initialization by using the `Type t { .member = expr }` syntax. Requires **`/std:c++latest`** (or **`/std:c++20`** starting in Visual Studio 2019 version 16.11).

### Ranking of enum conversion to its fixed underlying type

The compiler now ranks enum conversions according to [N4800](https://wg21.link/n4800) 11.3.3.2 Ranking implicit conversion sequences (4.2):

- A conversion that promotes an enumeration whose underlying type is fixed to its underlying type is better than one that promotes to the promoted underlying type, if the two are different.

This conversion ranking wasn't implemented correctly before Visual Studio 2019 version 16.1. The conforming behavior may change overload resolution behavior or expose an ambiguity where one previously was not detected.

This compiler behavior change applies to all **`/std`** modes and is both a source and binary breaking change.

The following example demonstrates how compiler behavior changes in 16.1 and later versions:

```cpp
#include <type_traits>

enum E : unsigned char { e };

int f(unsigned int)
{
return 1;
}

int f(unsigned char)
{
return 2;
}

struct A {};
struct B : public A {};

int f(unsigned int, const B&)
{
return 3;
}

int f(unsigned char, const A&)
{
return 4;
}

int main()
{
// Calls f(unsigned char) in 16.1 and later. Called f(unsigned int) in earlier versions.
// The conversion from 'E' to the fixed underlying type 'unsigned char' is better than the
// conversion from 'E' to the promoted type 'unsigned int'.
f(e);

// Error C2666. This call is ambiguous, but previously called f(unsigned int, const B&).
f(e, B{});
}
```

### New and updated standard library functions (C++20)

- `starts_with()` and `ends_with()` for `basic_string` and `basic_string_view`.
Expand Down Expand Up @@ -2462,6 +2514,12 @@ struct S {
};
```

## <a name="improvements_16b"></a> Conformance improvements in Visual Studio 2019 version 16.11

### `/std:c++20` compiler mode

Starting in Visual Studio 2019 version 16.11, the compiler now supports the [`/std:c++20`](../build/reference/std-specify-language-standard-version.md) compiler mode. Previously, C++20 features were available only in [`/std:c++latest`](../build/reference/std-specify-language-standard-version.md) mode in Visual Studio 2019. Features that originally required **`/std:c++latest`** mode now work in **`/std:c++20`** mode or later in the latest versions of Visual Studio.

## See also

[Microsoft C/C++ language conformance](visual-cpp-language-conformance.md)
1 change: 1 addition & 0 deletions docs/overview/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Microsoft C/C++ in Visual Studio
expanded: false
items:
Expand Down
1 change: 1 addition & 0 deletions docs/parallel/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Parallel programming in MSVC
href: ../parallel/parallel-programming-in-visual-cpp.md
- name: Auto-parallelization and auto-vectorization
Expand Down
1 change: 1 addition & 0 deletions docs/porting/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Microsoft C++ Porting and Upgrade Guide
href: ../porting/visual-cpp-porting-and-upgrading-guide.md
- name: Upgrade projects from earlier versions
Expand Down
1 change: 1 addition & 0 deletions docs/preprocessor/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: C/C++ preprocessor reference
href: ../preprocessor/c-cpp-preprocessor-reference.md
- name: Preprocessor
Expand Down
1 change: 1 addition & 0 deletions docs/sanitizers/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: "Code Sanitizers"
href: ../sanitizers/index.yml
- name: "AddressSanitizer"
Expand Down
1 change: 1 addition & 0 deletions docs/standard-library/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: C++ Standard Library reference
href: cpp-standard-library-reference.md
- name: C++ Standard Library header files
Expand Down
1 change: 1 addition & 0 deletions docs/text/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Text and strings in MSVC
href: ../text/text-and-strings-in-visual-cpp.md
- name: Unicode and MBCS
Expand Down
1 change: 1 addition & 0 deletions docs/windows/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Overview of Windows programming in C++
href: ../windows/overview-of-windows-programming-in-cpp.md
- name: Desktop Applications in C++
Expand Down