[Range] Definition of a range for gsl_vector

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

Karsten Ahnert skrev:
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; };
Why are you using gsl_vector* here? Why not gsl_vector? -Thorsten
participants (2)
-
Karsten Ahnert
-
Thorsten Ottosen