Definitions now in tuples subnamespace

[SVN r11052]
This commit is contained in:
Jaakko Järvi
2001-09-06 13:51:22 +00:00
parent 984cbdc728
commit c10fd424bc
5 changed files with 239 additions and 238 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 -----------------------------------------------
@ -65,7 +64,6 @@ template<class T> struct tuple_length;
namespace detail {
namespace tuples {
// -- generate error template, referencing to non-existing members of this
// template is used to produce compilation errors intentionally
@ -138,7 +136,6 @@ struct element<0> {
}
};
} // end of namespace tuples
} // end of namespace detail
@ -198,7 +195,7 @@ inline typename tuple_access_traits<
typename tuple_element<N, cons<HT, TT> >::type
>::non_const_type
get(cons<HT, TT>& c) {
return detail::tuples::element<N>::template
return detail::element<N>::template
get<
typename tuple_access_traits<
typename tuple_element<N, cons<HT, TT> >::type
@ -213,7 +210,7 @@ inline typename tuple_access_traits<
typename tuple_element<N, cons<HT, TT> >::type
>::const_type
get(const cons<HT, TT>& c) {
return detail::tuples::element<N>::template
return detail::element<N>::template
get<
typename tuple_access_traits<
typename tuple_element<N, cons<HT, TT> >::type
@ -246,7 +243,7 @@ struct cons {
typename tuple_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,
@ -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>
@ -320,7 +317,7 @@ struct cons<HT, null_type> {
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,
const null_type& = null_type())
@ -375,7 +372,6 @@ struct tuple_length<null_type> {
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,11 +399,11 @@ 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;
@ -416,25 +411,25 @@ public:
// tuple_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(),
= detail::default_arg<T0>::f(),
typename tuple_access_traits<T1>::parameter_type t1
= detail::tuples::default_arg<T1>::f(),
= detail::default_arg<T1>::f(),
typename tuple_access_traits<T2>::parameter_type t2
= detail::tuples::default_arg<T2>::f(),
= detail::default_arg<T2>::f(),
typename tuple_access_traits<T3>::parameter_type t3
= detail::tuples::default_arg<T3>::f(),
= detail::default_arg<T3>::f(),
typename tuple_access_traits<T4>::parameter_type t4
= detail::tuples::default_arg<T4>::f(),
= detail::default_arg<T4>::f(),
typename tuple_access_traits<T5>::parameter_type t5
= detail::tuples::default_arg<T5>::f(),
= detail::default_arg<T5>::f(),
typename tuple_access_traits<T6>::parameter_type t6
= detail::tuples::default_arg<T6>::f(),
= detail::default_arg<T6>::f(),
typename tuple_access_traits<T7>::parameter_type t7
= detail::tuples::default_arg<T7>::f(),
= detail::default_arg<T7>::f(),
typename tuple_access_traits<T8>::parameter_type t8
= detail::tuples::default_arg<T8>::f(),
= detail::default_arg<T8>::f(),
typename tuple_access_traits<T9>::parameter_type t9
= detail::tuples::default_arg<T9>::f())
= detail::default_arg<T9>::f())
: inherited(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) {}
@ -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
@ -133,7 +133,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 }; };
@ -170,16 +170,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
@ -207,15 +207,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
{
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;
@ -223,7 +224,7 @@ 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
@ -247,8 +248,9 @@ namespace boost {
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
@ -268,7 +270,7 @@ namespace boost {
{
template<typename Head, typename Tail>
static inline
typename detail::tuples::tuple_element_ref<N, cons<Head, Tail> >::RET
typename detail::tuple_element_ref<N, cons<Head, Tail> >::RET
get(cons<Head, Tail>& t)
{
return element<N-1>::get(t.tail);
@ -276,7 +278,7 @@ namespace boost {
template<typename Head, typename Tail>
static inline
typename detail::tuples::tuple_element_const_ref<N, cons<Head, Tail> >::RET
typename detail::tuple_element_const_ref<N, cons<Head, Tail> >::RET
get(const cons<Head, Tail>& t)
{
return element<N-1>::get(t.tail);
@ -317,10 +319,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;
@ -374,20 +376,21 @@ 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::tuple_element_ref<N, cons<Head, Tail> >::RET
get(cons<Head, Tail>& t, detail::workaround_holder<N>* = 0)
{
return element<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::tuple_element_const_ref<N, cons<Head, Tail> >::RET
get(const cons<Head, Tail>& t, detail::workaround_holder<N>* = 0)
{
return element<N>::get(t);
}
@ -485,185 +488,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

View File

@ -32,5 +32,14 @@
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
namespace boost {
using tuples::tuple;
using tuples::make_tuple;
using tuples::tie;
using tuples::get;
} // end namespace boost
#endif // BOOST_TUPLE_HPP

View File

@ -38,6 +38,7 @@
namespace boost {
namespace tuples {
inline bool operator==(const null_type&, const null_type&) { return true; }
inline bool operator>=(const null_type&, const null_type&) { return true; }
@ -48,7 +49,6 @@ inline bool operator>(const null_type&, const null_type&) { return false; }
namespace detail {
namespace tuples {
// comparison operators check statically the length of its operands and
// delegate the comparing task to the following functions. Hence
// the static check is only made once (should help the compiler).
@ -107,7 +107,6 @@ inline bool gte(const T1& lhs, const T2& rhs) {
template<>
inline bool gte<null_type,null_type>(const null_type&, const null_type&) { return true; }
} // end of namespace tuples
} // end of namespace detail
@ -119,7 +118,7 @@ inline bool operator==(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
// check that tuple_lengths are equal
BOOST_STATIC_ASSERT(tuple_length<T2>::value == tuple_length<S2>::value);
return detail::tuples::eq(lhs, rhs);
return detail::eq(lhs, rhs);
}
// not equal -----
@ -131,7 +130,7 @@ inline bool operator!=(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
// check that tuple_lengths are equal
BOOST_STATIC_ASSERT(tuple_length<T2>::value == tuple_length<S2>::value);
return detail::tuples::neq(lhs, rhs);
return detail::neq(lhs, rhs);
}
// <
@ -141,7 +140,7 @@ inline bool operator<(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
// check that tuple_lengths are equal
BOOST_STATIC_ASSERT(tuple_length<T2>::value == tuple_length<S2>::value);
return detail::tuples::lt(lhs, rhs);
return detail::lt(lhs, rhs);
}
// >
@ -151,7 +150,7 @@ inline bool operator>(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
// check that tuple_lengths are equal
BOOST_STATIC_ASSERT(tuple_length<T2>::value == tuple_length<S2>::value);
return detail::tuples::gt(lhs, rhs);
return detail::gt(lhs, rhs);
}
// <=
@ -161,7 +160,7 @@ inline bool operator<=(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
// check that tuple_lengths are equal
BOOST_STATIC_ASSERT(tuple_length<T2>::value == tuple_length<S2>::value);
return detail::tuples::lte(lhs, rhs);
return detail::lte(lhs, rhs);
}
// >=
@ -171,9 +170,10 @@ inline bool operator>=(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
// check that tuple_lengths are equal
BOOST_STATIC_ASSERT(tuple_length<T2>::value == tuple_length<S2>::value);
return detail::tuples::gte(lhs, rhs);
return detail::gte(lhs, rhs);
}
} // end of namespace tuples
} // end of namespace boost

View File

@ -39,9 +39,9 @@
namespace boost {
namespace tuples {
namespace detail {
namespace tuples {
class format_info {
public:
@ -106,47 +106,46 @@ public:
}
#endif // BOOST_NO_TEMPLATED_STREAMS
};
} // end of namespace detail
template<class CharType>
class tuple_manipulator {
const format_info::manipulator_type mt;
const detail::format_info::manipulator_type mt;
CharType f_c;
public:
explicit tuple_manipulator(format_info::manipulator_type m, const char c = 0)
explicit tuple_manipulator(detail::format_info::manipulator_type m,
const char c = 0)
: mt(m), f_c(c) {}
#if defined (BOOST_NO_TEMPLATED_STREAMS)
void set(std::ios &io) const {
format_info::set_manipulator(io, mt, f_c);
detail::format_info::set_manipulator(io, mt, f_c);
}
#else
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template<class CharType2, class CharTrait>
void set(std::basic_ios<CharType2, CharTrait> &io) const {
format_info::set_manipulator(io, mt, f_c);
detail::format_info::set_manipulator(io, mt, f_c);
}
#else
template<class CharTrait>
void set(std::basic_ios<CharType, CharTrait> &io) const {
format_info::set_manipulator(io, mt, f_c);
detail::format_info::set_manipulator(io, mt, f_c);
}
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif // BOOST_NO_TEMPLATED_STREAMS
};
} // end of namespace tuples
} // end of namespace detail
#if defined (BOOST_NO_TEMPLATED_STREAMS)
inline std::ostream&
operator<<(std::ostream& o, const detail::tuples::tuple_manipulator<char>& m) {
operator<<(std::ostream& o, const tuple_manipulator<char>& m) {
m.set(o);
return o;
}
inline std::istream&
operator>>(std::istream& i, const detail::tuples::tuple_manipulator<char>& m) {
operator>>(std::istream& i, const tuple_manipulator<char>& m) {
m.set(i);
return i;
}
@ -155,14 +154,14 @@ operator>>(std::istream& i, const detail::tuples::tuple_manipulator<char>& m) {
template<class CharType, class CharTrait>
inline std::basic_ostream<CharType, CharTrait>&
operator<<(std::basic_ostream<CharType, CharTrait>& o, const detail::tuples::tuple_manipulator<CharType>& m) {
operator<<(std::basic_ostream<CharType, CharTrait>& o, const tuple_manipulator<CharType>& m) {
m.set(o);
return o;
}
template<class CharType, class CharTrait>
inline std::basic_istream<CharType, CharTrait>&
operator>>(std::basic_istream<CharType, CharTrait>& i, const detail::tuples::tuple_manipulator<CharType>& m) {
operator>>(std::basic_istream<CharType, CharTrait>& i, const tuple_manipulator<CharType>& m) {
m.set(i);
return i;
}
@ -170,18 +169,18 @@ operator>>(std::basic_istream<CharType, CharTrait>& i, const detail::tuples::tup
#endif // BOOST_NO_TEMPLATED_STREAMS
template<class CharType>
inline detail::tuples::tuple_manipulator<CharType> set_open(const CharType c) {
return detail::tuples::tuple_manipulator<CharType>(detail::tuples::format_info::open, c);
inline tuple_manipulator<CharType> set_open(const CharType c) {
return tuple_manipulator<CharType>(detail::format_info::open, c);
}
template<class CharType>
inline detail::tuples::tuple_manipulator<CharType> set_close(const CharType c) {
return detail::tuples::tuple_manipulator<CharType>(detail::tuples::format_info::close, c);
inline tuple_manipulator<CharType> set_close(const CharType c) {
return tuple_manipulator<CharType>(detail::format_info::close, c);
}
template<class CharType>
inline detail::tuples::tuple_manipulator<CharType> set_delimiter(const CharType c) {
return detail::tuples::tuple_manipulator<CharType>(detail::tuples::format_info::delimiter, c);
inline tuple_manipulator<CharType> set_delimiter(const CharType c) {
return tuple_manipulator<CharType>(detail::format_info::delimiter, c);
}
@ -194,7 +193,6 @@ inline detail::tuples::tuple_manipulator<CharType> set_delimiter(const CharType
// set_open, set_close and set_delimiter
namespace detail {
namespace tuples {
// Note: The order of the print functions is critical
// to let a conforming compiler find and select the correct one.
@ -266,7 +264,6 @@ print(std::basic_ostream<CharType, CharTrait>& o, const cons<T1, T2>& t) {
#endif // BOOST_NO_TEMPLATED_STREAMS
} // namespace tuples
} // namespace detail
#if defined (BOOST_NO_TEMPLATED_STREAMS)
@ -275,13 +272,13 @@ inline std::ostream& operator<<(std::ostream& o, const cons<T1, T2>& t) {
if (!o.good() ) return o;
const char l =
detail::tuples::format_info::get_manipulator(o, detail::tuples::format_info::open);
detail::format_info::get_manipulator(o, detail::format_info::open);
const char r =
detail::tuples::format_info::get_manipulator(o, detail::tuples::format_info::close);
detail::format_info::get_manipulator(o, detail::format_info::close);
o << l;
detail::tuples::print(o, t);
detail::print(o, t);
o << r;
@ -297,13 +294,13 @@ operator<<(std::basic_ostream<CharType, CharTrait>& o,
if (!o.good() ) return o;
const CharType l =
detail::tuples::format_info::get_manipulator(o, detail::tuples::format_info::open);
detail::format_info::get_manipulator(o, detail::format_info::open);
const CharType r =
detail::tuples::format_info::get_manipulator(o, detail::tuples::format_info::close);
detail::format_info::get_manipulator(o, detail::format_info::close);
o << l;
detail::tuples::print(o, t);
detail::print(o, t);
o << r;
@ -316,7 +313,6 @@ operator<<(std::basic_ostream<CharType, CharTrait>& o,
// input stream operators
namespace detail {
namespace tuples {
#if defined (BOOST_NO_TEMPLATED_STREAMS)
@ -373,7 +369,6 @@ read(std::istream &is, cons<T1, T2>& t1) {
return read(is, t1.tail);
}
} // end namespace tuples
} // end namespace detail
inline std::istream&
@ -381,8 +376,8 @@ operator>>(std::istream &is, null_type&) {
if (!is.good() ) return is;
detail::tuples::extract_and_check_delimiter(is, detail::tuples::format_info::open);
detail::tuples::extract_and_check_delimiter(is, detail::tuples::format_info::close);
detail::extract_and_check_delimiter(is, detail::format_info::open);
detail::extract_and_check_delimiter(is, detail::format_info::close);
return is;
}
@ -394,11 +389,11 @@ operator>>(std::istream& is, cons<T1, T2>& t1) {
if (!is.good() ) return is;
detail::tuples::extract_and_check_delimiter(is, detail::tuples::format_info::open);
detail::extract_and_check_delimiter(is, detail::format_info::open);
detail::tuples::read(is, t1);
detail::read(is, t1);
detail::tuples::extract_and_check_delimiter(is, detail::tuples::format_info::close);
detail::extract_and_check_delimiter(is, detail::format_info::close);
return is;
}
@ -461,7 +456,6 @@ read(std::basic_istream<CharType, CharTrait> &is, cons<T1, T2>& t1) {
return read(is, t1.tail);
}
} // end namespace tuples
} // end namespace detail
@ -471,8 +465,8 @@ operator>>(std::basic_istream<CharType, CharTrait> &is, null_type&) {
if (!is.good() ) return is;
detail::tuples::extract_and_check_delimiter(is, detail::tuples::format_info::open);
detail::tuples::extract_and_check_delimiter(is, detail::tuples::format_info::close);
detail::extract_and_check_delimiter(is, detail::format_info::open);
detail::extract_and_check_delimiter(is, detail::format_info::close);
return is;
}
@ -483,17 +477,18 @@ operator>>(std::basic_istream<CharType, CharTrait>& is, cons<T1, T2>& t1) {
if (!is.good() ) return is;
detail::tuples::extract_and_check_delimiter(is, detail::tuples::format_info::open);
detail::extract_and_check_delimiter(is, detail::format_info::open);
detail::tuples::read(is, t1);
detail::read(is, t1);
detail::tuples::extract_and_check_delimiter(is, detail::tuples::format_info::close);
detail::extract_and_check_delimiter(is, detail::format_info::close);
return is;
}
#endif // BOOST_NO_TEMPLATED_STREAMS
} // end of namespace tuples
} // end of namespace boost
#endif // BOOST_TUPLE_IO_HPP