/* Copyright 2003-2019 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
#include
#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;
};
#define BOOST_MULTI_INDEX_KEY_TYPED_KEY_IMPL(qualifier,extractor) \
template< \
typename Class,typename Type,Type (Class::*PtrToMemberFunction)()qualifier \
> \
struct typed_key_impl \
{ \
using value_type=Class; \
using type=extractor; \
};
BOOST_MULTI_INDEX_KEY_TYPED_KEY_IMPL( ,mem_fun)
BOOST_MULTI_INDEX_KEY_TYPED_KEY_IMPL(const ,const_mem_fun)
BOOST_MULTI_INDEX_KEY_TYPED_KEY_IMPL(volatile ,volatile_mem_fun)
BOOST_MULTI_INDEX_KEY_TYPED_KEY_IMPL(const volatile ,cv_mem_fun)
BOOST_MULTI_INDEX_KEY_TYPED_KEY_IMPL(& ,ref_mem_fun)
BOOST_MULTI_INDEX_KEY_TYPED_KEY_IMPL(const& ,cref_mem_fun)
BOOST_MULTI_INDEX_KEY_TYPED_KEY_IMPL(volatile& ,vref_mem_fun)
BOOST_MULTI_INDEX_KEY_TYPED_KEY_IMPL(const volatile& ,cvref_mem_fun)
#undef BOOST_MULTI_INDEX_KEY_TYPED_KEY_IMPL
template
struct typed_key_impl
{
using value_type=Value;
using type=global_fun;
};
template
struct remove_noexcept{using type=T;};
#define BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT(qualifier) \
template \
struct remove_noexcept \
{using type=R(C::*)(Args...)qualifier;}; \
\
template \
struct remove_noexcept \
{using type=R(C::*)(Args...,...)qualifier;};
BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT(BOOST_PP_EMPTY())
/* VS warns without dummy arg */
BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT(const)
BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT(volatile)
BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT(const volatile)
BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT(&)
BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT(const&)
BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT(volatile&)
BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT(const volatile&)
BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT(&&)
BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT(const&&)
BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT(volatile&&)
BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT(const volatile&&)
#undef BOOST_MULTI_INDEX_KEY_REMOVE_MEMFUN_NOEXCEPT
template
struct remove_noexcept{using type=R(*)(Args...);};
template
struct remove_noexcept
{using type=R(*)(Args...,...);};
template
using remove_noexcept_t=typename remove_noexcept::type;
template
struct key_impl;
template
struct key_impl:typed_key_impl,Key>{};
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