[type_erasure] Using any with iterator Concept.

Hi, I'm trying to use type-erased iterator in STL algorithms, e.g. copy but get errors like this one: error C2039: 'iterator_category' : is not a member of 'boost::type_erasure::any<Concept>' c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility 373 of course any doesn't define iterator_category. I'm using MSVC2010 and doing something like this: typedef boost::type_erasure::any< boost::type_erasure::iterator< boost::single_pass_traversal_tag >
iterator;
// ... iterator first = return_some_iterator(...); iterator last = return_some_iterator(...); // BAM! std::copy(first, last, std::back_inserter(result)); // BAM! typedef iterator::iterator_category C; I simply tried to add it to the iterator<> Concept defined in iterator.hpp but this didn't help: template<...> struct iterator< ::boost::single_pass_traversal_tag, ...> : iterator< ::boost::incrementable_traversal_tag, ...> { typedef ValueType value_type; typedef typename iterator_reference< Reference, ValueType >::type reference; typedef DifferenceType difference_type; typedef std::input_iterator_tag iterator_category; }; Am I doing something wrong or is it an error in Boost.TypeErasure? Regards, Adam Wulkiewicz

AMDG On 04/26/2013 09:22 AM, Adam Wulkiewicz wrote:
I'm trying to use type-erased iterator in STL algorithms, e.g. copy but get errors like this one:
error C2039: 'iterator_category' : is not a member of 'boost::type_erasure::any<Concept>' c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility 373
of course any doesn't define iterator_category. I'm using MSVC2010 and doing something like this:
typedef boost::type_erasure::any< boost::type_erasure::iterator< boost::single_pass_traversal_tag >
iterator;
<snip>
I simply tried to add it to the iterator<> Concept defined in iterator.hpp but this didn't help:
template<...> struct iterator< ::boost::single_pass_traversal_tag, ...> : iterator< ::boost::incrementable_traversal_tag, ...> { <snip> typedef std::input_iterator_tag iterator_category; };
Am I doing something wrong or is it an error in Boost.TypeErasure?
The code currently supports only forward_traversal_tag, bidirectional_traversal_tag, and random_access_traversal_tag. What needs to be added is another concept_interface specialization. In Christ, Steven Watanabe

Hi, Steven Watanabe wrote:
The code currently supports only forward_traversal_tag, bidirectional_traversal_tag, and random_access_traversal_tag.
What needs to be added is another concept_interface specialization.
Of course, thanks. Now it works as expected. With the patch sent in the other email also bidirection iterator Concept must be tweaked since now it must use requirements from forward iterator Concept. I've run tests and on MSVC2010 and clang everything is ok but on MinGW and GCC 4.7 there is an error: boost/mpl/aux_/preprocessed/gcc/arg.hpp:45:9: error: template instantiation depth exceeds maximum of 128 in test_forward_iterator. After some tweaks (no_traversal iterator as a base Concept) it's ok for forward iterator but there are no tests for bidirectional and random access one. It's possible that this error will occur for those iterators even without my change. So just in case I've also set no_traversal_tag as a base Concept for those too. One might also try to implement only one concept_interface using boost::iterator_facade<...>::iterator_category or boost::detail::facade_iterator_category<> to be consistent with Boost.Iterator. I hope this would be useful. Do you know if Boost.TypeErasure is going to be released in 1.54 (preferably with similar changes)? I'm considering using it in Geometry.Index. Best regards, Adam Wulkiewicz
participants (2)
-
Adam Wulkiewicz
-
Steven Watanabe