Please consider these types:
struct Part
{
float data;
};
struct Wrap
{
Wrap( const Part& p )
:data( p.data )
{}
float data;
};
Now I would like to use an std::array<Part, N> to initialize an std::array<Wrap, N>.
int main()
{
std::array<Part, 3> parts{ Part{ 1.0f }, Part{ 2.0f }, Part{ 3.0f } };
std::array<Wrap, 3> wrappers( parts );
return 0;
}
( This throws the error "conversion from 'std::array<Part, 3>' to non-scalar type 'std::array<Wrap, 3>' requested" )
How can I use an std::array of type T to initialize an std::array of a type which is constructable from T?