|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72362 - sandbox/assign_v2/boost/assign/v2/support/mpl
From: erwann.rogard_at_[hidden]
Date: 2011-06-02 20:46:50
Author: e_r
Date: 2011-06-02 20:46:48 EDT (Thu, 02 Jun 2011)
New Revision: 72362
URL: http://svn.boost.org/trac/boost/changeset/72362
Log:
upd assign_v2
Added:
sandbox/assign_v2/boost/assign/v2/support/mpl/
sandbox/assign_v2/boost/assign/v2/support/mpl/variadic_args_to_indices.hpp (contents, props changed)
sandbox/assign_v2/boost/assign/v2/support/mpl/variadic_sequence.hpp (contents, props changed)
sandbox/assign_v2/boost/assign/v2/support/mpl/variadic_vector.hpp (contents, props changed)
Added: sandbox/assign_v2/boost/assign/v2/support/mpl/variadic_args_to_indices.hpp
==============================================================================
--- (empty file)
+++ sandbox/assign_v2/boost/assign/v2/support/mpl/variadic_args_to_indices.hpp 2011-06-02 20:46:48 EDT (Thu, 02 Jun 2011)
@@ -0,0 +1,111 @@
+#ifndef BOOST_ASSIGN_V2_SUPPORT_MPL_VARIADIC_ARGS_TO_INDICES_HPP_ER_2010
+#define BOOST_ASSIGN_V2_SUPPORT_MPL_VARIADIC_ARGS_TO_INDICES_HPP_ER_2010
+#include <boost/config.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
+
+// Provided temporarily, until /variadic_template/package_range_c.hpp by
+// Larry Evans is fully supported in the release.
+// Source : http://groups.google.com/group/comp.lang.c++/browse_thread/thread/b21c20c4312c383f/3b842a03167f5bd9#3b842a03167f5bd9
+
+namespace boost{
+namespace assign{
+namespace v2{
+
+template<typename I, I...Values> struct indices{};
+template<typename ...Args> struct pack_holder{};
+template<typename I, typename PackHolder> struct pack_holder_size{};
+template<typename I, typename ...Args>
+struct pack_holder_size<
+ I, pack_holder<Args...>
+>
+{
+ BOOST_STATIC_CONSTANT(I, value = sizeof...(Args) );
+};
+
+namespace mpl_aux{
+
+// Args to indices
+
+template<typename Indices, typename Pack> struct args_to_indices{};
+
+template<typename I, I...Tail, typename T, typename... Rest>
+struct args_to_indices<
+ indices<I, Tail...>,
+ pack_holder<T, Rest...>
+>
+{
+ typedef typename args_to_indices<
+ indices<I, Tail..., sizeof...(Tail)>,
+ pack_holder<Rest...>
+ >::type type;
+};
+
+template<typename I, I...Tail>
+struct args_to_indices<
+ indices<I, Tail...>,
+ pack_holder<>
+>{
+ typedef indices<I, Tail...> type;
+};
+
+// Head indices
+
+template<typename Indices, typename I, I K, I N>
+struct collect_indices
+{};
+
+template<typename I, I K, I N, I...Head>
+struct collect_indices<
+ indices<I, Head...>,
+ I, K, N
+>
+{
+ typedef typename collect_indices<
+ indices<I, Head..., K>,
+ I, K + 1, N
+ >::type type;
+};
+
+template<typename I, I N, I...Head>
+struct collect_indices<indices<I, Head...>, I, N, N>
+{
+ typedef indices<I, Head...> type;
+};
+
+}// aux
+
+template<typename I, typename...Args>
+struct args_to_indices
+ : mpl_aux::args_to_indices<
+ indices<I>,
+ pack_holder<Args...>
+ >
+{};
+
+template<typename I, I N>
+struct head_indices
+ : mpl_aux::collect_indices<
+ indices<I>, I, 0, N
+ >
+{};
+
+template<typename I, I K, I N>
+struct tail_indices
+ : mpl_aux::collect_indices<
+ indices<I, K>, I, K + 1, N
+ >
+{};
+
+template<typename I, I N>
+struct tail_indices<I, N, N>
+ : mpl_aux::collect_indices<
+ indices<I>, I, N, N
+ >
+{};
+
+}// v2
+}// assign
+}// boost
+
+#endif // BOOST_ASSIGN_V2_SUPPORT_MPL_VARIADIC_ARGS_TO_INDICES_HPP_ER_2010
Added: sandbox/assign_v2/boost/assign/v2/support/mpl/variadic_sequence.hpp
==============================================================================
--- (empty file)
+++ sandbox/assign_v2/boost/assign/v2/support/mpl/variadic_sequence.hpp 2011-06-02 20:46:48 EDT (Thu, 02 Jun 2011)
@@ -0,0 +1,65 @@
+////////////////////////////////////////////////////////////////////////////
+// variadic_sequence.hpp //
+// //
+// Copyright (C) 2011 Erwann Rogard //
+// Use, modification and distribution are subject to the //
+// Boost Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_V2_SUPPORT_MPL_VARIADIC_SEQUENCE_HPP_ER_2010
+#define BOOST_ASSIGN_V2_SUPPORT_MPL_VARIADIC_SEQUENCE_HPP_ER_2010
+#include <boost/preprocessor/repetition/enum.hpp>
+
+namespace boost{
+namespace mpl{
+namespace detail{
+namespace variadic_sequence_aux{
+
+// Source : http://stackoverflow.com/questions/2709315/is-boost-tuple-compatible-with-c0x-variadic-templates
+
+template <std::size_t, typename, typename...> struct nth_arg;
+
+template <std::size_t N, typename Void, typename T, typename... Args>
+struct nth_arg<N, Void, T, Args...>
+{
+ typedef typename nth_arg<N - 1, Void, Args...>::type type;
+};
+
+template <typename Void, typename T, typename... Args>
+struct nth_arg<0, Void, T, Args...>
+{
+ typedef T type;
+};
+
+template <std::size_t N, typename Void>
+struct nth_arg<N, Void>
+{
+ typedef Void type;
+};
+
+}// variadic_sequence_aux
+}// detail
+}// mpl
+}// boost
+
+#define BOOST_MPL_DETAIL_VARIADIC_SEQUENCE_arg(z, n, data) \
+ typename ::boost::mpl::detail::variadic_sequence_aux::nth_arg< \
+ n, data, Args...\
+ >::type \
+/**/
+
+#define BOOST_MPL_DETAIL_VARIADIC_SEQUENCE(N, FROM, TO, default_type) \
+template <typename ...Args> \
+struct TO \
+{ \
+ typedef FROM< \
+ BOOST_PP_ENUM( \
+ N, \
+ BOOST_MPL_DETAIL_VARIADIC_SEQUENCE_arg, \
+ default_type \
+ ) \
+ > type; \
+}; \
+/**/
+
+#endif // BOOST_ASSIGN_V2_SUPPORT_MPL_VARIADIC_SEQUENCE_HPP_ER_2010
Added: sandbox/assign_v2/boost/assign/v2/support/mpl/variadic_vector.hpp
==============================================================================
--- (empty file)
+++ sandbox/assign_v2/boost/assign/v2/support/mpl/variadic_vector.hpp 2011-06-02 20:46:48 EDT (Thu, 02 Jun 2011)
@@ -0,0 +1,30 @@
+////////////////////////////////////////////////////////////////////////////
+// variadic_sequence.hpp //
+// //
+// Copyright (C) 2011 Erwann Rogard //
+// Use, modification and distribution are subject to the //
+// Boost Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_V2_SUPPORT_MPL_DETAIL_VARIADIC_VECTOR_HPP_ER_2010
+#define BOOST_ASSIGN_V2_SUPPORT_MPL_DETAIL_VARIADIC_VECTOR_HPP_ER_2010
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/aux_/na.hpp>
+#include <boost/assign/v2/support/mpl/variadic_sequence.hpp>
+
+namespace boost{
+namespace mpl{
+namespace detail{
+
+BOOST_MPL_DETAIL_VARIADIC_SEQUENCE(
+ BOOST_MPL_LIMIT_VECTOR_SIZE,
+ ::boost::mpl::vector,
+ variadic_vector,
+ ::boost::mpl::na
+)
+
+}// detail
+}// mpl
+}// boost
+
+#endif // BOOST_ASSIGN_V2_SUPPORT_MPL_DETAIL_VARIADIC_VECTOR_HPP_ER_2010
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