|
Boost Users : |
From: Kris Braun (kris_braun_at_[hidden])
Date: 2004-02-23 21:08:12
Hello,
I've spent the day trying to get my iterators working
after upgrading to 1.31.0. I'm almost there, but I
can't seem to get const and non-const versions to
compare with each other. I've tried about everything I
can think of, so I'll just post a minimal test that
fails in hopes that someone can see my mistake:
#include <iostream>
#include <list>
#include <boost/iterator/transform_iterator.hpp>
template< class Type >
struct do_nothing {
typedef Type result_type;
result_type operator( )( const Type& t )
{ return t; }
};
template< class Iterator >
class simple_iterator :
public boost::transform_iterator< do_nothing<
typename Iterator::value_type >, Iterator >
{
private:
typedef boost::transform_iterator< do_nothing<
typename Iterator::value_type >, Iterator >
super_t;
public:
simple_iterator( void )
{ }
simple_iterator( Iterator
iter )
: super_t( iter )
{ }
template< class Iterator2 >
simple_iterator(
const
simple_iterator< Iterator2 >& iter )
: super_t( iter.base(
) )
{ }
};
typedef std::list< int > ListType;
typedef simple_iterator< ListType::iterator >
iterator;
typedef simple_iterator< ListType::const_iterator >
const_iterator;
struct Foo {
iterator begin( void )
{ return iterator( m.begin( ) ); }
const_iterator end( void ) const
{ return const_iterator( m.end( ) ); }
ListType m;
};
void foo( void )
{
Foo f;
for( iterator i = f.begin( ); i != f.end( ); ++i )
{ }
}
which on VC7.1 yield
src\util\test.cpp(53) : error C2678: binary '!=' : no
operator found which takes a left-hand operand of type
'iterator' (or there is no acceptable conversion)
Any help would be much appreciated!
Cheers,
Kris
__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net