Is `auto`-array is a valid function parameter in C++20?

Viewed 147

Please consider this sample C++20 program:

#include <vector>
#include <iostream>

auto make_vector( auto v[2] ) { return std::vector{v[0], v[1]}; }

int main()
{
    int x[2] = {1, 2};
    auto v = make_vector( x );
    std::cout << v[0] << ' ' << v[1] << '\n';
}

Both GCC and Clang accept it (https://gcc.godbolt.org/z/jKT7GjMK6)

However the latest Visual Studio 2019 16.10.3 with /std:c++latest option rejects it:

error C3318: 'auto [2]': an array cannot have an element type that contains 'auto'

Is it a bug or limitation of MSVC, or this code is not required to work in C++20?

0 Answers
Related