In the C++ Standard there is the following deduction guide for the template class std::valarray<T>
:
template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>;
However among the constructors of the class there is only the following appropriate constructor (or am I mistaken?)
valarray(const T&, size_t);
However if to run the following demonstrative program with a similar deduction guide
#include <iostream>
#include <utility>
template <typename T>
struct A
{
A( const T &, size_t ) { std::cout << "A<T>()\n"; }
};
template<class T, size_t cnt>
A(const T(&)[cnt], size_t) -> A<T>;
int main()
{
int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
A obj( a, std::size( a ) );
}
the gcc compiler issues error
rog.cc:17:12: error: invalid conversion from 'int*' to 'int' [-fpermissive]
17 | A obj( a, std::size( a ) );
| ^
| |
| int*
prog.cc:7:8: note: initializing argument 1 of 'A<T>::A(const T&, size_t) [with T = int; size_t = long unsigned int]'
7 | A( const T &, size_t ) { std::cout << "A<T>()\n"; }
| ^~~~~~~~~
So a question arises whether it is a defect of the C++ Standard, or a bug of the compiler or I missed something.