// Copyright (C) 2007 Dean Michael Berris // 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) #if !defined(BOOST_SELECT_2007_11_20) #define BOOST_SELECT_2007_11_20 #ifndef SELECT_TUPLE_MAX_SIZE #define SELECT_TUPLE_MAX_SIZE 10 #endif #include #include #include #include #include namespace boost { namespace impl { template struct choose : mpl::at_c< mpl::vector2, N > { }; // dispatcher template inline typename choose::type choose_element(std::pair const & pair) { return choose_element_dispatch(pair, mpl::int_()); }; template inline T1 choose_element_dispatch(std::pair const & pair, mpl::int_<0>) { return pair.first; }; template inline T2 choose_element_dispatch(std::pair const & pair, mpl::int_<1>) { return pair.second; }; }; template struct select { template typename impl::choose::type operator() (std::pair const & pair) const { return impl::choose_element(pair); }; #define SELECT_size(z, n, unused) \ template \ typename tuples::element >::type \ operator() (tuple const & tuple_) const { return tuples::get(tuple_); }; BOOST_PP_REPEAT_FROM_TO(3, SELECT_TUPLE_MAX_SIZE, SELECT_size, ~); #undef SELECT_size }; }; // namespace boost #endif