Created on 2005-12-17.00:00:00 last changed 172 months ago
Proposed resolution:
Duplicate: 589
[ Berlin: Some support, not universal, for respecting the explicit qualifier. ]
[ The following added by Howard and the example code was originally written by Dietmar. ]
Valid code below?
#include <vector> #include <iterator> #include <iostream> struct foo { explicit foo(int) {} }; int main() { std::vector<int> v_int; std::vector<foo> v_foo1(v_int.begin(), v_int.end()); std::vector<foo> v_foo2((std::istream_iterator<int>(std::cin)), std::istream_iterator<int>()); }
The iterator constructor X(i,j) for containers as defined in 23.1.1 and 23.2.2 does only require that i and j be input iterators but nothing is said about their associated value_type. There are three sensible options:
The issue has practical implications, and stdlib vendors have taken divergent approaches to it: Dinkumware follows 2, libstdc++ follows 3.
The same problem applies to the definition of insert(p,i,j) for sequences and insert(i,j) for associative contianers, as well as assign.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg2986 |
2010-10-21 18:28:33 | admin | set | messages: + msg2985 |
2010-10-21 18:28:33 | admin | set | messages: + msg2984 |
2005-12-17 00:00:00 | admin | create |