Boost logo

Boost Users :

From: Matt Steele (steelerm_at_[hidden])
Date: 2006-01-01 14:32:43


Hello Joaquin,

Thank you for your response.

> 2. I think that the code won't work as expected: const_mem_fun
> has some overloads of operator() in order to support
> chained pointers (http://tinyurl.com/9cd2v) that will hide
> the implicit conversion from const tuple<int>& to
> const tuple<int>::inherited&. Could you please try to insert
> some element in my_tuple_container_type? My hunch is that
> you'll get a compiler error about tuple<int> not having
> operator*. Please report back.

You're right; the code fails to compile and for the reason you give.

> remains. My suggestion is that you simply provide a user-defined
> key extractor like this (uncompiled, beware typos):
> template<typename Tuple,int N>
> struct tuple_member_extractor
> {
> typedef typename
> boost::tuples::element<N,Tuple>::type result_type;
>
> const result_type& operator()(const Tuple& t)const
> {
> return boost::tuples::get<N>(t);
> }
> };
>
> Hope this helps; I'd appreciate if you reported on the
> success/failure of this approach.
>

Your suggestion worked without any changes (runtime tested it
with a few toy calls to insert()/find() ). However, if instead of
invoking the global get<>() function template, I try to call the
member function template,

  return t.get<N>();

I get this compile error:

  error: invalid use of member (did you forget the '&' ?)

Do you know if this code should compile? If not, is there a way to call
a member function template in this context without relying on a global
function wrapper?

Thanks,

Matt


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