merged tuples_subnamespace branch to main trunk

[SVN r11121]
This commit is contained in:
Jaakko Järvi
2001-09-14 07:55:58 +00:00
parent 531fb617eb
commit 5b40ff62c6
5 changed files with 330 additions and 325 deletions

View File

@ -36,15 +36,14 @@
#include "boost/type_traits/cv_traits.hpp"
namespace boost {
namespace tuples {
// -- null_type --------------------------------------------------------
struct null_type {};
// a helper function to provide a const null_type type temporary
namespace detail {
namespace tuples {
inline const null_type cnull_type() { return null_type(); }
} // end tuples
} // end detail
// - cons forward declaration -----------------------------------------------
@ -60,12 +59,11 @@ template <
class tuple;
// tuple_length forward declaration
template<class T> struct tuple_length;
template<class T> struct length;
namespace detail {
namespace tuples {
// -- generate error template, referencing to non-existing members of this
// template is used to produce compilation errors intentionally
@ -108,24 +106,24 @@ struct default_arg<T&> {
};
// - cons getters --------------------------------------------------------
// called: element<N>::get<RETURN_TYPE>(aTuple)
// called: get_class<N>::get<RETURN_TYPE>(aTuple)
template< int N >
struct element {
struct get_class {
template<class RET, class HT, class TT >
inline static RET get(const cons<HT, TT>& t)
{
return element<N-1>::template get<RET>(t.tail);
return get_class<N-1>::template get<RET>(t.tail);
}
template<class RET, class HT, class TT >
inline static RET get(cons<HT, TT>& t)
{
return element<N-1>::template get<RET>(t.tail);
return get_class<N-1>::template get<RET>(t.tail);
}
};
template<>
struct element<0> {
struct get_class<0> {
template<class RET, class HT, class TT>
inline static RET get(const cons<HT, TT>& t)
{
@ -138,25 +136,24 @@ struct element<0> {
}
};
} // end of namespace tuples
} // end of namespace detail
// -cons type accessors ----------------------------------------
// typename tuple_element<N,T>::type gets the type of the
// typename tuples::element<N,T>::type gets the type of the
// Nth element ot T, first element is at index 0
// -------------------------------------------------------
template<int N, class T>
struct tuple_element
struct element
{
private:
typedef typename T::tail_type Next;
public:
typedef typename tuple_element<N-1, Next>::type type;
typedef typename element<N-1, Next>::type type;
};
template<class T>
struct tuple_element<0,T>
struct element<0,T>
{
typedef typename T::head_type type;
};
@ -170,7 +167,7 @@ struct tuple_element<0,T>
// (Joel de Guzman's suggestion). Rationale: get functions are part of the
// interface, so should the way to express their return types be.
template <class T> struct tuple_access_traits {
template <class T> struct access_traits {
typedef const T& const_type;
typedef T& non_const_type;
@ -182,7 +179,7 @@ template <class T> struct tuple_access_traits {
// be non-volatile and const. 8.5.3. (5)
};
template <class T> struct tuple_access_traits<T&> {
template <class T> struct access_traits<T&> {
typedef T& const_type;
typedef T& non_const_type;
@ -194,14 +191,14 @@ template <class T> struct tuple_access_traits<T&> {
// get function for non-const cons-lists, returns a reference to the element
template<int N, class HT, class TT>
inline typename tuple_access_traits<
typename tuple_element<N, cons<HT, TT> >::type
inline typename access_traits<
typename element<N, cons<HT, TT> >::type
>::non_const_type
get(cons<HT, TT>& c) {
return detail::tuples::element<N>::template
return detail::get_class<N>::template
get<
typename tuple_access_traits<
typename tuple_element<N, cons<HT, TT> >::type
typename access_traits<
typename element<N, cons<HT, TT> >::type
>::non_const_type>(c);
}
@ -209,14 +206,14 @@ get(cons<HT, TT>& c) {
// the element. If the element is a reference, returns the reference
// as such (that is, can return a non-const reference)
template<int N, class HT, class TT>
inline typename tuple_access_traits<
typename tuple_element<N, cons<HT, TT> >::type
inline typename access_traits<
typename element<N, cons<HT, TT> >::type
>::const_type
get(const cons<HT, TT>& c) {
return detail::tuples::element<N>::template
return detail::get_class<N>::template
get<
typename tuple_access_traits<
typename tuple_element<N, cons<HT, TT> >::type
typename access_traits<
typename element<N, cons<HT, TT> >::type
>::const_type>(c);
}
@ -234,25 +231,25 @@ struct cons {
head_type head;
tail_type tail;
typename tuple_access_traits<head_type>::non_const_type
typename access_traits<head_type>::non_const_type
get_head() { return head; }
typename tuple_access_traits<tail_type>::non_const_type
typename access_traits<tail_type>::non_const_type
get_tail() { return tail; }
typename tuple_access_traits<head_type>::const_type
typename access_traits<head_type>::const_type
get_head() const { return head; }
typename tuple_access_traits<tail_type>::const_type
typename access_traits<tail_type>::const_type
get_tail() const { return tail; }
cons() : head(detail::tuples::default_arg<HT>::f()), tail() {}
cons() : head(detail::default_arg<HT>::f()), tail() {}
// the argument for head is not strictly needed, but it prevents
// array type elements. This is good, since array type elements
// cannot be supported properly in any case (no assignment,
// copy works only if the tails are exactly the same type, ...)
cons(typename tuple_access_traits<head_type>::parameter_type h,
cons(typename access_traits<head_type>::parameter_type h,
const tail_type& t)
: head (h), tail(t) {}
@ -261,7 +258,7 @@ struct cons {
cons( T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
T6& t6, T7& t7, T8& t8, T9& t9, T10& t10 )
: head (t1),
tail (t2, t3, t4, t5, t6, t7, t8, t9, t10, detail::tuples::cnull_type())
tail (t2, t3, t4, t5, t6, t7, t8, t9, t10, detail::cnull_type())
{}
template <class HT2, class TT2>
@ -280,22 +277,22 @@ struct cons {
template <class T1, class T2>
cons& operator=( const std::pair<T1, T2>& u ) {
BOOST_STATIC_ASSERT(tuple_length<cons>::value == 2); // check length = 2
BOOST_STATIC_ASSERT(length<cons>::value == 2); // check length = 2
head = u.first; tail.head = u.second; return *this;
}
// get member functions (non-const and const)
template <int N>
typename tuple_access_traits<
typename tuple_element<N, cons<HT, TT> >::type
typename access_traits<
typename element<N, cons<HT, TT> >::type
>::non_const_type
get() {
return boost::get<N>(*this); // delegate to non-member get
}
template <int N>
typename tuple_access_traits<
typename tuple_element<N, cons<HT, TT> >::type
typename access_traits<
typename element<N, cons<HT, TT> >::type
>::const_type
get() const {
return boost::get<N>(*this); // delegate to non-member get
@ -310,19 +307,19 @@ struct cons<HT, null_type> {
head_type head;
typename tuple_access_traits<head_type>::non_const_type
typename access_traits<head_type>::non_const_type
get_head() { return head; }
null_type get_tail() { return null_type(); }
typename tuple_access_traits<head_type>::const_type
typename access_traits<head_type>::const_type
get_head() const { return head; }
const null_type get_tail() const { return null_type(); }
cons() : head(detail::tuples::default_arg<HT>::f()) {}
cons() : head(detail::default_arg<HT>::f()) {}
cons(typename tuple_access_traits<head_type>::parameter_type h,
cons(typename access_traits<head_type>::parameter_type h,
const null_type& = null_type())
: head (h) {}
@ -344,16 +341,16 @@ struct cons<HT, null_type> {
cons& operator=(const cons& u) { head = u.head; return *this; }
template <int N>
typename tuple_access_traits<
typename tuple_element<N, cons>::type
typename access_traits<
typename element<N, cons>::type
>::non_const_type
get() {
return boost::get<N>(*this);
}
template <int N>
typename tuple_access_traits<
typename tuple_element<N, cons>::type
typename access_traits<
typename element<N, cons>::type
>::const_type
get() const {
return boost::get<N>(*this);
@ -364,18 +361,17 @@ struct cons<HT, null_type> {
// templates for finding out the length of the tuple -------------------
template<class T>
struct tuple_length {
BOOST_STATIC_CONSTANT(int, value = 1 + tuple_length<typename T::tail_type>::value);
struct length {
BOOST_STATIC_CONSTANT(int, value = 1 + length<typename T::tail_type>::value);
};
template<>
struct tuple_length<null_type> {
struct length<null_type> {
BOOST_STATIC_CONSTANT(int, value = 0);
};
namespace detail {
namespace tuples {
// Tuple to cons mapper --------------------------------------------------
template <class T0, class T1, class T2, class T3, class T4,
@ -395,7 +391,6 @@ struct map_tuple_to_cons<null_type, null_type, null_type, null_type, null_type,
typedef null_type type;
};
} // end tuples
} // end detail
// -------------------------------------------------------------------
@ -404,37 +399,37 @@ template <class T0, class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8, class T9>
class tuple :
public detail::tuples::map_tuple_to_cons<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type
public detail::map_tuple_to_cons<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type
{
public:
typedef typename
detail::tuples::map_tuple_to_cons<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type inherited;
detail::map_tuple_to_cons<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type inherited;
typedef typename inherited::head_type head_type;
typedef typename inherited::tail_type tail_type;
// tuple_access_traits<T>::parameter_type takes non-reference types as const T&
// access_traits<T>::parameter_type takes non-reference types as const T&
explicit tuple(
typename tuple_access_traits<T0>::parameter_type t0
= detail::tuples::default_arg<T0>::f(),
typename tuple_access_traits<T1>::parameter_type t1
= detail::tuples::default_arg<T1>::f(),
typename tuple_access_traits<T2>::parameter_type t2
= detail::tuples::default_arg<T2>::f(),
typename tuple_access_traits<T3>::parameter_type t3
= detail::tuples::default_arg<T3>::f(),
typename tuple_access_traits<T4>::parameter_type t4
= detail::tuples::default_arg<T4>::f(),
typename tuple_access_traits<T5>::parameter_type t5
= detail::tuples::default_arg<T5>::f(),
typename tuple_access_traits<T6>::parameter_type t6
= detail::tuples::default_arg<T6>::f(),
typename tuple_access_traits<T7>::parameter_type t7
= detail::tuples::default_arg<T7>::f(),
typename tuple_access_traits<T8>::parameter_type t8
= detail::tuples::default_arg<T8>::f(),
typename tuple_access_traits<T9>::parameter_type t9
= detail::tuples::default_arg<T9>::f())
typename access_traits<T0>::parameter_type t0
= detail::default_arg<T0>::f(),
typename access_traits<T1>::parameter_type t1
= detail::default_arg<T1>::f(),
typename access_traits<T2>::parameter_type t2
= detail::default_arg<T2>::f(),
typename access_traits<T3>::parameter_type t3
= detail::default_arg<T3>::f(),
typename access_traits<T4>::parameter_type t4
= detail::default_arg<T4>::f(),
typename access_traits<T5>::parameter_type t5
= detail::default_arg<T5>::f(),
typename access_traits<T6>::parameter_type t6
= detail::default_arg<T6>::f(),
typename access_traits<T7>::parameter_type t7
= detail::default_arg<T7>::f(),
typename access_traits<T8>::parameter_type t8
= detail::default_arg<T8>::f(),
typename access_traits<T9>::parameter_type t9
= detail::default_arg<T9>::f())
: inherited(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) {}
@ -449,7 +444,7 @@ public:
template <class U1, class U2>
tuple& operator=(const std::pair<U1, U2>& k) {
BOOST_STATIC_ASSERT(tuple_length<tuple>::value == 2);// check_length = 2
BOOST_STATIC_ASSERT(length<tuple>::value == 2);// check_length = 2
this->head = k.first;
this->tail.head = k.second;
return *this;
@ -469,7 +464,6 @@ public:
// Swallows any assignment (by Doug Gregor)
namespace detail {
namespace tuples {
struct swallow_assign {
@ -478,12 +472,12 @@ struct swallow_assign {
return *this;
}
};
} // namespace tuples
} // namespace detail
// "ignore" allows tuple positions to be ignored when using "tie".
namespace {
detail::tuples::swallow_assign ignore;
detail::swallow_assign ignore;
}
// ---------------------------------------------------------------------------
@ -530,7 +524,7 @@ struct make_tuple_traits {
template<class T>
struct make_tuple_traits<T&> {
typedef typename
detail::tuples::generate_error<T&>::
detail::generate_error<T&>::
do_not_use_with_reference_type error;
};
@ -570,7 +564,6 @@ struct make_tuple_traits<const reference_wrapper<T> >{
namespace detail {
namespace tuples {
// a helper traits to make the make_tuple functions shorter (Vesa Karvonen's
// suggestion)
@ -594,7 +587,6 @@ struct make_tuple_mapper {
typename make_tuple_traits<T9>::type> type;
};
} // end tuples
} // end detail
// -make_tuple function templates -----------------------------------
@ -603,85 +595,85 @@ inline tuple<> make_tuple() {
}
template<class T0>
inline typename boost::detail::tuples::make_tuple_mapper<T0>::type
inline typename detail::make_tuple_mapper<T0>::type
make_tuple(const T0& t0) {
return typename boost::detail::tuples::make_tuple_mapper<T0>::type(t0);
return typename detail::make_tuple_mapper<T0>::type(t0);
}
template<class T0, class T1>
inline typename boost::detail::tuples::make_tuple_mapper<T0, T1>::type
inline typename detail::make_tuple_mapper<T0, T1>::type
make_tuple(const T0& t0, const T1& t1) {
return typename boost::detail::tuples::make_tuple_mapper<T0, T1>::type(t0, t1);
return typename detail::make_tuple_mapper<T0, T1>::type(t0, t1);
}
template<class T0, class T1, class T2>
inline typename boost::detail::tuples::make_tuple_mapper<T0, T1, T2>::type
inline typename detail::make_tuple_mapper<T0, T1, T2>::type
make_tuple(const T0& t0, const T1& t1, const T2& t2) {
return typename boost::detail::tuples::make_tuple_mapper<T0, T1, T2>::type(t0, t1, t2);
return typename detail::make_tuple_mapper<T0, T1, T2>::type(t0, t1, t2);
}
template<class T0, class T1, class T2, class T3>
inline typename boost::detail::tuples::make_tuple_mapper<T0, T1, T2, T3>::type
inline typename detail::make_tuple_mapper<T0, T1, T2, T3>::type
make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3) {
return typename boost::detail::tuples::make_tuple_mapper<T0, T1, T2, T3>::type
return typename detail::make_tuple_mapper<T0, T1, T2, T3>::type
(t0, t1, t2, t3);
}
template<class T0, class T1, class T2, class T3, class T4>
inline typename boost::detail::tuples::make_tuple_mapper<T0, T1, T2, T3, T4>::type
inline typename detail::make_tuple_mapper<T0, T1, T2, T3, T4>::type
make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3,
const T4& t4) {
return typename boost::detail::tuples::make_tuple_mapper<T0, T1, T2, T3, T4>::type
return typename detail::make_tuple_mapper<T0, T1, T2, T3, T4>::type
(t0, t1, t2, t3, t4);
}
template<class T0, class T1, class T2, class T3, class T4, class T5>
inline typename boost::detail::tuples::make_tuple_mapper<T0, T1, T2, T3, T4, T5>::type
inline typename detail::make_tuple_mapper<T0, T1, T2, T3, T4, T5>::type
make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3,
const T4& t4, const T5& t5) {
return typename boost::detail::tuples::make_tuple_mapper<T0, T1, T2, T3, T4, T5>::type
return typename detail::make_tuple_mapper<T0, T1, T2, T3, T4, T5>::type
(t0, t1, t2, t3, t4, t5);
}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6>
inline typename boost::detail::tuples::make_tuple_mapper<T0, T1, T2, T3, T4, T5, T6>::type
inline typename detail::make_tuple_mapper<T0, T1, T2, T3, T4, T5, T6>::type
make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3,
const T4& t4, const T5& t5, const T6& t6) {
return typename boost::detail::tuples::make_tuple_mapper
return typename detail::make_tuple_mapper
<T0, T1, T2, T3, T4, T5, T6>::type
(t0, t1, t2, t3, t4, t5, t6);
}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6,
class T7>
inline typename boost::detail::tuples::make_tuple_mapper<T0, T1, T2, T3, T4, T5, T6, T7>::type
inline typename detail::make_tuple_mapper<T0, T1, T2, T3, T4, T5, T6, T7>::type
make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3,
const T4& t4, const T5& t5, const T6& t6, const T7& t7) {
return typename boost::detail::tuples::make_tuple_mapper
return typename detail::make_tuple_mapper
<T0, T1, T2, T3, T4, T5, T6, T7>::type
(t0, t1, t2, t3, t4, t5, t6, t7);
}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6,
class T7, class T8>
inline typename boost::detail::tuples::make_tuple_mapper
inline typename detail::make_tuple_mapper
<T0, T1, T2, T3, T4, T5, T6, T7, T8>::type
make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3,
const T4& t4, const T5& t5, const T6& t6, const T7& t7,
const T8& t8) {
return typename boost::detail::tuples::make_tuple_mapper
return typename detail::make_tuple_mapper
<T0, T1, T2, T3, T4, T5, T6, T7, T8>::type
(t0, t1, t2, t3, t4, t5, t6, t7, t8);
}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6,
class T7, class T8, class T9>
inline typename boost::detail::tuples::make_tuple_mapper
inline typename detail::make_tuple_mapper
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type
make_tuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3,
const T4& t4, const T5& t5, const T6& t6, const T7& t7,
const T8& t8, const T9& t9) {
return typename boost::detail::tuples::make_tuple_mapper
return typename detail::make_tuple_mapper
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type
(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9);
}
@ -753,6 +745,7 @@ tie(T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8,
(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10);
}
} // end of namespace tuples
} // end of namespace boost

View File

@ -41,6 +41,7 @@
#endif
namespace boost {
namespace tuples {
// null_type denotes the end of a list built with "cons"
struct null_type
@ -53,7 +54,7 @@ namespace boost {
inline const null_type cnull_type() { return null_type(); }
namespace detail {
namespace tuples {
// Takes a pointer and routes all assignments to whatever it points to
template<typename T>
struct assign_to_pointee
@ -82,7 +83,6 @@ namespace boost {
}
};
} // end of namespace tuples
} // end of namespace detail
// cons builds a heterogenous list of types
@ -103,9 +103,9 @@ namespace boost {
typename boost::add_reference<const tail_type>::type get_tail() const { return tail; }
#if defined BOOST_MSVC
template<typename T>
template<typename Tail>
explicit cons(const head_type& h /* = head_type() */, // causes MSVC 6.5 to barf.
const T& t) : head(h), tail(t.head, t.tail)
const Tail& t) : head(h), tail(t.head, t.tail)
{
}
@ -116,8 +116,8 @@ namespace boost {
#else
template<typename T>
explicit cons(const head_type& h = head_type(),
const T& t) : head(h), tail(t.head, t.tail)
explicit cons(const head_type& h, const T& t) :
head(h), tail(t.head, t.tail)
{
}
@ -139,7 +139,7 @@ namespace boost {
};
namespace detail {
namespace tuples {
// Determines if the parameter is null_type
template<typename T> struct is_null_type { enum { RET = 0 }; };
template<> struct is_null_type<null_type> { enum { RET = 1 }; };
@ -176,16 +176,16 @@ namespace boost {
>
struct map_tuple_to_cons
{
typedef typename detail::tuples::build_cons<T10, null_type >::RET cons10;
typedef typename detail::tuples::build_cons<T9, cons10>::RET cons9;
typedef typename detail::tuples::build_cons<T8, cons9>::RET cons8;
typedef typename detail::tuples::build_cons<T7, cons8>::RET cons7;
typedef typename detail::tuples::build_cons<T6, cons7>::RET cons6;
typedef typename detail::tuples::build_cons<T5, cons6>::RET cons5;
typedef typename detail::tuples::build_cons<T4, cons5>::RET cons4;
typedef typename detail::tuples::build_cons<T3, cons4>::RET cons3;
typedef typename detail::tuples::build_cons<T2, cons3>::RET cons2;
typedef typename detail::tuples::build_cons<T1, cons2>::RET cons1;
typedef typename detail::build_cons<T10, null_type >::RET cons10;
typedef typename detail::build_cons<T9, cons10>::RET cons9;
typedef typename detail::build_cons<T8, cons9>::RET cons8;
typedef typename detail::build_cons<T7, cons8>::RET cons7;
typedef typename detail::build_cons<T6, cons7>::RET cons6;
typedef typename detail::build_cons<T5, cons6>::RET cons5;
typedef typename detail::build_cons<T4, cons5>::RET cons4;
typedef typename detail::build_cons<T3, cons4>::RET cons3;
typedef typename detail::build_cons<T2, cons3>::RET cons2;
typedef typename detail::build_cons<T1, cons2>::RET cons1;
};
// Workaround the lack of partial specialization in some compilers
@ -213,15 +213,16 @@ namespace boost {
typedef typename Tuple::head_type RET;
};
};
} // detail
} // tuples
} // namespace detail
// Return the Nth type of the given Tuple
template<int N, typename Tuple>
struct tuple_element
struct element
{
private:
typedef detail::tuples::_element_type<N> nth_type;
typedef detail::_element_type<N> nth_type;
public:
typedef typename nth_type::template inner<Tuple>::RET RET;
@ -229,13 +230,13 @@ namespace boost {
};
namespace detail {
namespace tuples {
// Return a reference to the Nth type of the given Tuple
template<int N, typename Tuple>
struct tuple_element_ref
struct element_ref
{
private:
typedef typename tuple_element<N, Tuple>::RET elt_type;
typedef typename element<N, Tuple>::RET elt_type;
public:
typedef typename add_reference<elt_type>::type RET;
@ -244,53 +245,56 @@ namespace boost {
// Return a const reference to the Nth type of the given Tuple
template<int N, typename Tuple>
struct tuple_element_const_ref
struct element_const_ref
{
private:
typedef typename tuple_element<N, Tuple>::RET elt_type;
typedef typename element<N, Tuple>::RET elt_type;
public:
typedef typename add_reference<const elt_type>::type RET;
typedef RET type;
};
}
}
} // namespace detail
// Get length of this tuple
template<typename Tuple>
struct tuple_length
struct length
{
enum { value = 1 + tuple_length<typename Tuple::tail_type>::value };
BOOST_STATIC_CONSTANT(int, value = 1 + length<typename Tuple::tail_type>::value);
};
template<>
struct tuple_length<null_type>
struct length<null_type>
{
enum { value = 0 };
BOOST_STATIC_CONSTANT(int, value = 0);
};
namespace detail {
// Reference the Nth element in a tuple and retrieve it with "get"
template<int N>
struct element
struct get_class
{
template<typename Head, typename Tail>
static inline
typename detail::tuples::tuple_element_ref<N, cons<Head, Tail> >::RET
typename detail::element_ref<N, cons<Head, Tail> >::RET
get(cons<Head, Tail>& t)
{
return element<N-1>::get(t.tail);
return get_class<N-1>::get(t.tail);
}
template<typename Head, typename Tail>
static inline
typename detail::tuples::tuple_element_const_ref<N, cons<Head, Tail> >::RET
typename detail::element_const_ref<N, cons<Head, Tail> >::RET
get(const cons<Head, Tail>& t)
{
return element<N-1>::get(t.tail);
return get_class<N-1>::get(t.tail);
}
};
template<>
struct element<0>
struct get_class<0>
{
template<typename Head, typename Tail>
static inline
@ -309,6 +313,8 @@ namespace boost {
}
};
} // namespace detail
// tuple class
template<
typename T1,
@ -323,10 +329,10 @@ namespace boost {
typename T10 = null_type
>
class tuple :
public detail::tuples::map_tuple_to_cons<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>::cons1
public detail::map_tuple_to_cons<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>::cons1
{
private:
typedef detail::tuples::map_tuple_to_cons<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> mapped_tuple;
typedef detail::map_tuple_to_cons<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> mapped_tuple;
typedef typename mapped_tuple::cons10 cons10;
typedef typename mapped_tuple::cons9 cons9;
typedef typename mapped_tuple::cons8 cons8;
@ -380,22 +386,23 @@ namespace boost {
};
namespace detail {
namespace tuples {
template<int N> struct workaround_holder {};
}}
} // namespace detail
template<int N, typename Head, typename Tail>
typename detail::tuples::tuple_element_ref<N, cons<Head, Tail> >::RET
get(cons<Head, Tail>& t, detail::tuples::workaround_holder<N>* = 0)
typename detail::element_ref<N, cons<Head, Tail> >::RET
get(cons<Head, Tail>& t, detail::workaround_holder<N>* = 0)
{
return element<N>::get(t);
return detail::get_class<N>::get(t);
}
template<int N, typename Head, typename Tail>
typename detail::tuples::tuple_element_const_ref<N, cons<Head, Tail> >::RET
get(const cons<Head, Tail>& t, detail::tuples::workaround_holder<N>* = 0)
typename detail::element_const_ref<N, cons<Head, Tail> >::RET
get(const cons<Head, Tail>& t, detail::workaround_holder<N>* = 0)
{
return element<N>::get(t);
return detail::get_class<N>::get(t);
}
// Make a tuple
@ -491,185 +498,186 @@ namespace boost {
// Tie variables into a tuple
template<typename T1>
inline
tuple<detail::tuples::assign_to_pointee<T1> >
tuple<detail::assign_to_pointee<T1> >
tie(T1& t1)
{
return make_tuple(detail::tuples::assign_to_pointee<T1>(&t1));
return make_tuple(detail::assign_to_pointee<T1>(&t1));
}
// Tie variables into a tuple
template<typename T1, typename T2>
inline
tuple<detail::tuples::assign_to_pointee<T1>,
detail::tuples::assign_to_pointee<T2> >
tuple<detail::assign_to_pointee<T1>,
detail::assign_to_pointee<T2> >
tie(T1& t1, T2& t2)
{
return make_tuple(detail::tuples::assign_to_pointee<T1>(&t1),
detail::tuples::assign_to_pointee<T2>(&t2));
return make_tuple(detail::assign_to_pointee<T1>(&t1),
detail::assign_to_pointee<T2>(&t2));
}
// Tie variables into a tuple
template<typename T1, typename T2, typename T3>
inline
tuple<detail::tuples::assign_to_pointee<T1>,
detail::tuples::assign_to_pointee<T2>,
detail::tuples::assign_to_pointee<T3> >
tuple<detail::assign_to_pointee<T1>,
detail::assign_to_pointee<T2>,
detail::assign_to_pointee<T3> >
tie(T1& t1, T2& t2, T3& t3)
{
return make_tuple(detail::tuples::assign_to_pointee<T1>(&t1),
detail::tuples::assign_to_pointee<T2>(&t2),
detail::tuples::assign_to_pointee<T3>(&t3));
return make_tuple(detail::assign_to_pointee<T1>(&t1),
detail::assign_to_pointee<T2>(&t2),
detail::assign_to_pointee<T3>(&t3));
}
// Tie variables into a tuple
template<typename T1, typename T2, typename T3, typename T4>
inline
tuple<detail::tuples::assign_to_pointee<T1>,
detail::tuples::assign_to_pointee<T2>,
detail::tuples::assign_to_pointee<T3>,
detail::tuples::assign_to_pointee<T4> >
tuple<detail::assign_to_pointee<T1>,
detail::assign_to_pointee<T2>,
detail::assign_to_pointee<T3>,
detail::assign_to_pointee<T4> >
tie(T1& t1, T2& t2, T3& t3, T4& t4)
{
return make_tuple(detail::tuples::assign_to_pointee<T1>(&t1),
detail::tuples::assign_to_pointee<T2>(&t2),
detail::tuples::assign_to_pointee<T3>(&t3),
detail::tuples::assign_to_pointee<T4>(&t4));
return make_tuple(detail::assign_to_pointee<T1>(&t1),
detail::assign_to_pointee<T2>(&t2),
detail::assign_to_pointee<T3>(&t3),
detail::assign_to_pointee<T4>(&t4));
}
// Tie variables into a tuple
template<typename T1, typename T2, typename T3, typename T4, typename T5>
inline
tuple<detail::tuples::assign_to_pointee<T1>,
detail::tuples::assign_to_pointee<T2>,
detail::tuples::assign_to_pointee<T3>,
detail::tuples::assign_to_pointee<T4>,
detail::tuples::assign_to_pointee<T5> >
tuple<detail::assign_to_pointee<T1>,
detail::assign_to_pointee<T2>,
detail::assign_to_pointee<T3>,
detail::assign_to_pointee<T4>,
detail::assign_to_pointee<T5> >
tie(T1& t1, T2& t2, T3& t3, T4& t4, T5 &t5)
{
return make_tuple(detail::tuples::assign_to_pointee<T1>(&t1),
detail::tuples::assign_to_pointee<T2>(&t2),
detail::tuples::assign_to_pointee<T3>(&t3),
detail::tuples::assign_to_pointee<T4>(&t4),
detail::tuples::assign_to_pointee<T5>(&t5));
return make_tuple(detail::assign_to_pointee<T1>(&t1),
detail::assign_to_pointee<T2>(&t2),
detail::assign_to_pointee<T3>(&t3),
detail::assign_to_pointee<T4>(&t4),
detail::assign_to_pointee<T5>(&t5));
}
// Tie variables into a tuple
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
inline
tuple<detail::tuples::assign_to_pointee<T1>,
detail::tuples::assign_to_pointee<T2>,
detail::tuples::assign_to_pointee<T3>,
detail::tuples::assign_to_pointee<T4>,
detail::tuples::assign_to_pointee<T5>,
detail::tuples::assign_to_pointee<T6> >
tuple<detail::assign_to_pointee<T1>,
detail::assign_to_pointee<T2>,
detail::assign_to_pointee<T3>,
detail::assign_to_pointee<T4>,
detail::assign_to_pointee<T5>,
detail::assign_to_pointee<T6> >
tie(T1& t1, T2& t2, T3& t3, T4& t4, T5 &t5, T6 &t6)
{
return make_tuple(detail::tuples::assign_to_pointee<T1>(&t1),
detail::tuples::assign_to_pointee<T2>(&t2),
detail::tuples::assign_to_pointee<T3>(&t3),
detail::tuples::assign_to_pointee<T4>(&t4),
detail::tuples::assign_to_pointee<T6>(&t5),
detail::tuples::assign_to_pointee<T5>(&t6));
return make_tuple(detail::assign_to_pointee<T1>(&t1),
detail::assign_to_pointee<T2>(&t2),
detail::assign_to_pointee<T3>(&t3),
detail::assign_to_pointee<T4>(&t4),
detail::assign_to_pointee<T6>(&t5),
detail::assign_to_pointee<T5>(&t6));
}
// Tie variables into a tuple
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
inline
tuple<detail::tuples::assign_to_pointee<T1>,
detail::tuples::assign_to_pointee<T2>,
detail::tuples::assign_to_pointee<T3>,
detail::tuples::assign_to_pointee<T4>,
detail::tuples::assign_to_pointee<T5>,
detail::tuples::assign_to_pointee<T6>,
detail::tuples::assign_to_pointee<T7> >
tuple<detail::assign_to_pointee<T1>,
detail::assign_to_pointee<T2>,
detail::assign_to_pointee<T3>,
detail::assign_to_pointee<T4>,
detail::assign_to_pointee<T5>,
detail::assign_to_pointee<T6>,
detail::assign_to_pointee<T7> >
tie(T1& t1, T2& t2, T3& t3, T4& t4, T5 &t5, T6 &t6, T7 &t7)
{
return make_tuple(detail::tuples::assign_to_pointee<T1>(&t1),
detail::tuples::assign_to_pointee<T2>(&t2),
detail::tuples::assign_to_pointee<T3>(&t3),
detail::tuples::assign_to_pointee<T4>(&t4),
detail::tuples::assign_to_pointee<T5>(&t5),
detail::tuples::assign_to_pointee<T6>(&t6),
detail::tuples::assign_to_pointee<T7>(&t7));
return make_tuple(detail::assign_to_pointee<T1>(&t1),
detail::assign_to_pointee<T2>(&t2),
detail::assign_to_pointee<T3>(&t3),
detail::assign_to_pointee<T4>(&t4),
detail::assign_to_pointee<T5>(&t5),
detail::assign_to_pointee<T6>(&t6),
detail::assign_to_pointee<T7>(&t7));
}
// Tie variables into a tuple
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
inline
tuple<detail::tuples::assign_to_pointee<T1>,
detail::tuples::assign_to_pointee<T2>,
detail::tuples::assign_to_pointee<T3>,
detail::tuples::assign_to_pointee<T4>,
detail::tuples::assign_to_pointee<T5>,
detail::tuples::assign_to_pointee<T6>,
detail::tuples::assign_to_pointee<T7>,
detail::tuples::assign_to_pointee<T8> >
tuple<detail::assign_to_pointee<T1>,
detail::assign_to_pointee<T2>,
detail::assign_to_pointee<T3>,
detail::assign_to_pointee<T4>,
detail::assign_to_pointee<T5>,
detail::assign_to_pointee<T6>,
detail::assign_to_pointee<T7>,
detail::assign_to_pointee<T8> >
tie(T1& t1, T2& t2, T3& t3, T4& t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8)
{
return make_tuple(detail::tuples::assign_to_pointee<T1>(&t1),
detail::tuples::assign_to_pointee<T2>(&t2),
detail::tuples::assign_to_pointee<T3>(&t3),
detail::tuples::assign_to_pointee<T4>(&t4),
detail::tuples::assign_to_pointee<T5>(&t5),
detail::tuples::assign_to_pointee<T6>(&t6),
detail::tuples::assign_to_pointee<T7>(&t7),
detail::tuples::assign_to_pointee<T8>(&t8));
return make_tuple(detail::assign_to_pointee<T1>(&t1),
detail::assign_to_pointee<T2>(&t2),
detail::assign_to_pointee<T3>(&t3),
detail::assign_to_pointee<T4>(&t4),
detail::assign_to_pointee<T5>(&t5),
detail::assign_to_pointee<T6>(&t6),
detail::assign_to_pointee<T7>(&t7),
detail::assign_to_pointee<T8>(&t8));
}
// Tie variables into a tuple
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
inline
tuple<detail::tuples::assign_to_pointee<T1>,
detail::tuples::assign_to_pointee<T2>,
detail::tuples::assign_to_pointee<T3>,
detail::tuples::assign_to_pointee<T4>,
detail::tuples::assign_to_pointee<T5>,
detail::tuples::assign_to_pointee<T6>,
detail::tuples::assign_to_pointee<T7>,
detail::tuples::assign_to_pointee<T8>,
detail::tuples::assign_to_pointee<T9> >
tuple<detail::assign_to_pointee<T1>,
detail::assign_to_pointee<T2>,
detail::assign_to_pointee<T3>,
detail::assign_to_pointee<T4>,
detail::assign_to_pointee<T5>,
detail::assign_to_pointee<T6>,
detail::assign_to_pointee<T7>,
detail::assign_to_pointee<T8>,
detail::assign_to_pointee<T9> >
tie(T1& t1, T2& t2, T3& t3, T4& t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8, T9 &t9)
{
return make_tuple(detail::tuples::assign_to_pointee<T1>(&t1),
detail::tuples::assign_to_pointee<T2>(&t2),
detail::tuples::assign_to_pointee<T3>(&t3),
detail::tuples::assign_to_pointee<T4>(&t4),
detail::tuples::assign_to_pointee<T5>(&t5),
detail::tuples::assign_to_pointee<T6>(&t6),
detail::tuples::assign_to_pointee<T7>(&t7),
detail::tuples::assign_to_pointee<T8>(&t8),
detail::tuples::assign_to_pointee<T9>(&t9));
return make_tuple(detail::assign_to_pointee<T1>(&t1),
detail::assign_to_pointee<T2>(&t2),
detail::assign_to_pointee<T3>(&t3),
detail::assign_to_pointee<T4>(&t4),
detail::assign_to_pointee<T5>(&t5),
detail::assign_to_pointee<T6>(&t6),
detail::assign_to_pointee<T7>(&t7),
detail::assign_to_pointee<T8>(&t8),
detail::assign_to_pointee<T9>(&t9));
}
// Tie variables into a tuple
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10>
inline
tuple<detail::tuples::assign_to_pointee<T1>,
detail::tuples::assign_to_pointee<T2>,
detail::tuples::assign_to_pointee<T3>,
detail::tuples::assign_to_pointee<T4>,
detail::tuples::assign_to_pointee<T5>,
detail::tuples::assign_to_pointee<T6>,
detail::tuples::assign_to_pointee<T7>,
detail::tuples::assign_to_pointee<T8>,
detail::tuples::assign_to_pointee<T9>,
detail::tuples::assign_to_pointee<T10> >
tuple<detail::assign_to_pointee<T1>,
detail::assign_to_pointee<T2>,
detail::assign_to_pointee<T3>,
detail::assign_to_pointee<T4>,
detail::assign_to_pointee<T5>,
detail::assign_to_pointee<T6>,
detail::assign_to_pointee<T7>,
detail::assign_to_pointee<T8>,
detail::assign_to_pointee<T9>,
detail::assign_to_pointee<T10> >
tie(T1& t1, T2& t2, T3& t3, T4& t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8, T9 &t9, T10 &t10)
{
return make_tuple(detail::tuples::assign_to_pointee<T1>(&t1),
detail::tuples::assign_to_pointee<T2>(&t2),
detail::tuples::assign_to_pointee<T3>(&t3),
detail::tuples::assign_to_pointee<T4>(&t4),
detail::tuples::assign_to_pointee<T5>(&t5),
detail::tuples::assign_to_pointee<T6>(&t6),
detail::tuples::assign_to_pointee<T7>(&t7),
detail::tuples::assign_to_pointee<T8>(&t8),
detail::tuples::assign_to_pointee<T9>(&t9),
detail::tuples::assign_to_pointee<T10>(&t10));
return make_tuple(detail::assign_to_pointee<T1>(&t1),
detail::assign_to_pointee<T2>(&t2),
detail::assign_to_pointee<T3>(&t3),
detail::assign_to_pointee<T4>(&t4),
detail::assign_to_pointee<T5>(&t5),
detail::assign_to_pointee<T6>(&t6),
detail::assign_to_pointee<T7>(&t7),
detail::assign_to_pointee<T8>(&t8),
detail::assign_to_pointee<T9>(&t9),
detail::assign_to_pointee<T10>(&t10));
}
// "ignore" allows tuple positions to be ignored when using "tie".
namespace {
detail::tuples::swallow_assign ignore;
detail::swallow_assign ignore;
}
} // namespace tuples
} // namespace boost
#endif // BOOST_TUPLE_BASIC_NO_PARTIAL_SPEC_HPP