Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81639 - sandbox/variadic_templates/sandbox/slim/test
From: cppljevans_at_[hidden]
Date: 2012-11-30 19:44:53


Author: cppljevans
Date: 2012-11-30 19:44:52 EST (Fri, 30 Nov 2012)
New Revision: 81639
URL: http://svn.boost.org/trac/boost/changeset/81639

Log:
add missing tuple_impl.*.hpp files
Text files modified:
   sandbox/variadic_templates/sandbox/slim/test/tuple_impl.bcon12_horizontal.hpp | 128 +++++--------------------------
   sandbox/variadic_templates/sandbox/slim/test/tuple_impl.bcon12_vertical.hpp | 93 +++++------------------
   sandbox/variadic_templates/sandbox/slim/test/tuple_impl.horizontal.hpp | 159 +++++++++++++++++++++++++++++++++++----
   sandbox/variadic_templates/sandbox/slim/test/tuple_impl.vertical.hpp | 146 +++++++++++++++++++++++++++---------
   4 files changed, 295 insertions(+), 231 deletions(-)

Modified: sandbox/variadic_templates/sandbox/slim/test/tuple_impl.bcon12_horizontal.hpp
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tuple_impl.bcon12_horizontal.hpp (original)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple_impl.bcon12_horizontal.hpp 2012-11-30 19:44:52 EST (Fri, 30 Nov 2012)
@@ -1,11 +1,10 @@
-#ifndef TUPLE_IMPL_BCON12_VERTICAL_INCLUDE_HPP
-#define TUPLE_IMPL_BCON12_VERTICAL_INCLUDE_HPP
+#ifndef TUPLE_IMPL_BCON12_HORIZONTAL_INCLUDE_HPP
+#define TUPLE_IMPL_BCON12_HORIZONTAL_INCLUDE_HPP
 //Acknowlegements:
 // The following code was adapted from part of the code in
 // https://github.com/ericniebler/home/blob/master/src/tuple/tuple.cpp
 //
 ///////////////////////////////////////////////////////////////////////////////
-// tuple.cpp
 //
 // Copyright 2012 Eric Niebler.
 // Distributed under the Boost Software License, Version 1.0. (See
@@ -13,88 +12,12 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 //
 
-#include <cstdio>
-#include <utility>
-#include <functional>
-#include <type_traits>
-#include <boost/preprocessor/cat.hpp>
-#include <boost/preprocessor/repetition/enum.hpp>
-#include <boost/preprocessor/repetition/enum_params.hpp>
-#include <boost/preprocessor/repetition/repeat.hpp>
+#include "./make_indexes.hpp"
 
