http://ift.tt/1pUDKXt lists all the vector ctors. But following two constructor cause compilation issues. Often in process of calling one, we end calling other.
vector( size_type count,
const T& value,
const Allocator& alloc = Allocator());
vector( std::initializer_list<T> init,
const Allocator& alloc = Allocator() );
And it often boils down to changing {} to () or vice-versa to make things work.
Is there a way to make the choice of ctor clear? without worrying about the brackets.
P.S.- If you put proper brackets, following code works perfectly.
vector{elem1, elem2}; // Initializer list version
vector(vector_size, elem); // A vector of size `vector_size` all the items having value = elem
Aucun commentaire:
Enregistrer un commentaire