Sequence containers must have fill constructors and range constructors, i.e. they should work, suggesting that MyContainersimulates container sequence value_typewhich intand size_typeequals std::size_t:
MyContainer<int> c = MyContainer<int>(4, 42);
std::array<int, 4> array = {1, 2, 3, 4};
MyContainer<int> c2 = MyContainer<int>(array.begin(), array.end());
The problem is that I'm not sure how to implement these two constructors. These signatures do not work:
template<typename T>
MyContainer<T>::MyContainer(const MyContainer::size_type n, const MyContainer::value_type& val);
template<typename T>
template<typename OtherIterator>
MyContainer<T>::MyContainer(OtherIterator i, OtherIterator j);
In this case, the instance, as in example 1 above, selects the range constructor instead of the fill constructor, since it 4is an int, not a size_type. It works if I pass 4u, but if I understand the requirements correctly, any positive integer should work.
, , , value_type .
Visual ++ std::vector, , , (_Is_iterator<_Iter>). ++.
, ... ?
. ++ 11, boost .