-#ifndef BRANCHING_FACTOR
-#define BRANCHING_FACTOR 7
-#endif
-
-#ifndef DEPTH
-#define DEPTH 7
-#endif
-
-// C++11 eliminates the need for macros! Oh, wait ...
-#define RETURN(...) -> decltype(__VA_ARGS__) { return __VA_ARGS__; }
-
-// New-style enable_if from Matt Calabrese
-#define ENABLE_IF(...) typename std::enable_if<(__VA_ARGS__)>::type *& = detail::enabler
-
-// For adding defaulted default, copy and move constructors, and move/copy assign.
-#define DEFAULTS(CLASS) \
- CLASS() = default; /*required for the type to be trivial!*/ \
- CLASS(CLASS const &) = default; /* memberwise copy */ \
- CLASS(CLASS &&) = default; /* member-wise move */ \
- /* These would otherwise be deleted because we */ \
- /* declared a move constructor! */ \
- CLASS &operator=(CLASS const &) = default; /* memberwise copy assign */ \
- CLASS &operator=(CLASS &&) = default; /* memberwise move assign */ \
- /**/
+#include "./RETURN_ENABLE_IF_DEFAULTS.hpp"
 
 namespace detail
 {
- extern void* enabler;
-
- ///////////////////////////////////////////////////////////////////////////
- // unrefwrap
- template<typename T>
- struct unrefwrap
- {
- typedef T type;
- };
-
- template<typename T>
- struct unrefwrap<std::reference_wrapper<T> >
- {
- typedef T &type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // as_tuple_element
- template<typename T>
- using as_tuple_element = typename unrefwrap<typename std::decay<T>::type>::type;
-
- ///////////////////////////////////////////////////////////////////////////
- // ints
- template<int ...I>
- struct ints
- {};
-
- ///////////////////////////////////////////////////////////////////////////
- // indices
- template<int N, typename Ints>
- struct indices_;
-
- template<int N, int... I>
- struct indices_<N, ints<I...>>
- : indices_<N-1, ints<N-1, I...>>
- {};
-
- template<int... I>
- struct indices_<0, ints<I...>>
- {
- typedef ints<I...> type;
- };
-
- template<int I>
- using indices = typename indices_<I, ints<>>::type;
-
     ///////////////////////////////////////////////////////////////////////////
     // tuple_elem
     template<int I, typename T>
@@ -118,18 +41,20 @@
     struct tuple_impl;
 
     template<int... Ints, typename H, typename ...T>
- struct tuple_impl<ints<0, Ints...>, H, T...>
+ struct tuple_impl<detail::int_indexes<0, Ints...>, H, T...>
         // can't seem to expand two packs in lock step with unrolling. Huh.
       : tuple_elem<0, H>, tuple_elem<Ints, T>...
     {
         DEFAULTS(tuple_impl)
 
+ #if TUPLE_TEMPLATED_CTOR == 1
         template<typename U, typename ...V
           , ENABLE_IF(sizeof...(V) != 0 || !std::is_same<U, tuple_impl &>::value)>
         explicit constexpr tuple_impl(U &&u, V &&...v) // HACK around gcc bug #53036
           : tuple_elem<0, H>(static_cast<U &&>(u))
           , tuple_elem<Ints, T>(static_cast<V &&>(v))...
         {}
+ #endif
     };
 
     ///////////////////////////////////////////////////////////////////////////
@@ -152,23 +77,12 @@
         return static_cast<T &&>(t.value);
     }
 
- ///////////////////////////////////////////////////////////////////////////
- // get_elem
- template<int I, typename T>
- tuple_elem<I, T> get_elem(tuple_elem<I, T> const &);
 }
 
 using detail::get;
 
 ///////////////////////////////////////////////////////////////////////////////
-// tuple_element
-template<int I, typename Tuple>
-struct tuple_element
- : decltype(detail::get_elem<I>(std::declval<Tuple>()))
-{};
-
-///////////////////////////////////////////////////////////////////////////////
-// tuple
+// tuple_bench
 template<typename ...T>
 struct tuple_bench;
 
@@ -178,11 +92,22 @@
 
 template<typename H, typename ...T>
 struct tuple_bench<H, T...>
- : detail::tuple_impl<detail::indices<sizeof...(T) + 1>, H, T...>
+ : detail::tuple_impl
+ < typename detail::make_indexes<sizeof...(T)+1>::type
+ , H
+ , T...
+ >
 {
- typedef detail::tuple_impl<detail::indices<sizeof...(T) + 1>, H, T...> impl_type;
-
     DEFAULTS(tuple_bench)
+
+ #if TUPLE_TEMPLATED_CTOR == 1
+ typedef
+ detail::tuple_impl
+ < typename detail::make_indexes<sizeof...(T)+1>::type
+ , H
+ , T...
+ >
+ impl_type;
 
     // not explicit to allow things like: return {42, "allo"};
     template<typename U, typename ...V
@@ -191,14 +116,7 @@
     constexpr tuple_bench(U &&u, V &&...v)
       : impl_type(static_cast<U &&>(u), static_cast<V &&>(v)...)
     {}
+ #endif
 };
 
