////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2008-2012. 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/interprocess for documentation. // ////////////////////////////////////////////////////////////////////////////// #ifndef BOOST_INTERPROCESS_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP #define BOOST_INTERPROCESS_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP #if (defined _MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif #include #include #include #include //std::size_t namespace boost { namespace interprocess { namespace ipcdetail { template class tuple; template<> class tuple<> {}; template class tuple : private tuple { typedef tuple inherited; public: tuple() { } // implicit copy-constructor is okay // Construct tuple from separate arguments. tuple(typename add_const_reference::type v, typename add_const_reference::type... vtail) : inherited(vtail...), m_head(v) {} // Construct tuple from another tuple. template tuple(const tuple& other) : m_head(other.head()), inherited(other.tail()) {} 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 tie_forward(Values&&... values) { return tuple(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{}; template > struct build_number_seq; template struct build_number_seq > : build_number_seq > {}; template struct build_number_seq<0, index_tuple > { typedef index_tuple type; }; }}} //namespace boost { namespace interprocess { namespace ipcdetail { #include #endif //#ifndef BOOST_INTERPROCESS_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP