|
Boost Users : |
Subject: [Boost-users] [Range] Definition of a range for gsl_vector
From: Karsten Ahnert (karsten.ahnert_at_[hidden])
Date: 2010-07-11 18:55:30
Hi,
I want to define a range for gsl_vector's. I have tried many versions
according to the manual but none is working. Maybe someone here could
help me.
This is what I do, or least what I think is most promising (the full
code can be found in the attachment):
namespace boost {
template<> struct range_iterator< gsl_vector* >
{
typedef gsl_vector_iterator type;
};
template<>
struct range_iterator< const gsl_vector* >
{
typedef const_gsl_vector_iterator type;
};
range_iterator< gsl_vector* >::type begin( gsl_vector* &x )
{
return gsl_vector_iterator( x );
}
range_iterator< const gsl_vector* >::type begin( const gsl_vector* &x )
{
return const_gsl_vector_iterator( x );
}
range_iterator< gsl_vector* >::type end( gsl_vector* &x )
{
return end_iterator( x );
}
range_iterator< const gsl_vector* >::type end( const gsl_vector* &x )
{
return end_iterator( x );
}
} // namespace boost
The iterators for gsl_vector are defined separately in the attachment.
If I now try to use the range via
typedef boost::range_iterator< gsl_vector* > gsl_iter_type;
gsl_iter_type::type i3 = boost::begin( vec );
gsl_iter_type::type i4 = boost::end( vec );
I get the following compile errors:
/home/karsten/boost/boost_1_43_0/boost/mpl/eval_if.hpp: In Instantiation
of boost::mpl::eval_if_c<true,
boost::range_const_iterator<gsl_vector*>,
boost::range_mutable_iterator<gsl_vector* const> >:
/home/karsten/boost/boost_1_43_0/boost/range/iterator.hpp:63:
instantiated from boost::range_iterator<gsl_vector* const>
../src/test_gsl_iterator.cpp:23: instantiated from here
/home/karsten/boost/boost_1_43_0/boost/mpl/eval_if.hpp:60: error: no
type named type in struct boost::range_const_iterator<gsl_vector*>
make: *** [src/test_gsl_iterator.o] Error 1
This is somehow strange, since begin() and end() are not used from my
definition, but from the original defintions in the Range library. Can
someone help me with this? What am I doing wrong?
Best regards,
Karsten
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