1. constructor by iterator
template< class InputIt > vector( InputIt first, InputIt last, const Allocator& alloc = Allocator() ); | (until C++20) |
template< class InputIt > constexpr vector( InputIt first, InputIt last, const Allocator& alloc = Allocator() ); |
struct Base
{
uint32_t m_data;
};
class Test
{
public:
Test(Base a):m_base(a) {
};
Base m_base;
uint32_t m_data = 0;
};
int main()
{
std::vector<Base> va = {{1}, {2}, {3},{4}, {5}, {6}};
Base buf[6] = {{1}, {2}, {3},{4}, {5}, {6}};
std::vector<Test> vat(va.begin(), va.end()); // call the Test(Base a)
std::vector<Test> vat1(buf, buf+6); // call the Test(Base a)
return 0;
}