Chris@102: /* Copyright 2003-2014 Joaquin M Lopez Munoz. Chris@102: * Distributed under the Boost Software License, Version 1.0. Chris@102: * (See accompanying file LICENSE_1_0.txt or copy at Chris@102: * http://www.boost.org/LICENSE_1_0.txt) Chris@102: * Chris@102: * See http://www.boost.org/libs/multi_index for library home page. Chris@102: */ Chris@102: Chris@102: #ifndef BOOST_MULTI_INDEX_DETAIL_CONS_STDTUPLE_HPP Chris@102: #define BOOST_MULTI_INDEX_DETAIL_CONS_STDTUPLE_HPP Chris@102: Chris@102: #if defined(_MSC_VER) Chris@102: #pragma once Chris@102: #endif Chris@102: Chris@102: #include /* keep it first to prevent nasty warns in MSVC */ Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: Chris@102: namespace boost{ Chris@102: Chris@102: namespace multi_index{ Chris@102: Chris@102: namespace detail{ Chris@102: Chris@102: /* std::tuple wrapper providing the cons-based interface of boost::tuple for Chris@102: * composite_key interoperability. Chris@102: */ Chris@102: Chris@102: template Chris@102: struct cons_stdtuple; Chris@102: Chris@102: struct cons_stdtuple_ctor_terminal Chris@102: { Chris@102: typedef boost::tuples::null_type result_type; Chris@102: Chris@102: template Chris@102: static result_type create(const StdTuple&) Chris@102: { Chris@102: return boost::tuples::null_type(); Chris@102: } Chris@102: }; Chris@102: Chris@102: template Chris@102: struct cons_stdtuple_ctor_normal Chris@102: { Chris@102: typedef cons_stdtuple result_type; Chris@102: Chris@102: static result_type create(const StdTuple& t) Chris@102: { Chris@102: return result_type(t); Chris@102: } Chris@102: }; Chris@102: Chris@102: template Chris@102: struct cons_stdtuple_ctor: Chris@102: boost::mpl::if_c< Chris@102: N::value, Chris@102: cons_stdtuple_ctor_normal, Chris@102: cons_stdtuple_ctor_terminal Chris@102: >::type Chris@102: {}; Chris@102: Chris@102: template Chris@102: struct cons_stdtuple Chris@102: { Chris@102: typedef typename std::tuple_element::type head_type; Chris@102: typedef cons_stdtuple_ctor tail_ctor; Chris@102: typedef typename tail_ctor::result_type tail_type; Chris@102: Chris@102: cons_stdtuple(const StdTuple& t_):t(t_){} Chris@102: Chris@102: const head_type& get_head()const{return std::get(t);} Chris@102: tail_type get_tail()const{return tail_ctor::create(t);} Chris@102: Chris@102: const StdTuple& t; Chris@102: }; Chris@102: Chris@102: template Chris@102: typename cons_stdtuple_ctor::result_type Chris@102: make_cons_stdtuple(const StdTuple& t) Chris@102: { Chris@102: return cons_stdtuple_ctor::create(t); Chris@102: } Chris@102: Chris@102: } /* namespace multi_index::detail */ Chris@102: Chris@102: } /* namespace multi_index */ Chris@102: Chris@102: } /* namespace boost */ Chris@102: Chris@102: #endif