/* Copyright 2003-2018 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_KEY_HPP #define BOOST_MULTI_INDEX_KEY_HPP #if defined(_MSC_VER) #pragma once #endif #include /* keep it first to prevent nasty warns in MSVC */ #include #include #include #include #if __cplusplus>=201703L||\ defined(BOOST_MSVC)&&defined(__cpp_nontype_template_parameter_auto) #define BOOST_MULTI_INDEX_KEY_SUPPORTED #include namespace boost{ namespace multi_index{ /* C++17 terse key specification syntax */ namespace detail{ template struct typed_key_impl; template struct typed_key_impl< Type Class::*,PtrToMember, typename std::enable_if::value>::type > { using value_type=Class; using type=member; }; template< typename Class,typename Type,Type (Class::*PtrToMemberFunction)()const > struct typed_key_impl { using value_type=Class; using type=const_mem_fun; }; template struct typed_key_impl { using value_type=Class; using type=mem_fun; }; template struct typed_key_impl { using value_type=Value; using type=global_fun; }; template struct key_impl; template struct key_impl:typed_key_impl{}; template struct least_generic; template struct least_generic { using type=T0; }; template struct least_generic { static_assert( std::is_convertible::value|| std::is_convertible::value, "one type should be convertible to the other"); using type=typename least_generic< typename std::conditional< std::is_convertible::value,T0,T1 >::type, Ts... >::type; }; template struct key_impl { using value_type=typename least_generic< typename std::decay::value_type>::type, typename std::decay::value_type>::type... >::type; using type=composite_key< value_type, typename key_impl::type, typename key_impl::type... >; }; template> struct composite_key_size; template struct composite_key_size> { static constexpr auto value=sizeof...(Args)-1; }; template struct limited_size_key_impl { static_assert( sizeof...(Keys)<=composite_key_size<>::value, "specified number of keys must meet the limits of " "boost::multi_index::composite_key"); using type=typename key_impl::type; }; } /* namespace multi_index::detail */ template using key=typename detail::limited_size_key_impl::type; } /* namespace multi_index */ } /* namespace boost */ #endif #endif