यह वीएस2012 और वीएस2013 दोनों में एक बग है क्योंकि यह सी ++ 11 मानक (_HAS_CPP0X
के साथ परिभाषित नहीं है) के रूप में परिभाषित है 1):
सी ++ 03 23.1.1 [lib.sequence.reqmts]/9 का कहना है:
:
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.
लेकिन सी ++ 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.
निर्माता सभी
अधिक यहाँ पर विचार नहीं किया जाना चाहिए था कि किया गया: https://stackoverflow.com/a/12432482/1938163
एक कामकाज के रूप में आप "ओवरलोड रिज़ॉल्यूशन को थोड़ा" में सहायता कर सकते हैं, उदा।
std::vector<int> v(static_cast<std::vector<int>::size_type>(N), M);
स्रोत
2014-09-18 17:21:11
दोनों जीसीसी और क्लैंग ठीक हैं, यह एक बग की तरह लगता है। –
मुझे दृढ़ता से वीएस की बग पर संदेह है .. –