-///////////////////////////////////////////////////////////////////////////////
-// make_tuple
-template<typename ...T>
-tuple_bench<detail::as_tuple_element<T>...> make_tuple(T &&...t)
-{
- return {t...};
-}
-
 #endif

Modified: sandbox/variadic_templates/sandbox/slim/test/tuple_impl.bcon12_vertical.hpp
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tuple_impl.bcon12_vertical.hpp (original)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple_impl.bcon12_vertical.hpp 2012-11-30 19:44:52 EST (Fri, 30 Nov 2012)
@@ -13,9 +13,6 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 //
 
-#include <utility>
-#include <functional>
-#include <type_traits>
 #include <boost/preprocessor/cat.hpp>
 #include <boost/preprocessor/repetition/enum_params.hpp>
 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
@@ -26,29 +23,13 @@
 #include <boost/preprocessor/comparison/equal.hpp>
 #include <boost/preprocessor/control/expr_if.hpp>
 #include <boost/preprocessor/punctuation/comma_if.hpp>
+#include "./RETURN_ENABLE_IF_DEFAULTS.hpp"
 
 // Must be greater than or equal to 1. (1 means don't do loop unrolling.)
-#ifndef UNROLL_MAX
-#define UNROLL_MAX 10
+#ifndef TUPLE_UNROLL_MAX
+#define TUPLE_UNROLL_MAX 10
 #endif
 
-// C++11 eliminates the need for macros! Oh, wait ...
-#define RETURN(...) -> decltype(__VA_ARGS__) { return __VA_ARGS__; }
-
-// New-style enable_if from Matt Calabrese
-#define ENABLE_IF(...) typename std::enable_if<(__VA_ARGS__)>::type *& = detail::enabler
-
-// For adding defaulted default, copy and move constructors, and move/copy assign.
-#define DEFAULTS(CLASS) \
- CLASS() = default; /*required for the type to be trivial!*/ \
- CLASS(CLASS const &) = default; /* memberwise copy */ \
- CLASS(CLASS &&) = default; /* member-wise move */ \
- /* These would otherwise be deleted because we */ \
- /* declared a move constructor! */ \
- CLASS &operator=(CLASS const &) = default; /* memberwise copy assign */ \
- CLASS &operator=(CLASS &&) = default; /* memberwise move assign */ \
- /**/
-
 #define DISABLE_COPY_IF(CLASS, N, T) \
     BOOST_PP_COMMA_IF(BOOST_PP_EQUAL(N, 1)) \
     BOOST_PP_EXPR_IF( \
@@ -57,34 +38,6 @@
     ) \
     /**/
 
