c++ - Base class with variadic template constructor wont copy-construct from derived class -


when compile code visual studio 2013 error:

error c2664: 'std::array<int,10>::array(const std::array<int,10> &)' : cannot convert argument 1 'initializer-list' 'const std::array<int,10> &' 

i thought derived class staticaly cast (sliced) base class always, why doesn't work here?

and thought work without explicit cast?

#include <array>  template <typename t> class { public:     std::array<t, 10> data;     template <typename... z>     a(z... ts) : data({ ts... }) { } };  template <typename t> class b : public a<t> { public:     template <typename... z>     b(z... ts) : a<t>({ ts... }) { } };  int main() {     b<int> w(1,4,3);     a<int> g(w); //cant construct derived class     a<int> h(static_vast< a<int> >(w)); //not cast      a<int> j(4,5);     a<int> t(j);  //regular copy constructor works      b<int> p(t); //works, can construct derived base     return 0; } 


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -