Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 894 Bytes

compiler-error-c2080.md

File metadata and controls

34 lines (26 loc) · 894 Bytes
description title ms.date f1_keywords helpviewer_keywords
Learn more about: Compiler Error C2080
Compiler Error C2080
08/18/2022
C2080
C2080

Compiler Error C2080

'identifier': the type for 'type' can only be deduced from a single initializer expression

Remarks

The compiler can only deduce the type for auto or decltype(auto) if the declaration uses direct list-initialization and the initializer-list has a single element.

Example

The following sample shows some declarations that cause C2080:

auto x1(1, 2);           // C2080
auto x2({4});            // C2080
decltype(auto) x3(1, 2); // C2080
decltype(auto) x4({4});  // C2080

To resolve the issue, use a single value initializer:

auto x1 = 1;             // Valid
auto x2(1);              // Valid
decltype(auto) x3 = 1;   // Valid
decltype(auto) x4(1);    // Valid