-namespace detail
-{
- extern void* enabler;
-
- ///////////////////////////////////////////////////////////////////////////
- template<int I>
- using int_ = std::integral_constant<int, I>;
-
- ///////////////////////////////////////////////////////////////////////////
- // unrefwrap
- template<typename T>
- struct unrefwrap
- {
- typedef T type;
- };
-
- template<typename T>
- struct unrefwrap<std::reference_wrapper<T> >
- {
- typedef T &type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // as_tuple_element
- template<typename T>
- using as_tuple_element = typename unrefwrap<typename std::decay<T>::type>::type;
-}
-
 template<typename ...T>
 struct tuple_bench;
 
@@ -98,14 +51,14 @@
 
 #define BOOST_PP_LOCAL_MACRO(N) \
 template<BOOST_PP_ENUM_PARAMS(N, typename T)> \
-struct tuple_bench<BOOST_PP_ENUM_PARAMS(N, T)> \
+struct tuple_bench<BOOST_PP_ENUM_PARAMS(N, T)> \
 { \
- DEFAULTS(tuple_bench) \
+ DEFAULTS(tuple_bench) \
                                                                     \
     template<BOOST_PP_ENUM_PARAMS(N, typename U) \
- DISABLE_COPY_IF(tuple_bench, N, U0) \
+ DISABLE_COPY_IF(tuple_bench, N, U0) \
> \
- constexpr tuple_bench(BOOST_PP_ENUM_BINARY_PARAMS(N, U, &&u)) \
+ constexpr tuple_bench(BOOST_PP_ENUM_BINARY_PARAMS(N, U, &&u)) \
       : BOOST_PP_ENUM(N, INIT, ~) \
     {} \
                                                                     \
@@ -113,26 +66,26 @@
 }; \
 /**/
 
-#define BOOST_PP_LOCAL_LIMITS (1, UNROLL_MAX)
+#define BOOST_PP_LOCAL_LIMITS (1, TUPLE_UNROLL_MAX)
 #include BOOST_PP_LOCAL_ITERATE()
 
 // A tuple type that can be statically initialized
-template<BOOST_PP_ENUM_PARAMS(UNROLL_MAX, typename T), typename ...Tail>
-struct tuple_bench<BOOST_PP_ENUM_PARAMS(UNROLL_MAX, T), Tail...>
+template<BOOST_PP_ENUM_PARAMS(TUPLE_UNROLL_MAX, typename T), typename ...Tail>
+struct tuple_bench<BOOST_PP_ENUM_PARAMS(TUPLE_UNROLL_MAX, T), Tail...>
 {
     DEFAULTS(tuple_bench)
 
     // Not explicit to allow things like: return {42, "allo"};.
- template<BOOST_PP_ENUM_PARAMS(UNROLL_MAX, typename U), typename ...Rest
+ template<BOOST_PP_ENUM_PARAMS(TUPLE_UNROLL_MAX, typename U), typename ...Rest
       , ENABLE_IF(sizeof...(Rest)==sizeof...(Tail))
- DISABLE_COPY_IF(tuple_bench, UNROLL_MAX, U0)
+ DISABLE_COPY_IF(tuple_bench, TUPLE_UNROLL_MAX, U0)
>
- constexpr tuple_bench(BOOST_PP_ENUM_BINARY_PARAMS(UNROLL_MAX, U, &&u), Rest &&...rest)
- : BOOST_PP_ENUM(UNROLL_MAX, INIT, ~)
+ constexpr tuple_bench(BOOST_PP_ENUM_BINARY_PARAMS(TUPLE_UNROLL_MAX, U, &&u), Rest &&...rest)
+ : BOOST_PP_ENUM(TUPLE_UNROLL_MAX, INIT, ~)
       , tail(static_cast<Rest &&>(rest)...) // std::forward is NOT constexpr!
     {}
 
- BOOST_PP_REPEAT(UNROLL_MAX, MEMBERS, ~)
+ BOOST_PP_REPEAT(TUPLE_UNROLL_MAX, MEMBERS, ~)
     tuple_bench<Tail...> tail;
 };
 
@@ -142,6 +95,10 @@
 
 namespace detail
 {
+ ///////////////////////////////////////////////////////////////////////////
+ template<int I>
+ struct int_{};
+
     // Work-around strange gcc bug
     template<int J>
     struct impl
@@ -154,13 +111,13 @@
         ) \
         /**/
 
- #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_DEC(UNROLL_MAX))
+ #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_DEC(TUPLE_UNROLL_MAX))
         #include BOOST_PP_LOCAL_ITERATE()
 
         template<typename Tuple, int I>
         static inline constexpr auto get_elem(Tuple &&that, int_<I>)
         RETURN(
- impl<I-I>::get_elem(static_cast<Tuple &&>(that).tail, int_<I-UNROLL_MAX>())
+ impl<I-I>::get_elem(static_cast<Tuple &&>(that).tail, int_<I-TUPLE_UNROLL_MAX>())
         )
     };
 }
@@ -185,12 +142,4 @@
     detail::impl<I-I>::get_elem(static_cast<tuple_bench<T...> &&>(tup), detail::int_<I>())
 )
 
