Let's say you have a c++0x std::array member of a template class and you want to initialize it by means of a constructor that takes a couple of iterators:
template <typename Tp, size_t N>
class Test
{
public:
template <typename Iterator>
Test(Iterator first, Iterator last)
{
if (std::distance(first,last) > N )
throw std::runtime_error("bad range");
std::copy(first, last, _M_storage.begin());
}
private:
std::array<Tp, N> _M_storage;
};
Assuming that you are providing a range congruent with the size of your storage, is it possible to initialize the std::array in the constructor initializer, avoiding the superflous default constructors of Tps in the storage? Is it possible to exploit the std::initializer_list<> in this case?