Es ist ein Fehler in beiden VS2012 und VS2013, da es nicht mit dem C++ 11-Standard konform ist (mit _HAS_CPP0X
definiert als 1):
C++ 03 23.1.1 [lib.sequence.reqmts]/9 sagt:
For every sequence defined in this clause and in clause 21:
— the constructor template <class InputIterator> X(InputIterator f, InputIterator l, const Allocator& a = Allocator())
shall have the same effect as:
X(static_cast<typename X::size_type>(f), static_cast<typename X::value_type>(l), a)
if InputIterator
is an integral type.
aber von C++ 11 23.2.3 [sequence.reqmts]/14:
For every sequence container defined in this Clause and in Clause 21:
— If the constructor template <class InputIterator> X(InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type())
is called with a type InputIterator
that does not qualify as an input iterator, then the constructor shall not participate in overload resolution.
Das Konstruktor sollte nicht bei allen
Mehr hier in Betracht gezogen wurden: https://stackoverflow.com/a/12432482/1938163
Als Workaround könnten Sie "helfen, die Überladung Auflösung ein bisschen", z.
std::vector<int> v(static_cast<std::vector<int>::size_type>(N), M);
Sowohl gcc und clang sind in Ordnung, scheint wie ein Fehler. –
Ich vermute stark VS-Bug .. –