Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81605 - sandbox/variadic_templates/sandbox/slim/test
From: cppljevans_at_[hidden]
Date: 2012-11-27 22:00:56


Author: cppljevans
Date: 2012-11-27 22:00:55 EST (Tue, 27 Nov 2012)
New Revision: 81605
URL: http://svn.boost.org/trac/boost/changeset/81605

Log:
add missing .hpp file
Added:
   sandbox/variadic_templates/sandbox/slim/test/tree_builder.hpp (contents, props changed)

Added: sandbox/variadic_templates/sandbox/slim/test/tree_builder.hpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/sandbox/slim/test/tree_builder.hpp 2012-11-27 22:00:55 EST (Tue, 27 Nov 2012)
@@ -0,0 +1,56 @@
+#ifndef TREE_BUILDER_HPP_INCLUDED
+#define TREE_BUILDER_HPP_INCLUDED
+//OriginalSource:
+// 2012-10-25.1521 CST
+// Copied code from unrolled_tuple.cpp from:
+// https://github.com/ericniebler/home/tree/master/src/tuple
+//
+///////////////////////////////////////////////////////////////////////////////
+//
+// Copyright 2012 Eric Niebler.
+// Distributed under 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)
+//
+#include "./make_tuple.hpp"
+#include <boost/preprocessor/repetition/enum.hpp>
+
+#ifndef TUPLE_SIZE
+#define TUPLE_SIZE 2
+#endif
+
+#ifndef TREE_DEPTH
+#define TREE_DEPTH 5
+#endif
+
+template<int I>
+struct tree_builder
+{
+ #define M0(Z, N, D) ::make_tuple( static_cast<T &&>(t), std::integral_constant<int, N>())
+ #define M1(Z, N, D) auto BOOST_PP_CAT(tmp, N) = ::get<N>(res);
+
+ template<typename T>
+ static auto make_tree(T &&t)
+ -> decltype(tree_builder<I+1>::make_tree(::make_tuple(BOOST_PP_ENUM(TUPLE_SIZE, M0, ~))))
+ {
+ auto res = tree_builder<I+1>::make_tree(::make_tuple(BOOST_PP_ENUM(TUPLE_SIZE, M0, ~)));
+ // Get each element of the tuple.
+ BOOST_PP_REPEAT(TUPLE_SIZE, M1, ~)
+ return res;
+ }
+
+ #undef M1
+ #undef M0
+};
+
+template<>
+struct tree_builder<TREE_DEPTH+1>
+{
+ template<typename T>
+ static T make_tree(T &&t)
+ {
+ return static_cast<T &&>(t);
+ }
+};
+
+#endif


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