
Hi, If a pointer container holds noncopyable objects, the iterators seem not to meet ReadableIteratorConcept whose 'value_type' must be CopyConstructible? This doesn't compile: #include <boost/ptr_container/ptr_vector.hpp> #include <boost/concept_check.hpp> #include <boost/iterator/iterator_concepts.hpp> #include <boost/noncopyable.hpp> struct my : boost::noncopyable { }; template< class Iterator > void foo(Iterator) { boost::function_requires< boost_concepts::ReadableIteratorConcept<Iterator> >(); } int main() { boost::ptr_vector<my> vec; ::foo(vec.begin()); } Anything wrong..? -- Shunsuke Sogame

Shunsuke Sogame wrote:
Hi,
If a pointer container holds noncopyable objects, the iterators seem not to meet ReadableIteratorConcept whose 'value_type' must be CopyConstructible?
Anything wrong..?
Hm. I don't know. It seems counter-intuitive that a non-copyable type must be copyable. OTOH, for ptr_vector<T>, ptr_vector<T>::iterator's value_type is T (see detail/void_ptr_iterator.hpp). Maybe this should be changed to T*? -Thorsten

Shunsuke Sogame wrote:
Hi,
If a pointer container holds noncopyable objects, the iterators seem not to meet ReadableIteratorConcept whose 'value_type' must be CopyConstructible?
From http://www.boost.org/libs/iterator/doc/new-iter-concepts.html#readable-itera... it seems that the iterator type itself must be CC and CA. For a given iterator a, *a must be convertible to iterator_traits<X>::value_type (we'll use T for this below). For pointer containers, this currently poses quite a problem because of its indirected interface: the conversion could succeed if T was defined as iterator_traits<X>::reference, but the ReadableIteratorConcept does not allow T to be a reference type. The only thing I can come up with is that pointer container iterators does not satisfy the ReadableIteratorConcept, but only the ReadableLvalueIteratorConcept. Does that make sense? -Thorsten

Thorsten Ottosen wrote:
Shunsuke Sogame wrote:
Hi,
If a pointer container holds noncopyable objects, the iterators seem not to meet ReadableIteratorConcept whose 'value_type' must be CopyConstructible?
From
http://www.boost.org/libs/iterator/doc/new-iter-concepts.html#readable-itera...
it seems that the iterator type itself must be CC and CA. For a given iterator a, *a must be convertible to iterator_traits<X>::value_type (we'll use T for this below).
For pointer containers, this currently poses quite a problem because of its indirected interface: the conversion could succeed if T was defined as iterator_traits<X>::reference, but the ReadableIteratorConcept does not allow T to be a reference type.
The only thing I can come up with is that pointer container iterators does not satisfy the ReadableIteratorConcept, but only the ReadableLvalueIteratorConcept.
Does that make sense?
LvalueIteratorConcept? It seems to be right. I overlooked 'Readable' and 'Lvalue' is orthogonal. A concept checker of my alogorithm should have been something like... boost::function_requires< boost_concepts::ReadableIteratorConcept<Iterator> *OR* boost_concepts::LvalueIteratorConcept<Iterator> >(); I don't know how to OR, though :-( Thanks! -- Shunsuke Sogame
participants (2)
-
Shunsuke Sogame
-
Thorsten Ottosen