////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2008-2013. 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) // // See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// #ifndef BOOST_CONTAINER_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP #define BOOST_CONTAINER_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP #ifndef BOOST_CONFIG_HPP # include #endif #if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include #include #include #include #include //std::size_t namespace lslboost { namespace container { namespace dtl { template class tuple; template<> class tuple<> {}; template class tuple : private tuple { typedef tuple inherited; public: tuple() : inherited(), m_head() {} template tuple(U &&u, Args && ...args) : inherited(::lslboost::forward(args)...), m_head(::lslboost::forward(u)) {} // Construct tuple from another tuple. template tuple(const tuple& other) : inherited(other.tail()), m_head(other.head()) {} template tuple& operator=(const tuple& other) { m_head = other.head(); tail() = other.tail(); return this; } typename add_reference::type head() { return m_head; } typename add_reference::type head() const { return m_head; } inherited& tail() { return *this; } const inherited& tail() const { return *this; } protected: Head m_head; }; template tuple forward_as_tuple_impl(Values&&... values) { return tuple(::lslboost::forward(values)...); } template struct tuple_element; template struct tuple_element > { typedef typename tuple_element >::type type; }; template struct tuple_element<0, tuple > { typedef Head type; }; template class get_impl; template class get_impl > { typedef typename tuple_element >::type Element; typedef get_impl > Next; public: typedef typename add_reference::type type; typedef typename add_const_reference::type const_type; static type get(tuple& t) { return Next::get(t.tail()); } static const_type get(const tuple& t) { return Next::get(t.tail()); } }; template class get_impl<0, tuple > { public: typedef typename add_reference::type type; typedef typename add_const_reference::type const_type; static type get(tuple& t) { return t.head(); } static const_type get(const tuple& t){ return t.head(); } }; template typename get_impl >::type get(tuple& t) { return get_impl >::get(t); } template typename get_impl >::const_type get(const tuple& t) { return get_impl >::get(t); } //////////////////////////////////////////////////// // Builds an index_tuple<0, 1, 2, ..., Num-1>, that will // be used to "unpack" into comma-separated values // in a function call. //////////////////////////////////////////////////// template struct index_tuple{ typedef index_tuple type; }; template struct concat_index_tuple; template struct concat_index_tuple, index_tuple> : index_tuple{}; template struct build_number_seq; template struct build_number_seq : concat_index_tuple::type ,typename build_number_seq::type >::type {}; template<> struct build_number_seq<0> : index_tuple<>{}; template<> struct build_number_seq<1> : index_tuple<0>{}; }}} //namespace lslboost { namespace container { namespace dtl { #include #endif //#ifndef BOOST_CONTAINER_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP