|
Boost : |
From: Larry Evans (cppljevans_at_[hidden])
Date: 2005-01-17 16:47:06
On 01/16/2005 03:11 PM, Larry Evans wrote:
> On 01/15/2005 05:26 PM, David Abrahams wrote:
[snip]
> >
> > Finally, the kind of access being done is completely different from
> > what's done with tuple.
>
> I've not looked *real* close at tuple, but I assumed boost::tuple had
> the following type of access:
[snip]
> Could you elaborate on how the kinds of element access in boost::tuple
> and that of tuple_type in get_ith_head_test.cpp are different?
Maybe you meant the way element access was being done. I've
just looked at boost/tuple/detail/tuple_basic.hpp. I see two
templates which may be candidates for how tuple implements get. The
first is:
template< int N >
struct get_class {
template<class RET, class HT, class TT >
inline static RET get(const cons<HT, TT>& t)
{
#if BOOST_WORKAROUND(__IBMCPP__,==600)
// vacpp 6.0 is not very consistent regarding the member template
keyword
// Here it generates an error when the template keyword is used.
return get_class<N-1>::get<RET>(t.tail);
#else
return get_class<N-1>::BOOST_NESTED_TEMPLATE get<RET>(t.tail);
#endif
}
...
and the 2nd, which looks closer to what could be the implementation
is prefixed with comment:
// -cons type accessors ----------------------------------------
// typename tuples::element<N,T>::type gets the type of the
// Nth element ot T, first element is at index 0
// -------------------------------------------------------
but the code for that looks very similar to get_ith_tail. The
difference is that get_ith_tail uses specialization to split apart the
Head and Tail parts and recurses on the Tail, whereas tuples:element
uses the nested typedef for tail_type to recurse on the tail.
Do you mean this is completely different, or is there some other code
I should look at to see how tuple accesses its elements?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk