My code:
#include <array>
struct Base {};
struct Derived : Base {};
void f_one(Base & foo) {}
void f_array(std::array<Base, 2> foo) {}
int main() {
Derived a;
f_one(a);
std::array<Derived, 2> b = {};
f_array(b);
return 0;
}
My error:
no known conversion from 'array<Derived, [...]>' to 'array<Base, [...]>' for 1st argument
Why is the compiler able to convert a single instance of Derived
to Base
but not an std::array
of them?