Using gcc 3.2 (on MinGW) the template parameter defaults for
indirect_iterator_generator don't work with shared_ptr. This has been
discussed* on the list before, but there doesn't seem to have been a
user-friendly resolution to the issues involved (at least not in
release 1_30_0). Using my compiler, the current situation requires the
client code to supply all five of the template parameters.
*some previous threads on the subject:
http://groups.yahoo.com/group/Boost-Users/message/1618
http://lists.boost.org/MailArchives/boost/msg33273.php
http://lists.boost.org/MailArchives/boost/msg33316.php
My sample code:
#include
#include
#include <list>
int main ()
{
typedef std::list ListType;
typedef ListType::iterator BaseIterator;
typedef boost::indirect_iterator_generator<BaseIterator>::type Adapter;
}
Error output:
f:/mingw/include/c++/3.2/bits/stl_iterator_base_types.h: In
instantiation of `std::iterator_traits':
d:/CVS/boost/boost/boost/iterator_adaptors.hpp:1111: instantiated from
`boost::detail::iterator_traits'
d:/CVS/boost/boost/boost/iterator_adaptors.hpp:1111: instantiated from
`boost::detail::traits_of_value_type'
iterator_adapter.cc:9: instantiated from here
f:/mingw/include/c++/3.2/bits/stl_iterator_base_types.h:123: no type
named ` iterator_category' in `class boost::shared_ptr<int>'
f:/mingw/include/c++/3.2/bits/stl_iterator_base_types.h:125: no type
named ` difference_type' in `class boost::shared_ptr<int>'
Looking at iterator_adaptors.hpp:1111 we have (reformatted):
struct traits_of_value_type {
typedef typename boost::detail::iterator_traits<T>::value_type
outer_value;
typedef typename boost::detail::iterator_traits::value_type
value_type;
typedef typename boost::detail::iterator_traits::reference
reference;
typedef typename boost::detail::iterator_traits::pointer
pointer;
};
So traits_of_value_type tries to look up the *iterator_traits* of the
*value type* for the supplied iterator. Does the value type really
need to have complete iterator traits for the compiler to figure out
the defaults here? Is anybody working on improving the ease-of-use for
indirect_iterator_generator?
--
Raoul Gough
"Let there be one measure for wine throughout our kingdom, and one
measure for ale, and one measure for corn" - Magna Carta