Re: [Boost-users] [tuple] no easy access to get function

----- Mensaje original ----- De: Frank Birbacher <bloodymir.crap@gmx.net> Fecha: Sábado, Enero 21, 2006 2:29 am Asunto: [Boost-users] [tuple] no easy access to get function
Hi!
Today I wanted to std::transform a range of tuples into a sequence of one element. I thought I could just take the address of some tuple::get<N> function. Maybe also specify the Tuple type as template parameter [...] I'd rather want to take the address of boost::tuple::get<N,Tuple>, but the template parameters won't match.
Maybe you forgot the final s in "tuples" when writing boost::tuples::get<N,Tuple> ?? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

On Sat, 21 Jan 2006, JOAQUIN LOPEZ MU?Z wrote:
----- Mensaje original ----- De: Frank Birbacher <bloodymir.crap@gmx.net> Fecha: Sábado, Enero 21, 2006 2:29 am Asunto: [Boost-users] [tuple] no easy access to get function
Today I wanted to std::transform a range of tuples into a sequence of one element. I thought I could just take the address of some tuple::get<N> function. Maybe also specify the Tuple type as template parameter [...] I'd rather want to take the address of boost::tuple::get<N,Tuple>, but the template parameters won't match.
Maybe you forgot the final s in "tuples" when writing
boost::tuples::get<N,Tuple>
There is a thin wrapper declared in the boost namespace as well. The probleme is elsewhere. The argument to the get function is not a boost::tuple<>, but some base class template. Thus the template arguments of the function are not and an integer and a tuple, but an integer and something else (actually, a cons<HT,TT> if you look in the code). To take the address of such a function, you need to bind the integer, as well as HT and TT, not a tuple. However, I am wondering if there would be a problem to declare the thin wrapper simply like this (example with the const version): template< int N , typename Tuple > inline typename tuples::access_traits< typename tuples::element< N , Tuples >::type >::const_type get( const Tuple& t ) { return tuples::get< N >( c ) ; } ? -- François Duranleau LIGUM, Université de Montréal "Ne me demandez pas comment ça va, car je vous mentirai." - moi-même

Hi! I started to use more extensively Boost.Mpl recently, and I started as well to get ADL-related compile errors when a template argument is an MPL sequence. I could resolve the conflicts within my own code, but I hit one coming from Boost.Range. Here is a simple example that provokes an error (tested with g++ 4.0.3 and Boost 1.33.1): #include <boost/mpl/vector.hpp> #include <boost/range/begin.hpp> #include <vector> template < typename T > struct dummy {} ; void trouble() { typedef dummy< ::boost::mpl::vector< int > > vt ; typedef ::std::vector< const vt* > ct ; boost::const_begin( ct() ) ; } The compiler reports a conflict between boost::begin (called by boost::const_begin in <boost/range/begin.hpp>) and boost::mpl::begin. For now, I resolved it simply by changing the function boost::const_begin like this (in <boost/range/begin.hpp>): namespace boost { template< class T > inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type const_begin( const T& r ) { return boost::begin( r ); } } ^^^^^^^ Similarly for boost::end. However, if that call was really meant to be resolved through ADL, then it seems to me there is a problem, and I don't know if anything can be done. Any ideas? -- François Duranleau LIGUM, Université de Montréal "Ne me demandez pas comment ça va, car je vous mentirai." - moi-même

François Duranleau wrote:
Hi!
I started to use more extensively Boost.Mpl recently, and I started as well to get ADL-related compile errors when a template argument is an MPL sequence. I could resolve the conflicts within my own code, but I hit one coming from Boost.Range. Here is a simple example that provokes an error (tested with g++ 4.0.3 and Boost 1.33.1):
#include <boost/mpl/vector.hpp> #include <boost/range/begin.hpp> #include <vector>
template < typename T > struct dummy {} ;
void trouble() { typedef dummy< ::boost::mpl::vector< int > > vt ; typedef ::std::vector< const vt* > ct ;
boost::const_begin( ct() ) ; }
The compiler reports a conflict between boost::begin (called by boost::const_begin in <boost/range/begin.hpp>) and boost::mpl::begin.
For now, I resolved it simply by changing the function boost::const_begin like this (in <boost/range/begin.hpp>):
namespace boost { template< class T > inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type const_begin( const T& r ) { return boost::begin( r ); } } ^^^^^^^
Similarly for boost::end. However, if that call was really meant to be resolved through ADL, then it seems to me there is a problem, and I don't know if anything can be done.
Any ideas?
Hi, I maybe already post it. I hear ADL dependent way was rejected. Now that we must always add 'boost::'. It is obviously a bug of Boost.Range... Regards, MB p-stade.sourceforge.net
participants (3)
-
François Duranleau
-
JOAQUIN LOPEZ MU?Z
-
MB