diff --git a/include/boost/tuple/detail/tuple_basic.hpp b/include/boost/tuple/detail/tuple_basic.hpp index e171da3..e75a294 100644 --- a/include/boost/tuple/detail/tuple_basic.hpp +++ b/include/boost/tuple/detail/tuple_basic.hpp @@ -59,7 +59,7 @@ template < class tuple; // tuple_length forward declaration -template struct tuple_length; +template struct length; @@ -106,24 +106,24 @@ struct default_arg { }; // - cons getters -------------------------------------------------------- -// called: element::get(aTuple) +// called: get_class::get(aTuple) template< int N > -struct element { +struct get_class { template inline static RET get(const cons& t) { - return element::template get(t.tail); + return get_class::template get(t.tail); } template inline static RET get(cons& t) { - return element::template get(t.tail); + return get_class::template get(t.tail); } }; template<> -struct element<0> { +struct get_class<0> { template inline static RET get(const cons& t) { @@ -140,20 +140,20 @@ struct element<0> { // -cons type accessors ---------------------------------------- -// typename tuple_element::type gets the type of the +// typename tuples::element::type gets the type of the // Nth element ot T, first element is at index 0 // ------------------------------------------------------- template -struct tuple_element +struct element { private: typedef typename T::tail_type Next; public: - typedef typename tuple_element::type type; + typedef typename element::type type; }; template -struct tuple_element<0,T> +struct element<0,T> { typedef typename T::head_type type; }; @@ -167,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 struct tuple_access_traits { +template struct access_traits { typedef const T& const_type; typedef T& non_const_type; @@ -179,7 +179,7 @@ template struct tuple_access_traits { // be non-volatile and const. 8.5.3. (5) }; -template struct tuple_access_traits { +template struct access_traits { typedef T& const_type; typedef T& non_const_type; @@ -191,14 +191,14 @@ template struct tuple_access_traits { // get function for non-const cons-lists, returns a reference to the element template -inline typename tuple_access_traits< - typename tuple_element >::type +inline typename access_traits< + typename element >::type >::non_const_type get(cons& c) { - return detail::element::template + return detail::get_class::template get< - typename tuple_access_traits< - typename tuple_element >::type + typename access_traits< + typename element >::type >::non_const_type>(c); } @@ -206,14 +206,14 @@ get(cons& c) { // the element. If the element is a reference, returns the reference // as such (that is, can return a non-const reference) template -inline typename tuple_access_traits< - typename tuple_element >::type +inline typename access_traits< + typename element >::type >::const_type get(const cons& c) { - return detail::element::template + return detail::get_class::template get< - typename tuple_access_traits< - typename tuple_element >::type + typename access_traits< + typename element >::type >::const_type>(c); } @@ -231,16 +231,16 @@ struct cons { head_type head; tail_type tail; - typename tuple_access_traits::non_const_type + typename access_traits::non_const_type get_head() { return head; } - typename tuple_access_traits::non_const_type + typename access_traits::non_const_type get_tail() { return tail; } - typename tuple_access_traits::const_type + typename access_traits::const_type get_head() const { return head; } - typename tuple_access_traits::const_type + typename access_traits::const_type get_tail() const { return tail; } cons() : head(detail::default_arg::f()), tail() {} @@ -249,7 +249,7 @@ struct cons { // 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::parameter_type h, + cons(typename access_traits::parameter_type h, const tail_type& t) : head (h), tail(t) {} @@ -277,22 +277,22 @@ struct cons { template cons& operator=( const std::pair& u ) { - BOOST_STATIC_ASSERT(tuple_length::value == 2); // check length = 2 + BOOST_STATIC_ASSERT(length::value == 2); // check length = 2 head = u.first; tail.head = u.second; return *this; } // get member functions (non-const and const) template - typename tuple_access_traits< - typename tuple_element >::type + typename access_traits< + typename element >::type >::non_const_type get() { return boost::get(*this); // delegate to non-member get } template - typename tuple_access_traits< - typename tuple_element >::type + typename access_traits< + typename element >::type >::const_type get() const { return boost::get(*this); // delegate to non-member get @@ -307,19 +307,19 @@ struct cons { head_type head; - typename tuple_access_traits::non_const_type + typename access_traits::non_const_type get_head() { return head; } null_type get_tail() { return null_type(); } - typename tuple_access_traits::const_type + typename access_traits::const_type get_head() const { return head; } const null_type get_tail() const { return null_type(); } cons() : head(detail::default_arg::f()) {} - cons(typename tuple_access_traits::parameter_type h, + cons(typename access_traits::parameter_type h, const null_type& = null_type()) : head (h) {} @@ -341,16 +341,16 @@ struct cons { cons& operator=(const cons& u) { head = u.head; return *this; } template - typename tuple_access_traits< - typename tuple_element::type + typename access_traits< + typename element::type >::non_const_type get() { return boost::get(*this); } template - typename tuple_access_traits< - typename tuple_element::type + typename access_traits< + typename element::type >::const_type get() const { return boost::get(*this); @@ -361,12 +361,12 @@ struct cons { // templates for finding out the length of the tuple ------------------- template -struct tuple_length { - BOOST_STATIC_CONSTANT(int, value = 1 + tuple_length::value); +struct length { + BOOST_STATIC_CONSTANT(int, value = 1 + length::value); }; template<> -struct tuple_length { +struct length { BOOST_STATIC_CONSTANT(int, value = 0); }; @@ -408,27 +408,27 @@ public: typedef typename inherited::tail_type tail_type; -// tuple_access_traits::parameter_type takes non-reference types as const T& +// access_traits::parameter_type takes non-reference types as const T& explicit tuple( - typename tuple_access_traits::parameter_type t0 + typename access_traits::parameter_type t0 = detail::default_arg::f(), - typename tuple_access_traits::parameter_type t1 + typename access_traits::parameter_type t1 = detail::default_arg::f(), - typename tuple_access_traits::parameter_type t2 + typename access_traits::parameter_type t2 = detail::default_arg::f(), - typename tuple_access_traits::parameter_type t3 + typename access_traits::parameter_type t3 = detail::default_arg::f(), - typename tuple_access_traits::parameter_type t4 + typename access_traits::parameter_type t4 = detail::default_arg::f(), - typename tuple_access_traits::parameter_type t5 + typename access_traits::parameter_type t5 = detail::default_arg::f(), - typename tuple_access_traits::parameter_type t6 + typename access_traits::parameter_type t6 = detail::default_arg::f(), - typename tuple_access_traits::parameter_type t7 + typename access_traits::parameter_type t7 = detail::default_arg::f(), - typename tuple_access_traits::parameter_type t8 + typename access_traits::parameter_type t8 = detail::default_arg::f(), - typename tuple_access_traits::parameter_type t9 + typename access_traits::parameter_type t9 = detail::default_arg::f()) : inherited(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) {} @@ -444,7 +444,7 @@ public: template tuple& operator=(const std::pair& k) { - BOOST_STATIC_ASSERT(tuple_length::value == 2);// check_length = 2 + BOOST_STATIC_ASSERT(length::value == 2);// check_length = 2 this->head = k.first; this->tail.head = k.second; return *this; diff --git a/include/boost/tuple/detail/tuple_basic_no_partial_spec.hpp b/include/boost/tuple/detail/tuple_basic_no_partial_spec.hpp index 04e30e8..f98ed61 100644 --- a/include/boost/tuple/detail/tuple_basic_no_partial_spec.hpp +++ b/include/boost/tuple/detail/tuple_basic_no_partial_spec.hpp @@ -219,7 +219,7 @@ namespace tuples { // Return the Nth type of the given Tuple template - struct tuple_element + struct element { private: typedef detail::_element_type nth_type; @@ -233,10 +233,10 @@ namespace tuples { // Return a reference to the Nth type of the given Tuple template - struct tuple_element_ref + struct element_ref { private: - typedef typename tuple_element::RET elt_type; + typedef typename element::RET elt_type; public: typedef typename add_reference::type RET; @@ -245,10 +245,10 @@ namespace tuples { // Return a const reference to the Nth type of the given Tuple template - struct tuple_element_const_ref + struct element_const_ref { private: - typedef typename tuple_element::RET elt_type; + typedef typename element::RET elt_type; public: typedef typename add_reference::type RET; @@ -259,40 +259,42 @@ namespace tuples { // Get length of this tuple template - struct tuple_length + struct length { - enum { value = 1 + tuple_length::value }; + BOOST_STATIC_CONSTANT(int, value = 1 + length::value); }; template<> - struct tuple_length + struct length { - enum { value = 0 }; + BOOST_STATIC_CONSTANT(int, value = 0); }; + namespace detail { + // Reference the Nth element in a tuple and retrieve it with "get" template - struct element + struct get_class { template static inline - typename detail::tuple_element_ref >::RET + typename detail::element_ref >::RET get(cons& t) { - return element::get(t.tail); + return get_class::get(t.tail); } template static inline - typename detail::tuple_element_const_ref >::RET + typename detail::element_const_ref >::RET get(const cons& t) { - return element::get(t.tail); + return get_class::get(t.tail); } }; template<> - struct element<0> + struct get_class<0> { template static inline @@ -311,6 +313,8 @@ namespace tuples { } }; + } // namespace detail + // tuple class template< typename T1, @@ -388,17 +392,17 @@ namespace tuples { } // namespace detail template - typename detail::tuple_element_ref >::RET + typename detail::element_ref >::RET get(cons& t, detail::workaround_holder* = 0) { - return element::get(t); + return detail::get_class::get(t); } template - typename detail::tuple_element_const_ref >::RET + typename detail::element_const_ref >::RET get(const cons& t, detail::workaround_holder* = 0) { - return element::get(t); + return detail::get_class::get(t); } // Make a tuple diff --git a/include/boost/tuple/tuple_comparison.hpp b/include/boost/tuple/tuple_comparison.hpp index 5af1399..cf3d2c9 100644 --- a/include/boost/tuple/tuple_comparison.hpp +++ b/include/boost/tuple/tuple_comparison.hpp @@ -115,8 +115,8 @@ inline bool gte(const null_type&, const null_type&) { retur template inline bool operator==(const cons& lhs, const cons& rhs) { - // check that tuple_lengths are equal - BOOST_STATIC_ASSERT(tuple_length::value == tuple_length::value); + // check that tuple lengths are equal + BOOST_STATIC_ASSERT(length::value == length::value); return detail::eq(lhs, rhs); } @@ -127,8 +127,8 @@ template inline bool operator!=(const cons& lhs, const cons& rhs) { - // check that tuple_lengths are equal - BOOST_STATIC_ASSERT(tuple_length::value == tuple_length::value); + // check that tuple lengths are equal + BOOST_STATIC_ASSERT(length::value == length::value); return detail::neq(lhs, rhs); } @@ -137,8 +137,8 @@ inline bool operator!=(const cons& lhs, const cons& rhs) template inline bool operator<(const cons& lhs, const cons& rhs) { - // check that tuple_lengths are equal - BOOST_STATIC_ASSERT(tuple_length::value == tuple_length::value); + // check that tuple lengths are equal + BOOST_STATIC_ASSERT(length::value == length::value); return detail::lt(lhs, rhs); } @@ -147,8 +147,8 @@ inline bool operator<(const cons& lhs, const cons& rhs) template inline bool operator>(const cons& lhs, const cons& rhs) { - // check that tuple_lengths are equal - BOOST_STATIC_ASSERT(tuple_length::value == tuple_length::value); + // check that tuple lengths are equal + BOOST_STATIC_ASSERT(length::value == length::value); return detail::gt(lhs, rhs); } @@ -157,8 +157,8 @@ inline bool operator>(const cons& lhs, const cons& rhs) template inline bool operator<=(const cons& lhs, const cons& rhs) { - // check that tuple_lengths are equal - BOOST_STATIC_ASSERT(tuple_length::value == tuple_length::value); + // check that tuple lengths are equal + BOOST_STATIC_ASSERT(length::value == length::value); return detail::lte(lhs, rhs); } @@ -167,8 +167,8 @@ inline bool operator<=(const cons& lhs, const cons& rhs) template inline bool operator>=(const cons& lhs, const cons& rhs) { - // check that tuple_lengths are equal - BOOST_STATIC_ASSERT(tuple_length::value == tuple_length::value); + // check that tuple lengths are equal + BOOST_STATIC_ASSERT(length::value == length::value); return detail::gte(lhs, rhs); } diff --git a/include/boost/tuple/tuple_io.hpp b/include/boost/tuple/tuple_io.hpp index 8b1828c..64514f0 100644 --- a/include/boost/tuple/tuple_io.hpp +++ b/include/boost/tuple/tuple_io.hpp @@ -217,7 +217,7 @@ print(std::ostream& o, const cons& t) { o << t.head; #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - if (tuple_length::value == 0) + if (tuples::length::value == 0) return o; #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION o << d; @@ -254,7 +254,7 @@ print(std::basic_ostream& o, const cons& t) { o << t.head; #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - if (tuple_length::value == 0) + if (tuples::length::value == 0) return o; #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION o << d; @@ -360,7 +360,7 @@ read(std::istream &is, cons& t1) { is >> t1.head; #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - if (tuple_length::value == 0) + if (tuples::length::value == 0) return is; #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION @@ -447,7 +447,7 @@ read(std::basic_istream &is, cons& t1) { is >> t1.head; #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - if (tuple_length::value == 0) + if (tuples::length::value == 0) return is; #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION