From cppreference.com
template<typenameT,std::size_tcnt>valarray(constT(&)[cnt],std::size_t)->valarray<T>;(since C++17)This
is provided for
to allow deduction from array and size (note that deduction from pointer and size is covered by the implicit guides).
Example
Run this code
#include<iostream>#include<valarray>intmain(){inta[]={1,2,3,4};std::valarrayva(a,3);// uses explicit deduction guidefor(intx:va)std::cout<<x<<' ';std::cout<<'\n';}Output:
1 2 3