/* Copyright 2003-2014 Joaquin M Lopez Munoz. * 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/multi_index for library home page. */ #ifndef BOOST_MULTI_INDEX_DETAIL_CONS_STDTUPLE_HPP #define BOOST_MULTI_INDEX_DETAIL_CONS_STDTUPLE_HPP #if defined(_MSC_VER) #pragma once #endif #include /* keep it first to prevent nasty warns in MSVC */ #include #include #include namespace boost{ namespace multi_index{ namespace detail{ /* std::tuple wrapper providing the cons-based interface of boost::tuple for * composite_key interoperability. */ template struct cons_stdtuple; struct cons_stdtuple_ctor_terminal { typedef boost::tuples::null_type result_type; template static result_type create(const StdTuple&) { return boost::tuples::null_type(); } }; template struct cons_stdtuple_ctor_normal { typedef cons_stdtuple result_type; static result_type create(const StdTuple& t) { return result_type(t); } }; template struct cons_stdtuple_ctor: boost::mpl::if_c< N::value, cons_stdtuple_ctor_normal, cons_stdtuple_ctor_terminal >::type {}; template struct cons_stdtuple { typedef typename std::tuple_element::type head_type; typedef cons_stdtuple_ctor tail_ctor; typedef typename tail_ctor::result_type tail_type; cons_stdtuple(const StdTuple& t_):t(t_){} const head_type& get_head()const{return std::get(t);} tail_type get_tail()const{return tail_ctor::create(t);} const StdTuple& t; }; template typename cons_stdtuple_ctor::result_type make_cons_stdtuple(const StdTuple& t) { return cons_stdtuple_ctor::create(t); } } /* namespace multi_index::detail */ } /* namespace multi_index */ } /* namespace boost */ #endif