-///////////////////////////////////////////////////////////////////////////////
-// make_tuple
-template<typename ...T>
-inline tuple_bench<detail::as_tuple_element<T>...> make_tuple(T &&...t)
-{
- return {t...};
-}
-
 #endif

Modified: sandbox/variadic_templates/sandbox/slim/test/tuple_impl.horizontal.hpp
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tuple_impl.horizontal.hpp (original)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple_impl.horizontal.hpp 2012-11-30 19:44:52 EST (Fri, 30 Nov 2012)
@@ -1,32 +1,155 @@
 #ifndef TUPLE_IMPL_HORIZONTAL_INCLUDE_HPP
 #define TUPLE_IMPL_HORIZONTAL_INCLUDE_HPP
-#include "make_indexes.hpp"
- template<typename Key, typename Value>
- struct element
- ;
- template<int Key, typename Value>
- struct element<int_key<Key>,Value>
+//Acknowlegements:
+// Most of the templated CTOR's code was copied parts of the code in
+// https://github.com/ericniebler/home/blob/master/src/tuple/tuple.cpp
+//
+#include <type_traits>
+
+#if TUPLE_TEMPLATED_CTOR == 1
+#include "./RETURN_ENABLE_IF_DEFAULTS.hpp"
+#endif
+
+#include "./make_indexes.hpp"
+
+namespace detail
+{
+
+ template<int Index, typename Value>
+ struct key_value
   {
+ #if TUPLE_TEMPLATED_CTOR == 1
+ DEFAULTS(key_value)
+
+ template
+ < typename U
+ , ENABLE_IF(!std::is_same<U, key_value &>::value)
+ >
+ explicit constexpr
+ key_value(U &&u)
+ : value(static_cast<U &&>(u))
+ {}
+ #endif
       Value value;
   };
- template<typename Keys, typename... Args>
+
+ template
+ < typename Indexes
+ , typename... Elements
+ >
   struct tuple_impl
   ;
- template<int... Indices, typename... Args>
- struct tuple_impl<int_indexes<Indices...>, Args...>
- : element<int_key<Indices>, Args>...
- {};
-
- template<typename... Args>
- struct tuple_bench
- : tuple_impl<typename make_indexes<sizeof...(Args)>::type, Args...>
+
+ template
+ < int... Indices
+ , typename Element0
+ , typename... Elements
+ >
+ struct tuple_impl
+ < int_indexes<0,Indices...>
+ , Element0
+ , Elements...
+ >
+ : key_value<0, Element0>
+ , key_value<Indices, Elements>...
   {
+
+ #if TUPLE_TEMPLATED_CTOR == 1
+ DEFAULTS(tuple_impl)
+
+ template
+ < typename U0
+ , typename ...Us
+ , ENABLE_IF(sizeof...(Us) != 0 || !std::is_same<U0, tuple_impl &>::value)
+ >
+ explicit constexpr
+ tuple_impl(U0 &&u0, Us &&...us) // HACK around gcc bug #53036
+ : key_value< 0 , Element0>(static_cast<U0 &&>(u0))
+ , key_value< Indices, Elements>(static_cast<Us &&>(us))...
+ {}
+ #endif
+
   };
 
- template<int Key, typename Value>
+ template<int Index, typename Value>
+ constexpr
     Value&
- get(element<int_key<Key>,Value>& key_val)
+ get(key_value<Index,Value>& ndx_val)
+ {
+ return ndx_val.value;
+ }
+ template<int Index, typename Value>
+ constexpr
+ Value const&
+ get(key_value<Index,Value>const& ndx_val)
+ {
+ return ndx_val.value;
+ }
+ template<int Index, typename Value>
+ constexpr
+ Value&&
+ get(key_value<Index,Value>&& ndx_val)
   {
- return key_val.value;
+ return static_cast<Value&&>(ndx_val.value);
   }
+
+}//detail namespace
+
+using detail::get;
+
+ template
+ < typename... Elements
+ >
+ struct tuple_bench
+ ;
+ template
+ <
+ >
+ struct tuple_bench
+ <
+ >
+ {
+ };
+ template
+ < typename Element0
+ , typename... Elements
+ >
+ struct tuple_bench
+ < Element0
+ , Elements...
+ >
+ : detail::tuple_impl
+ < detail::indices<1+sizeof...(Elements)>
+ , Element0
+ , Elements...
+ >
+ {
+ #if TUPLE_TEMPLATED_CTOR == 1
+ DEFAULTS(tuple_bench)
+
+ typedef
+ detail::tuple_impl
+ < detail::indices<1+sizeof...(Elements)>
+ , Element0
+ , Elements...
+ >
+ impl_type
+ ;
+ // not explicit to allow things like: return {42, "allo"};
+ template
+ < typename U0
+ , typename ...Us
+ , ENABLE_IF(sizeof...(Us) == sizeof...(Elements))
+ , ENABLE_IF(sizeof...(Us) != 0 || !std::is_same<U0, tuple_bench &>::value)
+ >
+ constexpr
+ tuple_bench(U0 &&u0, Us &&...us)
+ : impl_type
+ ( static_cast<U0 &&>(u0)
+ , static_cast<Us &&>(us)...
+ )
+ {}
+ #endif
+ };
+
 #endif//TUPLE_IMPL_HORIZONTAL_INCLUDE_HPP

Modified: sandbox/variadic_templates/sandbox/slim/test/tuple_impl.vertical.hpp
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tuple_impl.vertical.hpp (original)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple_impl.vertical.hpp 2012-11-30 19:44:52 EST (Fri, 30 Nov 2012)
@@ -1,67 +1,140 @@
 #ifndef TUPLE_IMPL_VERTICAL_INCLUDE_HPP
 #define TUPLE_IMPL_VERTICAL_INCLUDE_HPP
- template<int Index,typename... Args>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/repeat_from_to.hpp>
+#if TUPLE_TEMPLATED_CTOR == 1
+#include <boost/preprocessor/comparison/equal.hpp>
+#include <boost/preprocessor/control/expr_if.hpp>
+#include <boost/preprocessor/punctuation/comma_if.hpp>
+#endif
+
+namespace detail
+{
+ template<int Key>
+ struct int_key
+ /**@brief
+ * Provide a means for overloading the
+ * tuple_impl::get_elem methods
+ * to retrieve Key'th element in tuple.
+ */
+ {};
+
+ template<int Index,typename... Elements>
   struct tuple_impl;
   template<int Index>
   struct tuple_impl<Index>
+ /**@brief
+ * Dummy tuple_impl to allow:
+ * using tuple_tail::get_elem
+ * in subclasses.
+ */
   {
- void at_value(){}
+ void get_elem(){}
   };
   
-#if !defined(TUPLE_CHUNK)
- #define TUPLE_CHUNK 10
-#endif
-#include <boost/preprocessor/repetition/enum_params.hpp>
-#include <boost/preprocessor/repetition/repeat_from_to.hpp>
-#define TUPLE_IMPL_TYPE_NAME H
-#define TUPLE_IMPL_MEMB_NAME h
-#define TUPLE_IMPL_MEMBER(z_IGNORE,MEMB_NUMB,data_IGNORE)\
- BOOST_PP_CAT(TUPLE_IMPL_TYPE_NAME,MEMB_NUMB)\
- BOOST_PP_CAT(TUPLE_IMPL_MEMB_NAME,MEMB_NUMB)\
+#if !defined(UNROLL_MAX)
+ #define UNROLL_MAX 10
+#endif
+
+#define TUPLE_IMPL_ELEM_TYPE elem_type
+#define TUPLE_IMPL_ELEM_MEMB elem_memb
+#if TUPLE_TEMPLATED_CTOR == 1
+
+#define DISABLE_COPY_IF(CLASS, N, T) \
+ BOOST_PP_COMMA_IF(BOOST_PP_EQUAL(N, 1)) \
+ BOOST_PP_EXPR_IF( \
+ BOOST_PP_EQUAL(N, 1) \
+ , ENABLE_IF(!std::is_same<T, CLASS &>::value) \
+ ) \
+ /**/
+#define TUPLE_CTORS_ENUM(CLASS,ARITY)\
+ DEFAULTS(CLASS)\
+\
+ template<BOOST_PP_ENUM_PARAMS(ARITY, typename U) \
+ DISABLE_COPY_IF(tuple_bench, ARITY, U0) \
+ > \
+ constexpr CLASS(BOOST_PP_ENUM_BINARY_PARAMS(ARITY, U, &&u)) \
+ : BOOST_PP_ENUM(ARITY, INIT, ~) \
+ {} \
+\
+ /**/
+#define TUPLE_CTORS_TAIL(CLASS,ARITY,ELEMS_TAIL,ARGS_TAIL)\
+ DEFAULTS(CLASS)\
+\
+ template<BOOST_PP_ENUM_PARAMS(ARITY, typename U), typename ...ELEMS_TAIL \
+ , ENABLE_IF(sizeof...(ELEMS_TAIL)==sizeof...(ARGS_TAIL)) \
+ DISABLE_COPY_IF(CLASS, ARITY, U0) \
+ > \
+ constexpr CLASS(BOOST_PP_ENUM_BINARY_PARAMS(ARITY, U, &&u), ARGS_TAIL &&...args_tail) \
+ : BOOST_PP_ENUM(ARITY, INIT, ~) \
+ , tuple_tail(static_cast<ARGS_TAIL &&>(args_tail)...) \
+ {} \
+ /**/
+#else
+#define TUPLE_CTORS_ENUM(CLASS,ARITY)\
+ /**/
+#define TUPLE_CTORS_TAIL(CLASS,ARITY)\
+ /**/
+#endif
+
+#define TUPLE_IMPL_MEMBER(z_IGNORE,MEMB_NUMB,START_INDEX)\
+ BOOST_PP_CAT(TUPLE_IMPL_ELEM_TYPE,MEMB_NUMB)\
+ BOOST_PP_CAT(TUPLE_IMPL_ELEM_MEMB,MEMB_NUMB)\
         ;\
- BOOST_PP_CAT(TUPLE_IMPL_TYPE_NAME,MEMB_NUMB)&\
- at_value\
- ( int_key<Index+MEMB_NUMB>\
+ BOOST_PP_CAT(TUPLE_IMPL_ELEM_TYPE,MEMB_NUMB)&\
+ get_elem\
+ ( int_key<START_INDEX+MEMB_NUMB>\
         )\
         {\
- return BOOST_PP_CAT(TUPLE_IMPL_MEMB_NAME,MEMB_NUMB);\
+ return BOOST_PP_CAT(TUPLE_IMPL_ELEM_MEMB,MEMB_NUMB);\
         }\
         /**/
 
-#define TUPLE_IMPL_STRUCT_TAIL(z_IGNORE, ARITY, data_IGNORE) \
- template<int Index, BOOST_PP_ENUM_PARAMS(ARITY, typename TUPLE_IMPL_TYPE_NAME)> \
- struct tuple_impl<Index, BOOST_PP_ENUM_PARAMS(ARITY, TUPLE_IMPL_TYPE_NAME)> \
+#define TUPLE_IMPL_STRUCT_ENUM(z_IGNORE, ARITY, data_IGNORE) \
+ template<int Index, BOOST_PP_ENUM_PARAMS(ARITY, typename TUPLE_IMPL_ELEM_TYPE)> \
+ struct tuple_impl<Index, BOOST_PP_ENUM_PARAMS(ARITY, TUPLE_IMPL_ELEM_TYPE)> \
   { \
- BOOST_PP_REPEAT(ARITY,TUPLE_IMPL_MEMBER,~) \
+ BOOST_PP_REPEAT(ARITY,TUPLE_IMPL_MEMBER,Index) \
+ TUPLE_CTORS_ENUM(tuple_impl,ARITY) \
   }; \
   /**/
   
- BOOST_PP_REPEAT_FROM_TO(1,TUPLE_CHUNK,TUPLE_IMPL_STRUCT_TAIL,~)
+ BOOST_PP_REPEAT_FROM_TO(1,UNROLL_MAX,TUPLE_IMPL_STRUCT_ENUM,~)
   
- template<int Index, BOOST_PP_ENUM_PARAMS(TUPLE_CHUNK, typename TUPLE_IMPL_TYPE_NAME), typename... Others>
- struct tuple_impl<Index, BOOST_PP_ENUM_PARAMS(TUPLE_CHUNK, TUPLE_IMPL_TYPE_NAME), Others...>
- : tuple_impl<Index+TUPLE_CHUNK, Others...>
+ template
+ < int Index
+ , BOOST_PP_ENUM_PARAMS(UNROLL_MAX
+ , typename... ElemTail
+ >
+ struct tuple_impl
+ < Index
+ , BOOST_PP_ENUM_PARAMS(UNROLL_MAX, TUPLE_IMPL_ELEM_TYPE)
+ , ElemTail...
+ >
+ : tuple_impl<Index+UNROLL_MAX, ElemTail...>
   {
- typedef tuple_impl<Index+TUPLE_CHUNK,Others...> base;
- using base::at_value;
+ typedef tuple_impl< ElemTail...> tuple_tail;
+ using tuple_tail::get_elem;
       
- BOOST_PP_REPEAT(TUPLE_CHUNK,TUPLE_IMPL_MEMBER,~)
+ BOOST_PP_REPEAT(UNROLL_MAX,TUPLE_IMPL_MEMBER,Index)
+ TUPLE_CTORS_TAIL(tuple_impl,UNROLL_MAX,ElemTail)
   };
   
-#undef TUPLE_IMPL_TYPE_NAME
-#undef TUPLE_IMPL_MEMB_NAME
+#undef TUPLE_IMPL_ELEM_TYPE
+#undef TUPLE_IMPL_ELEM_MEMB
 #undef TUPLE_IMPL_MEMBER
-#undef TUPLE_IMPL_STRUCT_TAIL
+#undef TUPLE_IMPL_STRUCT_ENUM
+}
 
 #ifdef VERT_AMORT
   #include "make_indexes.hpp"
 #endif
   
- template<typename... Args>
+ template<typename... Elements>
   struct tuple_bench
- : tuple_impl<0,Args...>
+ : detail::tuple_impl<0,Elements...>
 #ifdef VERT_AMORT
- , make_indexes<sizeof...(Args)>::type
+ , detail::make_indexes<sizeof...(Elements)>::type
     //This is actually useless for the purpose of VERTICAL tuple.
     //The real purpose is to cause this VERTICAL tuple to incur
     //the same make_indexes overhead as the HORIZONTAL tuple.
@@ -70,12 +143,13 @@
     //many instances of the same make_indexes used in all
     //HORIZONTAL tuples with same size.
 #endif
- {};
+ {
+ };
   
   template< int Index, typename Tuple>
     auto
- get(Tuple& tuple) -> decltype(tuple.at_value(int_key<Index>()))
+ get(Tuple& tuple) -> decltype(tuple.get_elem(detail::int_key<Index>()))
   {
- return tuple.at_value(int_key<Index>());
+ return tuple.get_elem(detail::int_key<Index>());
   }
 #endif//TUPLE_IMPL_VERTICAL_INCLUDE_HPP


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk