"boost/multi_index/key_extractors.hpp"
概要
"boost/multi_index/identity.hpp"
概要
"boost/multi_index/member.hpp"
概要
"boost/multi_index/mem_fun.hpp"
概要
"boost/multi_index/global_fun.hpp"
概要
"boost/multi_index/composite_key.hpp"
概要
"boost/multi_index/key.hpp"
概要
键值提取类被 基于键值的索引 使用,以从 multi_index_container
的元素中获取索引键值。 如果满足以下条件,则称 CopyConstructible
和 CopyAssignable
类 KeyFromValue
是从类型 Type
的键值提取器:
KeyFromValue::result_type
,k1(ca)
已定义并返回可转换为 const KeyFromValue::result_type&
的值,k2
是 k1
的副本,则 k1(ca)
与 k2(ca)
是相同的值,const KeyFromValue
的每个 k1
、k2
和类型为 const Type&
的 ca
。
此外,如果满足以下附加条件,则 KeyFromValue
是读/写键值提取器
remove_reference_t<KeyFromValue::result_type>
不是 const
限定的。k1(a)
已定义并返回可转换为 KeyFromValue::result_type&
的值,k1(a)
绑定到与 k1(const_cast<const Type&>(a))
相同的对象,const KeyFromValue
的每个 k1
和类型为 Type&
的 a
。
Boost.MultiIndex 提供了十二个通用键值提取器
identity
,member
,const_mem_fun
(和三个 变体),mem_fun
(和三个 变体),global_fun
和composite_key
,key
允许对之前的提取器进行非常简洁的规范 (除了 identity
)。
Boost.MultiIndex 提供的键值提取器根据类型 Type
进行模板化,不仅用于从类型 Type
的对象中提取键值,还用于从 Boost.Ref 提供的引用包装器以及指向 Type
的链式指针(或 Type
的引用包装器)中提取键值:链式指针是任何类型 P
,使得对于类型为 const P
的对象 p
*p
产生类型为 Type&
或 boost::reference_wrapper<Type>
的对象,或者*p
产生指向 Type
的链式指针,Type&
或 boost::reference_wrapper<Type>
值的类指针对象的任意组合。
"boost/multi_index/key_extractors.hpp"
概要#include <boost/multi_index/identity.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/mem_fun.hpp> #include <boost/multi_index/global_fun.hpp> #include <boost/multi_index/composite_key.hpp>
此头文件包含 Boost.MultiIndex 提供的所有键值提取器。
"boost/multi_index/identity.hpp"
概要namespace boost{ namespace multi_index{ template<typename T> struct identity; } // namespace boost::multi_index } // namespace boost
identity
identity
是一个 键值提取器
,它充当无操作的恒等函子。
template<typename Type> struct identity { typedef Type result_type; // only provided if const ChainedPtr& is not convertible to const Type& template<typename ChainedPtr> Type& operator()(const ChainedPtr& x)const; const Type& operator()(const Type& x)const; Type& operator()(Type& x)const; // only provided if Type is non-const // only provided if Type is non-const const Type& operator()(const reference_wrapper<const Type>& x)const; // only provided if Type is const Type& operator()( const reference_wrapper<typename remove_const<Type>::type>& x)const; Type& operator()(const reference_wrapper<Type>& x)const; };
identity<Type>
是以下模型的模型
Type
的读/写 键值提取器
,reference_wrapper<const Type>
的 键值提取器
,reference_wrapper<Type>
的读/写 键值提取器
,const Type
的 链式指针 的 键值提取器
,Type
的 链式指针 的读/写 键值提取器
。identity
成员template<typename ChainedPtr> Type& operator()(const ChainedPtr& x)const;
要求:ChainedPtr
是指向Type
的 链式指针 类型。
返回: 对x
链式指向的对象的引用。
const Type& operator()(const Type& x)const;
返回: x
。
Type& operator()(Type& x)const;
返回: x
。
const Type& operator()(const reference_wrapper<const Type>& x)const;
返回: x.get()
。
Type& operator()(const reference_wrapper<typename remove_const<Type>::type>& x)const;
返回: x.get()
。
Type& operator()(const reference_wrapper<Type>& x)const;
返回: x.get()
。
"boost/multi_index/member.hpp"
概要namespace boost{ namespace multi_index{ template<class Class,typename Type,Type Class::*PtrToMember> struct member; template<class Class,typename Type,std::size_t OffsetOfMember> struct member_offset; // deprecated #define BOOST_MULTI_INDEX_MEMBER(Class,Type,MemberName) implementation defined } // namespace boost::multi_index } // namespace boost
member
member
是一个 键值提取器
,旨在访问类的给定成员。
template<class Class,typename Type,Type Class::*PtrToMember> struct member { typedef Type result_type; // only provided if const ChainedPtr& is not convertible to const Class& template<typename ChainedPtr> Type& operator()(const ChainedPtr& x)const; const Type& operator()(const Class& x)const; Type& operator()(Class& x)const; // only provided if Type is non-const const Type& operator()(const reference_wrapper<const Class>& x)const; Type& operator()(const reference_wrapper<Class>& x)const; };
PtrToMember
模板参数指定要提取的特定 Type Class::*
成员指针。 member<Class,Type,PtrToMember>
是以下模型的模型
Class
的 键值提取器
,如果 Type
不是 const
限定的,则为读/写,reference_wrapper<const Class>
的 键值提取器
,reference_wrapper<Class>
的 键值提取器
,如果 Type
不是 const
限定的,则为读/写,const Class
的 链式指针 的 键值提取器
,Class
的 链式指针 的 键值提取器
,如果 Type
不是 const
限定的,则为读/写。member
成员template<typename ChainedPtr> Type& operator()(const ChainedPtr& x)const;
要求:ChainedPtr
是指向Type
的 链式指针 类型。
返回: 对x
链式指向的对象的引用。
const Type& operator()(const Class& x)const;
返回: x.*PtrToMember
。
Type& operator()(Class& x)const;
返回: x.*PtrToMember
。
const Type& operator()(const reference_wrapper<const Class>& x)const;
返回: x.get().*PtrToMember
。
Type& operator()(const reference_wrapper<Class>& x)const;
返回: x.get().*PtrToMember
。
member_offset
member_offset
旨在克服某些旧版编译器的限制,目前已弃用。 有关更多信息,请参阅 Boost.MultiIndex 的 先前版本。
BOOST_MULTI_INDEX_MEMBER
BOOST_MULTI_INDEX_MEMBER(Class,Type,MemberName)
此宏被设计为旧版编译器的可移植性机制,在这些编译器中可能不支持 member
。 因此,在现代环境中不再需要它,但某些用户可能仍然更喜欢它而不是普通的 member
,因为它提供了稍微简洁的语法。
"boost/multi_index/mem_fun.hpp"
概要namespace boost{ namespace multi_index{ template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()const> struct const_mem_fun; template< class Class,typename Type,Type (Class::*PtrToMemberFunction)()const volatile > struct cv_mem_fun; template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()const&> struct cref_mem_fun; template< class Class,typename Type,Type (Class::*PtrToMemberFunction)()const volatile& > struct cvref_mem_fun; template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()> struct mem_fun; template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()volatile> struct volatile_mem_fun; template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()&> struct ref_mem_fun; template< class Class,typename Type,Type (Class::*PtrToMemberFunction)()volatile& > struct vref_mem_fun; template< class Class,typename Type, typename PtrToMemberFunctionType,PtrToMemberFunctionType PtrToMemberFunction > struct const_mem_fun_explicit; // deprecated template< class Class,typename Type, typename PtrToMemberFunctionType,PtrToMemberFunctionType PtrToMemberFunction > struct mem_fun_explicit; // deprecated #define BOOST_MULTI_INDEX_CONST_MEM_FUN(Class,Type,MemberFunName) \ implementation defined #define BOOST_MULTI_INDEX_MEM_FUN(Class,Type,MemberFunName) \ implementation defined } // namespace boost::multi_index } // namespace boost
const_mem_fun
const_mem_fun
是一个 键值提取器
,它返回调用类的给定常量成员函数的结果作为键值。
template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()const> struct const_mem_fun { typedef typename remove_reference<Type>::type result_type; // only provided if const ChainedPtr& is not convertible to const Class& template<typename ChainedPtr> Type operator()(const ChainedPtr& x)const; Type operator()(const Class& x)const; Type operator()(const reference_wrapper<const Class>& x)const; Type operator()(const reference_wrapper<Class>& x)const; };
PtrToMemberFunction
模板参数指定用于提取的特定 Type (Class::*PtrToMemberFunction)()const
指向常量成员函数的指针。 const_mem_fun<Class,Type,PtrToMemberFunction>
是以下模型的模型
Class
的 键值提取器
,reference_wrapper<const Class>
的 键值提取器
,reference_wrapper<Class>
的 键值提取器
,const Class
的 链式指针 的 键值提取器
,Class
的 链式指针 的 键值提取器
,Type
是对非 const
限定类型的左值引用,则也是读/写。
const_mem_fun
成员template<typename ChainedPtr> Type operator()(const ChainedPtr& x)const;
要求:ChainedPtr
是指向Type
的 链式指针 类型。
返回:(y.*PtrToMemberFunction)()
,其中y
是x
链式指向的对象。
Type operator()(const Class& x)const;
返回: (x.*PtrToMemberFunction)()
。
Type operator()(const reference_wrapper<const Class>& x)const;
返回: (x.get().*PtrToMemberFunction)()
。
Type operator()(const reference_wrapper<Class>& x)const;
返回: (x.get().*PtrToMemberFunction)()
。
cv_mem_fun
, cref_mem_fun
和 cvref_mem_fun
这些 键值提取器
是 const_mem_fun
的变体,用于传递的成员函数是以下情况:
const volatile
(cv_mem_fun
),const &
限定的 (cref_mem_fun
),const volatile &
限定的 (cvref_mem_fun
)。const_mem_fun
完全相同。
mem_fun
mem_fun
是一个 键值提取器
,它返回调用类的给定成员函数的结果作为键值。
template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()> struct mem_fun { typedef typename remove_reference<Type>::type result_type; // only provided if ChainedPtr& is not convertible to Class& template<typename ChainedPtr> Type operator()(const ChainedPtr& x)const; Type operator()(Class& x)const; Type operator()(const reference_wrapper<Class>& x)const; };
PtrToMemberFunction
模板参数指定用于提取的特定 Type (Class::*PtrToMemberFunction)()
指向成员函数的指针。 mem_fun<Class,Type,PtrToMemberFunction>
是以下模型的模型
Type
是对非 const
限定类型的左值引用,则也是读/写。
mem_fun
成员template<typename ChainedPtr> Type operator()(const ChainedPtr& x)const;
要求:ChainedPtr
是指向Type
的 链式指针 类型。
返回:(y.*PtrToMemberFunction)()
,其中y
是x
链式指向的对象。
Type operator()(Class& x)const;
返回: (x.*PtrToMemberFunction)()
。
Type operator()(const reference_wrapper<Class>& x)const;
返回: (x.get().*PtrToMemberFunction)()
。
volatile_mem_fun
, ref_mem_fun
和 vref_mem_fun
这些 键值提取器
是 mem_fun
的变体,用于传递的成员函数是以下情况:
volatile
(volatile_mem_fun
),&
限定的 (ref_mem_fun
),volatile &
限定的 (vref_mem_fun
)。mem_fun
完全相同。
const_mem_fun_explicit
和 mem_fun_explicit
这些提取器作为 MSVC++ 6.0 的解决方法提供,现在已弃用。 有关更多信息,请参阅 Boost.MultiIndex 的 先前版本。
BOOST_MULTI_INDEX_CONST_MEM_FUN
和 BOOST_MULTI_INDEX_MEM_FUN
BOOST_MULTI_INDEX_CONST_MEM_FUN(Class,Type,MemberFunName) BOOST_MULTI_INDEX_MEM_FUN(Class,Type,MemberFunName)
用于 const_mem_fun
和 mem_fun
的可移植性宏。 尽管现代编译器不再需要,但某些用户可能仍然决定使用它们,因为它们提供了稍微简洁的语法。
"boost/multi_index/global_fun.hpp"
概要namespace boost{ namespace multi_index{ template<class Value,typename Type,Type (*PtrToFunction)(Value)> struct global_fun; } // namespace boost::multi_index } // namespace boost
global_fun
global_fun
是一个 键值提取器
,它基于给定的全局或静态成员函数,该函数接受基类型作为参数并返回关联的键值。
template<class Value,typename Type,Type (*PtrToFunction)(Value)> struct global_fun { typedef typename remove_reference<Type>::type result_type; // Only provided under the following circumstances: // - If Value is a reference to a constant type, only provided // when const ChainedPtr& is not convertible to Value; // - if Value is a reference to a non-const type, only provided // when ChainedPtr& is not convertible to Value; // - else, only provided when const ChainedPtr& is not // convertible to const Value&. Type operator()(const ChainedPtr& x)const; // only provided if Value is a reference type Type operator()(Value x)const; // only provided if Value is not a reference type Type operator()(const Value& x)const; // only provided if Value is not a reference type Type operator()(const reference_wrapper<const Value>& x)const; // only provided if Value is a reference type Type operator()( const reference_wrapper< remove_reference<Value>::type>& x)const; // only provided if Value is not a reference type or is // a reference to a constant type Type operator()( const reference_wrapper< typename remove_const< typename remove_reference<Value>::type>::type>& x)const; };
PtrToFunction
指定用于从某些 BaseType
提取类型为 Type
的键值的特定函数。 global_fun
支持以下函数签名
Type f(BaseType)
(Value
为 BaseType
),Type f(const BaseType&)
(Value
为 const BaseType&
),Type f(BaseType&)
(Value
为 BaseType&
)。global_fun<Type,Value,PtrToFunction>
是以下模型的模型当 Value
为 BaseType
或 const BaseType&
时,global_fun<Type,Value,PtrToFunction>
也是以下模型的模型BaseType
的 键值提取器
,reference_wrapper<const BaseType>
的 键值提取器
,const BaseType
的 链式指针 的 键值提取器
。Type
是对非 const
限定类型的左值引用,则 global_fun<Type,Value,PtrToFunction>
也是读/写。
global_fun
成员template<typename ChainedPtr> Type operator()(const ChainedPtr& x)const;
要求:ChainedPtr
是指向Value
的 链式指针 类型。
返回:PtrToFunction)(y)
,其中y
是x
链式指向的对象。
Type operator()(Value x)const;
返回: PtrToFunction(x)
。
Type operator()(const Value& x)const;
返回: PtrToFunction(x)
。
Type operator()(const reference_wrapper<const Value>& x)const;
返回: PtrToFunction(x.get())
。
Type operator()(
const reference_wrapper<remove_reference<Value>::type>& x)const;
返回: PtrToFunction(x.get())
。
Type operator()(
const reference_wrapper<
typename remove_const<
typename remove_reference<Value>::type>::type>& x)const;
返回: PtrToFunction(x.get())
。
"boost/multi_index/composite_key.hpp"
概要namespace boost{ namespace multi_index{ template<typename Value,typename KeyFromValue0,...,typename KeyFromValuen> struct composite_key; template<typename CompositeKey> struct composite_key_result; // comparison operators for composite_key_result: // OP is any of ==,<,!=,>,>=,<= template<typename CompositeKey1,typename CompositeKey2> bool operator OP( const composite_key_result<CompositeKey1>& x, const composite_key_result<CompositeKey2>& y); template<typename CompositeKey,typename... Values> bool operator OP( const composite_key_result<CompositeKey>& x, const std::tuple<Values...>& y); template<typename CompositeKey,typename... Values> bool operator OP( const std::tuple<Values...>& x, const composite_key_result<CompositeKey>& y); template<typename CompositeKey,typename Value0,...,typename Valuen> bool operator OP( const composite_key_result<CompositeKey>& x, const boost::tuple<Value0,...,Valuen>& y); template<typename Value0,...,typename Valuen,typename CompositeKey> bool operator OP( const boost::tuple<Value0,...,Valuen>& x, const composite_key_result<CompositeKey>& y); // equality functors: template<typename Pred0,...,typename Predn> struct composite_key_equal_to; template<typename CompositeKeyResult> struct composite_key_result_equal_to; // deprecated // comparison functors: template<typename Compare0,...,typename Comparen> struct composite_key_compare; template<typename CompositeKeyResult> struct composite_key_result_less; // deprecated template<typename CompositeKeyResult> struct composite_key_result_greater; // deprecated // hash functors: template<typename Hash0,...,typename Hashn> struct composite_key_hash; template<typename CompositeKeyResult> struct composite_key_result_hash; // deprecated } // namespace boost::multi_index } // namespace boost // specializations of external functors for composite_key_result: namespace std{ template<typename CompositeKey> struct equal_to<boost::multi_index::composite_key_result<CompositeKey> >; template<typename CompositeKey> struct less<boost::multi_index::composite_key_result<CompositeKey> >; template<typename CompositeKey> struct greater<boost::multi_index::composite_key_result<CompositeKey> >; } // namespace std namespace boost{ template<typename CompositeKey> struct hash<boost::multi_index::composite_key_result<CompositeKey> >; } // namespace boost
composite_key
composite_key
是一个 键值提取器
,它返回在编译时指定类型的多个键值提取器的组合值。 返回的对象类型为 composite_key_result
<composite_key>
。
template<typename Value,typename KeyFromValue0,...,typename KeyFromValuen> struct composite_key { typedef boost::tuple<KeyFromValue0,...,KeyFromValuen> key_extractor_tuple; typedef Value value_type; typedef composite_key_result<composite_key> result_type; composite_key( const KeyFromValue0& k0=KeyFromValue0(), ... const KeyFromValuen& kn=KeyFromValuen()); composite_key(const key_extractor_tuple& x); const key_extractor_tuple& key_extractors()const; key_extractor_tuple& key_extractors() // only provided if const ChainedPtr& is not convertible to const value_type& template<typename ChainedPtr> result_type operator()(const ChainedPtr& x)const; result_type operator()(const value_type& x)const; result_type operator()(const reference_wrapper<const value_type>& x)const; result_type operator()(const reference_wrapper<value_type>& x)const; };
KeyFromValue0
, ... , KeyFromValuen
是组合到复合键值中的键值提取器的类型。 这些类型中的每一种都必须是来自 Value
的 键值提取器
。 必须至少提供一个键值提取器。 composite_key
实例化的最大键值提取器数量是实现定义的。 composite_key
在内部存储每个组成键值提取器类型的对象。 composite_key<Value,KeyFromValue0,...,KeyFromValuen>
是以下模型的模型
Value
的 键值提取器
,reference_wrapper<const Value>
的 键值提取器
,reference_wrapper<Value>
的 键值提取器
,const Value
的 链式指针 的 键值提取器
,Value
的 链式指针 的 键值提取器
。composite_key
成员composite_key(
const KeyFromValue0& k0=KeyFromValue0(),
...
const KeyFromValuen& kn=KeyFromValuen());
效果: 构造一个 composite_key
,它存储提供的键值提取器对象的副本。
composite_key(const key_extractor_tuple& x);
效果: 构造一个composite_key
,它存储在x
中提供的键值提取器对象的副本。
const key_extractor_tuple& key_extractors()const;
返回: 对元组的常量引用,该元组保存由 composite_key
内部存储的键值提取器。
key_extractor_tuple& key_extractors();
返回: 对元组的引用,该元组保存由 composite_key
内部存储的键值提取器。
template<typename ChainedPtr>
result_type operator()(const ChainedPtr& x)const;
要求:ChainedPtr
是指向result_type
的 链式指针 类型。
返回: 依赖于*this
和y
的result_type
对象,其中y
是x
链式指向的对象。
result_type operator()(const value_type& x)const;
返回: 依赖于*this
和x
的result_type
对象。
result_type operator()(const reference_wrapper<const value_type>& x)const;
返回: 依赖于*this
和x.get()
的result_type
对象。
result_type operator()(const reference_wrapper<value_type>& x)const;
返回: 依赖于*this
和x.get()
的result_type
对象。
composite_key_result
这是由 composite_key
实例化返回的不透明类型,作为其提取的键值。
template<typename CompositeKey> struct composite_key_result { no public interface available }; // comparison: // OP is any of ==,<,!=,>,>=,<= template<typename CompositeKey1,typename CompositeKey2> bool operator OP( const composite_key_result<CompositeKey1>& x, const composite_key_result<CompositeKey2>& y); template<typename CompositeKey,typename... Values> bool operator OP( const composite_key_result<CompositeKey>& x, const std::tuple<Values...>& y); template<typename CompositeKey,typename... Values> bool operator OP( const std::tuple<Values...>& x, const composite_key_result<CompositeKey>& y); template<typename CompositeKey,typename Value0,...,typename Valuen> bool operator OP( const composite_key_result<CompositeKey>& x, const boost::tuple<Value0,...,Valuen>& y); template<typename Value0,...,typename Valuen,typename CompositeKey> bool operator OP( const boost::tuple<Value0,...,Valuen>& x, const composite_key_result<CompositeKey>& y);
CompositeKey
是与 composite_key_result
类型关联的 composite_key
实例化。 由复合键值返回的 composite_key_result
类型的对象必须始终被视为临时对象,即它们不应被存储或复制。 composite_key_result
不保证是 DefaultConstructible
或 CopyAssignable
。 类型为 composite_key_result<CompositeKey>
的每个对象都在内部关联到从中返回它的 CompositeKey
和类型为 CompositeKey::value_type
的对象,复合键值已应用于该对象。
给定类型为 composite_key_result<CompositeKey>
的 x
,我们使用以下符号
ck(x)
是与 x
关联的 CompositeKey
对象,v(x)
是与 x
关联的类型为 CompositeKey::value_type
的对象,ki(x) = ck(x).key_extractors().get<i>()
,即 ck(x)
的第 i
个键值提取器,xi = ki(x)(v(x))
,即由第 i
个键值提取器从 v(x)
提取的键值,length(x)
是 ck(x)
的键值提取器的数量。y
是值的 std::tuple
或 boost::tuple
,我们定义yi=get<i>(y)
,length(y)
是 y
的元素数量。template<typename CompositeKey1,typename CompositeKey2>
bool operator==(
const composite_key_result<CompositeKey1>& x,
const composite_key_result<CompositeKey2>& y);
template<typename CompositeKey,typename... Values>
bool operator==(
const composite_key_result<CompositeKey>& x,
const std::tuple<Values...>& y);
template<typename CompositeKey,typename... Values>
bool operator==(
const std::tuple<Values...>& x,
const composite_key_result<CompositeKey>& y);
template<typename CompositeKey,typename Value0,...,typename Valuen>
bool operator==(
const composite_key_result<CompositeKey>& x,
const boost::tuple<Value0,...,Valuen>& y);
template<typename Value0,...,typename Valuen,typename CompositeKey>
bool operator==(
const boost::tuple<Value0,...,Valuen>& x,
const composite_key_result<CompositeKey>& y);
要求:length(x)==length(y)
。 表达式xi==yi
对于[0,length(x))
中的所有i
均有效。
返回: 当且仅当对于复杂度: 执行的键值提取操作和比较次数不超过评估上述表达式所需的次数,从[0,length(x))
中的所有i
,xi==yi
时,返回true
。i==0
开始。 一旦确定结果为false
,评估就会短路。
template<typename CompositeKey1,typename CompositeKey2>
bool operator<(
const composite_key_result<CompositeKey1>& x,
const composite_key_result<CompositeKey2>& y);
template<typename CompositeKey,typename... Values>
bool operator<(
const composite_key_result<CompositeKey>& x,
const std::tuple<Values...>& y);
template<typename CompositeKey,typename... Values>
bool operator<(
const std::tuple<Values...>& x,
const composite_key_result<CompositeKey>& y);
template<typename CompositeKey,typename Value0,...,typename Valuen>
bool operator<(
const composite_key_result<CompositeKey>& x,
const boost::tuple<Value0,...,Valuen>& y);
template<typename Value0,...,typename Valuen,typename CompositeKey>
bool operator<(
const boost::tuple<Value0,...,Valuen>& x,
const composite_key_result<CompositeKey>& y);
要求: 表达式xi<yi
和yi<xi
对于[0,min(length(x),length(y)))
中的所有i
均有效。
返回: 当且仅当存在某个j
在范围[0,min(length(x),length(y)))
中,使得对于复杂度: 执行的键值提取操作和比较次数不超过评估上述表达式所需的次数,从[0,j)
中的所有i
,!(xi<yi) && !(yi<xi)
,
xj<yj
.i==0
开始。 一旦确定结果为false
,评估就会短路。
template<typename CompositeKey1,typename CompositeKey2>
bool operator OP(
const composite_key_result<CompositeKey1>& x,
const composite_key_result<CompositeKey2>& y);
template<typename CompositeKey,typename... Values>
bool operator OP(
const composite_key_result<CompositeKey>& x,
const std::tuple<Values...>& y);
template<typename CompositeKey,typename... Values>
bool operator OP(
const std::tuple<Values...>& x,
const composite_key_result<CompositeKey>& y);
template<typename CompositeKey,typename Value0,...,typename Valuen>
bool operator OP(
const composite_key_result<CompositeKey>& x,
const boost::tuple<Value0,...,Valuen>& y);
template<typename Value0,...,typename Valuen,typename CompositeKey>
bool operator OP(
const boost::tuple<Value0,...,Valuen>& x,
const composite_key_result<CompositeKey>& y);
(OP
是 !=
, >
, >=
, <=
中的任何一个。)
要求: 下面给出的表达式有效(对于考虑的特定OP
)。
返回: 当且仅当!(x==y)
(OP
为!=
),
y< x
(OP
为>
),
!(x< y)
(OP
为>=
),
!(y< x)
(OP
为<=
)。
composite_key_equal_to
composite_key_equal_to
测试 composite_key_result
实例以及它们与值元组之间的相等性,使用内部存储的基本相等性谓词集合。
template<typename Pred0,...,typename Predn> struct composite_key_equal_to { typedef boost::tuple<Pred0,...,Predn> key_eq_tuple; composite_key_equal_to( const Pred0& p0=Pred0(), ... const Predn& pn=Predn()); composite_key_equal_to(const key_eq_tuple& x); const key_eq_tuple& key_eqs()const; key_eq_tuple& key_eqs(); template<typename CompositeKey1,typename CompositeKey2> bool operator()( const composite_key_result<CompositeKey1> & x, const composite_key_result<CompositeKey2> & y)const; template<typename CompositeKey,typename... Values> bool operator()( const composite_key_result<CompositeKey>& x, const std::tuple<Values...>& y)const; template<typename CompositeKey,typename... Values> bool operator()( const std::tuple<Values...>& x, const composite_key_result<CompositeKey>& y)const; template<typename CompositeKey,typename Value0,...,typename Valuen> bool operator()( const composite_key_result<CompositeKey>& x, const boost::tuple<Value0,...,Valuen>& y)const; template<typename Value0,...,typename Valuen,typename CompositeKey> bool operator()( const boost::tuple<Value0,...,Valuen>& x, const composite_key_result<CompositeKey>& y)const; };
Pred0
, ... , Predn
是 composite_key_equal_to
存储的相等性二元谓词的类型。 这些谓词中的每一个都必须是 CopyConstructible
和 CopyAssignable
。 必须至少提供一个相等性谓词。 composite_key_equal_to
实例化的最大相等性谓词数量是实现定义的。 composite_key_equal_to
是 CopyConstructible
和 CopyAssignable
。 如果每个 Predi
本身都是 DefaultConstructible
,它也是 DefaultConstructible
。
请注意,形式上不要求 Predi
类型以任何明确的方式充当相等性谓词。 然而,如果情况如此,composite_key_equal_to
的语义是明确定义的,如关于 composite_key_result
的语义 一节中所述。
在下文中,我们使用为 composite_key_result
引入的相同 符号。
composite_key_equal_to
成员composite_key_equal_to(
const Pred0& p0=Pred0(),
...
const Predn& pn=Predn());
效果: 构造一个 composite_key_equal_to
,它存储提供的相等性谓词的副本。
composite_key_equal_to(const key_eq_tuple& x);
效果: 构造一个composite_key_equal_to
,它存储在x
中提供的相等性谓词对象的副本。
const key_eq_tuple& key_eqs()const;
返回: 对元组的常量引用,该元组保存由 composite_key_equal_to
内部存储的相等性谓词对象。
key_eq_tuple& key_eqs();
返回: 对元组的引用,该元组保存由 composite_key_equal_to
内部存储的相等性谓词对象。
template<typename CompositeKey1,typename CompositeKey2>
bool operator()(
const composite_key_result<CompositeKey1> & x,
const composite_key_result<CompositeKey2> & y)const;
template<typename CompositeKey,typename Values...>
bool operator()(
const composite_key_result<CompositeKey>& x,
const std::tuple<Values...>& y)const;
template<typename CompositeKey,typename Values...>
bool operator()(
const std::tuple<Values...>& x,
const composite_key_result<CompositeKey>& y)const;
template<typename CompositeKey,typename Value0,...,typename Valuen>
bool operator()(
const composite_key_result<CompositeKey>& x,
const boost::tuple<Value0,...,Valuen>& y)const;
template<typename Value0,...,typename Valuen,typename CompositeKey>
bool operator()(
const boost::tuple<Value0,...,Valuen>& x,
const composite_key_result<CompositeKey>& y)const;
要求:length(x)==length(y)
。 表达式key_eqs().get<i>()(xi,yi)
和key_eqs().get<i>()(yi,xi)
对于[0,length(x))
中的所有i
均有效。
返回: 当且仅当对于复杂度: 执行的键值提取操作和比较次数不超过评估上述表达式所需的次数,从[0,length(x))
中的所有i
,key_eqs().get<i>()(xi,yi)
时,返回true
。
i==0
开始。 一旦确定结果为false
,评估就会短路。
composite_key_result_equal_to
已弃用。 请改用 std::equal_to<CompositeKeyResult>
。
std::equal_to
对 composite_key
结果的特化
std::equal_to<CompositeKeyResult>
,其中 CompositeKeyResult
是 composite_key_result
的实例化,其行为类似于 composite_key_equal_to
的特定化,其中提供的所有比较谓词都是 std::equal_to
的实例化。
namespace std{ template<typename CompositeKey> struct equal_to<boost::multi_index::composite_key_result<CompositeKey> > { typedef boost::multi_index::composite_key_result< CompositeKey> first_argument_type; typedef first_argument_type second_argument_type; typedef bool result_type; template<typename CompositeKey1,typename CompositeKey2> bool operator()( const boost::multi_index::composite_key_result<CompositeKey1> & x, const boost::multi_index::composite_key_result<CompositeKey2> & y)const; template<typename CompositeKey,typename... Values> bool operator()( const boost::multi_index::composite_key_result<CompositeKey>& x, const std::tuple<Values...>& y)const; template<typename CompositeKey,typename... Values> bool operator()( const std::tuple<Values...>& x, const boost::multi_index::composite_key_result<CompositeKey>& y)const; template<typename CompositeKey,typename Value0,...,typename Valuen> bool operator()( const boost::multi_index::composite_key_result<CompositeKey>& x, const boost::tuple<Value0,...,Valuen>& y)const; template<typename Value0,...,typename Valuen,typename CompositeKey> bool operator()( const boost::tuple<Value0,...,Valuen>& x, const boost::multi_index::composite_key_result<CompositeKey>& y)const; }; } // namespace std
CompositeKeyResult
必须是某种类型 composite_key<KeyFromValue0,...,KeyFromValuen>
的 composite_key_result
的实例化。 然后 std::equal_to<CompositeKeyResult>::operator()
等效于 composite_key_equal_to<Pred0,...,Predn>::operator()
,取
对于所有i = 0,...,n
,Predi = std::equal_to<KeyFromValuei::result_type>
。
除了 composite_key_equal_to
施加的对 Predi
的要求外,这些类型中的每一种都必须是 DefaultConstructible
。 std::equal_to<CompositeKeyResult>
是 DefaultConstructible
、CopyConstructible
和 CopyAssignable
。
composite_key_compare
composite_key_compare
使用内部存储的基本比较谓词集合,比较 composite_key_result
实例之间以及它们与值元组之间的关系。
template<typename Compare0,...,typename Comparen> struct composite_key_compare { typedef boost::tuple<Compare0,...,Comparen> key_comp_tuple; composite_key_compare( const Compare0& c0=Compare0(), ... const Comparen& cn=Comparen()); composite_key_compare(const key_comp_tuple& x); const key_comp_tuple& key_comps()const; key_comp_tuple& key_comps(); template<typename CompositeKey1,typename CompositeKey2> bool operator()( const composite_key_result<CompositeKey1> & x, const composite_key_result<CompositeKey2> & y)const; template<typename CompositeKey,typename... Values> bool operator()( const composite_key_result<CompositeKey>& x, const std::tuple<Values...>& y)const; template<typename CompositeKey,typename... Values> bool operator()( const std::tuple<Values...>& x, const composite_key_result<CompositeKey>& y)const; template<typename CompositeKey,typename Value0,...,typename Valuen> bool operator()( const composite_key_result<CompositeKey>& x, const boost::tuple<Value0,...,Valuen>& y)const; template<typename Value0,...,typename Valuen,typename CompositeKey> bool operator()( const boost::tuple<Value0,...,Valuen>& x, const composite_key_result<CompositeKey>& y)const; template<typename CompositeKey,typename Value> bool operator()( const composite_key_result<CompositeKey>& x,const Value& y)const; template<typename Value,typename CompositeKey> bool operator()( const Value& x,const composite_key_result<CompositeKey>& y)const; };
Compare0
, ... , Comparen
是 composite_key_compare
存储的比较二元谓词的类型。 这些谓词中的每一个都必须是 CopyConstructible
和 CopyAssignable
。 必须至少提供一个比较谓词。 composite_key_compare
实例化的最大比较谓词数量是实现定义的。 composite_key_compare
是 CopyConstructible
和 CopyAssignable
。 如果每个 Comparei
本身都是 DefaultConstructible
,它也是 DefaultConstructible
。
请注意,形式上不要求 Comparei
类型以任何明确的方式充当比较谓词。 然而,如果情况如此,composite_key_compare
的语义是明确定义的,如关于 composite_key_result
的语义 一节中所述。
在下文中,我们使用为 composite_key_result
引入的相同 符号。
composite_key_compare
成员composite_key_compare(
const Compare0& c0=Compare0(),
...
const Comparen& cn=Comparen());
效果: 构造一个 composite_key_compare
,它存储提供的比较谓词的副本。
composite_key_compare(const key_comp_tuple& x);
效果: 构造一个composite_key_compare
,它存储在x
中提供的比较谓词对象的副本。
const key_comp_tuple& key_comps()const;
返回: 对元组的常量引用,该元组保存由 composite_key_compare
内部存储的比较谓词对象。
key_comp_tuple& key_comps();
返回: 对元组的引用,该元组保存由 composite_key_compare
内部存储的比较谓词对象。
template<typename CompositeKey1,typename CompositeKey2>
bool operator()(
const composite_key_result<CompositeKey1> & x,
const composite_key_result<CompositeKey2> & y)const;
template<typename CompositeKey,typename... Values>
bool operator()(
const composite_key_result<CompositeKey>& x,
const std::tuple<Values...>& y)const;
template<typename CompositeKey,typename... Values>
bool operator()(
const std::tuple<Values...>& x,
const composite_key_result<CompositeKey>& y)const;
template<typename CompositeKey,typename Value0,...,typename Valuen>
bool operator()(
const composite_key_result<CompositeKey>& x,
const boost::tuple<Value0,...,Valuen>& y)const;
template<typename Value0,...,typename Valuen,typename CompositeKey>
bool operator()(
const boost::tuple<Value0,...,Valuen>& x,
const composite_key_result<CompositeKey>& y)const;
要求: 表达式key_comps().get<i>()(xi,yi)
和key_comps().get<i>()(yi,xi)
对于[0,min(length(x),length(y)))
中的所有i
均有效。
返回: 当且仅当存在某个j
在范围[0,min(length(x),length(y)))
中,使得对于复杂度: 执行的键值提取操作和比较次数不超过评估上述表达式所需的次数,从[0,j)
中的所有i
,!key_comps().get<i>()(xi,yi) && !key_comps().get<i>()(yi,xi)
,
key_comps().get<j>()(xj,yj)
.i==0
开始。 一旦确定结果为false
,评估就会短路。
template<typename CompositeKey,typename Value>
bool operator()(
const composite_key_result<CompositeKey>& x,const Value& y)const;
效果return operator()(x,boost::make_tuple(boost::cref(y)));
template<typename Value,typename CompositeKey>
bool operator()(
const Value& x,const composite_key_result<CompositeKey>& y)const;
效果return operator()(boost::make_tuple(boost::cref(x)),y);
composite_key_result_less
已弃用。 请改用 std::less<CompositeKeyResult>
。
composite_key_result_greater
已弃用。 请改用 std::greater<CompositeKeyResult>
。
std::less
对 composite_key
结果的特化
std::less<CompositeKeyResult>
,其中 CompositeKeyResult
是 composite_key_result
的实例化,其行为类似于 composite_key_compare
的特定化,其中提供的所有比较谓词都是 std::less
的实例化。
namespace std{ template<typename CompositeKey> struct less<boost::multi_index::composite_key_result<CompositeKey> > { typedef boost::multi_index::composite_key_result< CompositeKey> first_argument_type; typedef first_argument_type second_argument_type; typedef bool result_type; template<typename CompositeKey1,typename CompositeKey2> bool operator()( const boost::multi_index::composite_key_result<CompositeKey1> & x, const boost::multi_index::composite_key_result<CompositeKey2> & y)const; template<typename CompositeKey,typename... Values> bool operator()( const boost::multi_index::composite_key_result<CompositeKey>& x, const std::tuple<Values...>& y)const; template<typename CompositeKey,typename... Values> bool operator()( const std::tuple<Values...>& x, const boost::multi_index::composite_key_result<CompositeKey>& y)const; template<typename CompositeKey,typename Value0,...,typename Valuen> bool operator()( const boost::multi_index::composite_key_result<CompositeKey>& x, const boost::tuple<Value0,...,Valuen>& y)const; template<typename Value0,...,typename Valuen,typename CompositeKey> bool operator()( const boost::tuple<Value0,...,Valuen>& x, const boost::multi_index::composite_key_result<CompositeKey>& y)const; template<typename CompositeKey,typename Value> bool operator()( const boost::multi_index::composite_key_result<CompositeKey>& x, const Value& y)const; template<typename Value,typename CompositeKey> bool operator()( const Value& x, const boost::multi_index::composite_key_result<CompositeKey>& y)const; }; } // namespace std
CompositeKeyResult
必须是某种类型 composite_key<KeyFromValue0,...,KeyFromValuen>
的 composite_key_result
的实例化。 然后 std::less<CompositeKeyResult>::operator()
等效于 composite_key_compare<Compare0,...,Comparen>::operator()
,取
对于所有i = 0,...,n
,Comparei = std::less<KeyFromValuei::result_type>
。
除了 composite_key_compare
施加的对 Comparei
的要求外,这些类型中的每一种都必须是 DefaultConstructible
。 std::less<CompositeKeyResult>
是 DefaultConstructible
、CopyConstructible
和 CopyAssignable
。
std::greater
对 composite_key
结果的特化
std::greater<CompositeKeyResult>
,其中 CompositeKeyResult
是 composite_key_result
的实例化,其行为类似于 composite_key_compare
的特定化,其中提供的所有比较谓词都是 std::greater
的实例化。
namespace std{ template<typename CompositeKey> struct greater<boost::multi_index::composite_key_result<CompositeKey> > { typedef boost::multi_index::composite_key_result< CompositeKey> first_argument_type; typedef first_argument_type second_argument_type; typedef bool result_type; template<typename CompositeKey1,typename CompositeKey2> bool operator()( const boost::multi_index::composite_key_result<CompositeKey1> & x, const boost::multi_index::composite_key_result<CompositeKey2> & y)const; template<typename CompositeKey,typename... Values> bool operator()( const boost::multi_index::composite_key_result<CompositeKey>& x, const std::tuple<Values...>& y)const; template<typename CompositeKey,typename... Values> bool operator()( const std::tuple<Values...>& x, const boost::multi_index::composite_key_result<CompositeKey>& y)const; template<typename CompositeKey,typename Value0,...,typename Valuen> bool operator()( const boost::multi_index::composite_key_result<CompositeKey>& x, const boost::tuple<Value0,...,Valuen>& y)const; template<typename Value0,...,typename Valuen,typename CompositeKey> bool operator()( const boost::tuple<Value0,...,Valuen>& x, const boost::multi_index::composite_key_result<CompositeKey>& y)const; template<typename CompositeKey,typename Value> bool operator()( const boost::multi_index::composite_key_result<CompositeKey>& x, const Value& y)const; template<typename Value,typename CompositeKey> bool operator()( const Value& x, const boost::multi_index::composite_key_result<CompositeKey>& y)const; }; } // namespace std
CompositeKeyResult
必须是某种类型 composite_key<KeyFromValue0,...,KeyFromValuen>
的 composite_key_result
的实例化。 然后 std::greater<CompositeKeyResult>::operator()
等效于 composite_key_compare<Compare0,...,Comparen>::operator()
,取
对于所有i = 0,...,n
,Comparei = std::greater<KeyFromValuei::result_type>
。
除了 composite_key_compare
施加的对 Comparei
的要求外,这些类型中的每一种都必须是 DefaultConstructible
。 std::greater<CompositeKeyResult>
是 DefaultConstructible
、CopyConstructible
和 CopyAssignable
。
composite_key_hash
composite_key_hash
基于基本哈希函子集合,为 composite_key_result
实例生成哈希值。
template<typename Hash0,...,typename Hashn> struct composite_key_hash { typedef boost::tuple<Hash0,...,Hashn> key_hasher_tuple; composite_key_hash( const Hash0& h0=Hash0(), ... const Hashn& hn=Hashn()); composite_key_hash(const key_hasher_tuple& x); const key_hasher_tuple& key_hash_functions()const; key_hasher_tuple& key_hash_functions(); template<typename CompositeKey> std::size_t operator()( const composite_key_result<CompositeKey>& x)const; template<typename... Values> std::size_t operator()( const std::tuple<Values...>& x)const; template<typename Value0,...,typename Valuen> std::size_t operator()( const boost::tuple<Value0,...,Valuen>& x)const; };
Hash0
, ... , Hashn
是 composite_key_hash
存储的哈希一元函数对象的类型。 这些对象中的每一个都必须是 CopyConstructible
和 CopyAssignable
,并返回类型为 std::size_t
且在范围 [0, std::numeric_limits<std::size_t>::max())
) 内的值。 必须至少提供一个哈希函子。 composite_key_hash
实例化的最大哈希函子数量是实现定义的。 composite_key_hash
是 CopyConstructible
和 CopyAssignable
。 如果每个 Hashi
本身都是 DefaultConstructible
,它也是 DefaultConstructible
。
在下文中,我们使用为 composite_key_result
引入的相同 符号。
composite_key_hash
成员composite_key_hash(
const Hash0& h0=Hash0(),
...
const Hashn& hn=Hashn());
效果: 构造一个 composite_key_hash
,它存储提供的哈希函子的副本。
composite_key_hash(const key_hasher_tuple& x);
效果: 构造一个composite_key_hash
,它存储在x
中提供的哈希函子的副本。
const key_hasher_tuple& key_hash_functions()const;
返回: 对元组的常量引用,该元组保存由 composite_key_hash
内部存储的哈希函子。
key_hasher_tuple& key_hash_functions();
返回: 对元组的引用,该元组保存由 composite_key_hash
内部存储的哈希函子。
template<typename CompositeKey>
bool operator()(
const composite_key_result<CompositeKey>& x)const;
template<typename... Values>
bool operator()(
const std::tuple<Values...>& x)const;
template<typename Value0,...,typename Valuen>
bool operator()(
const boost::tuple<Value0,...,Valuen>& x)const;
要求:length(x)==length(key_hash_functions())
。 表达式key_hash_functions().get<i>()(xi)
对于[0,length(x))
中的所有i
均有效。
返回: 范围[0, std::numeric_limits<std::size_t>::max())
内的值,该值仅取决于数值元组(key_hash_functions().get<0>()(x0)
, ... ,key_hash_functions().get<N>()(xN)
), 其中N=length(x)-1
。
composite_key_result_hash
已弃用。 请改用 boost::hash<CompositeKeyResult>
。
boost::hash
对 composite_key
结果的特化
boost::hash<CompositeKeyResult>
,其中 CompositeKeyResult
是 composite_key_result
的实例化,其行为类似于 composite_key_hash
的特定化,其中提供的所有哈希函子都是 boost::hash
的实例化。
namespace boost{ template<typename CompositeKey> struct hash<multi_index::composite_key_result<CompositeKey> > { typedef multi_index::composite_key_result<CompositeKey> argument_type; typedef std::size_t result_type; template<typename CompositeKey> std::size_t operator()( const multi_index::composite_key_result<CompositeKey>& x)const; template<typename... Values> std::size_t operator()( const std::tuple<Values...>& x)const; template<typename Value0,...,typename Valuen> std::size_t operator()( const boost::tuple<Value0,...,Valuen>& x)const; }; } // namespace boost
CompositeKeyResult
必须是 composite_key_result
的实例化,针对某种类型 composite_key<KeyFromValue0,...,KeyFromValuen>
。 boost::hash<CompositeKeyResult>::operator()
随后等价于 composite_key_hash<Hash0,...,Hashn>::operator()
,采用
对于所有i = 0,...,n
,Hashi = boost::hash<KeyFromValuei::result_type>
。
除了 composite_key_hash
对 Hashi
施加的要求之外,这些类型中的每一种都必须是 DefaultConstructible
。 boost::hash<CompositeKeyResult>
是 DefaultConstructible
、CopyConstructible
和 CopyAssignable
。
composite_key_result
的语义composite_key_result
对象的相等性、比较和哈希操作的设计基于以下原理:composite_key_result
被视为一个“虚拟”元组,其每个元素都是相应基本键提取器的结果。 因此,任何给定的操作都解析为相应元素级操作的组合。 这种映射保留了所涉及基本操作的基本属性; 例如,如果基本谓词本身导出等价关系,则它定义了一个真正的等价关系。 我们可以用以下形式化的方式陈述这些事实。
考虑 composite_key_equal_to
的实例化,类型为 Pred0
, ... , Predn
,使得每个 Predi
在某种类型 Ti
上导出等价关系,并令 CompositeKey
为 composite_key<Value,KeyFromValue0,...,KeyFromValuej>
形式的类型,其中 j <= n
,使得
对于所有那么,i = 0,...,j
,KeyFromValuei::result_type = Ti
。
composite_key_equal_to
在 composite_key_result<CompositeKey>
类型的元素上导出等价关系; 这样两个对象是等价的,如果它们的所有基本键提取器值也是等价的。 此外,给定一个 composite_key_hash<Hash0,...,Hashj>
的实例化,以下类型是 (composite_key_hash
, composite_key_equal_to
) 关于 composite_key_result<CompositeKey>
的 Compatible Keys
前提是每个tuple<Q0,...,Qj>
,
composite_key_result<composite_key<K0,...,Kj> >
,对于所有i = 0,...,j
,其中Ki::result_type = Qi
。
Qi
要么是 Ti
,要么是 (Hashi
, Predi
) 的 Compatible Key
。
对于比较,考虑 composite_key_compare
的实例化,类型为 Compare0
, ... , Comparen
,使得每个 Comparei
在类型 Ti
上导出严格弱序关系。 那么,对于以上述相同方式定义的 CompositeKey
类型,composite_key_compare
在 composite_key_result<CompositeKey>
类型的元素上导出严格弱序关系,并且导出的顺序是字典序。 此外,以下类型是 composite_key_compare
关于 composite_key_result<CompositeKey>
的 Compatible Keys
前提是tuple<Q0,...,Qk>
,k <= n
composite_key_result<composite_key<K0,...,Kk> >
,对于所有i = 0,...,k
,其中Ki::result_type = Qi
。
i = 0,...,min(j,k)-1
,Qi
要么是 Ti
,要么不比 Ti
粗糙(Qi
是 Comparei
的 Compatible Key
,并且没有 Ti
的两个不同元素等价于 Qi
的单个元素);Qm
(其中 m = min(j,k)
)要么是 Tm
,要么是 Comparem
的 Compatible Key
。1+min(j,k)
个元素上按字典顺序进行。
composite_key_result
的相等性和比较运算符也具有类似的属性。 但是请注意,相等性仅为相同长度的对象定义,而比较则采用所考虑操作数的最小长度。 因此,由 x==y
导出的等价类是与 !(x<y)&&!(y<x)
相关的等价类的子集。
"boost/multi_index/key.hpp"
概要#include <boost/multi_index/member.hpp> #include <boost/multi_index/mem_fun.hpp> #include <boost/multi_index/global_fun.hpp> #include <boost/multi_index/composite_key.hpp> #if implementation defined /* auto non-type template parameters supported */ #define BOOST_MULTI_INDEX_KEY_SUPPORTED namespace boost{ namespace multi_index{ template<auto... Keys> using key=implementation defined; } /* namespace multi_index */ } /* namespace boost */ #endif
key
在符合 C++17 标准的环境中,key
为指定 Boost.MultiIndex 预定义的键提取器提供了一种非常简洁的语法。 传递给 key
的模板参数数量必须大于零,且不超过 composite_key
接受的最大键提取器数量。 key<Key>
解析为
Key
的类型为 Type Class::*
,则解析为 member<Class,Type,Key>
,Key
的类型为 Type (Class::*)()const
(带有或不带有 noexcept
规范),则解析为 const_mem_fun<Class,Type,Key>
,Key
的类型为 Type (Class::*)()const volatile
(带有或不带有 noexcept
规范),则解析为 cv_mem_fun<Class,Type,Key>
,Key
的类型为 Type (Class::*)()const&
(带有或不带有 noexcept
规范),则解析为 cref_mem_fun<Class,Type,Key>
,Key
的类型为 Type (Class::*)()const volatile&
(带有或不带有 noexcept
规范),则解析为 cvref_mem_fun<Class,Type,Key>
,Key
的类型为 Type (Class::*)()
(带有或不带有 noexcept
规范),则解析为 mem_fun<Class,Type,Key>
,Key
的类型为 Type (Class::*)()volatile
(带有或不带有 noexcept
规范),则解析为 volatile_mem_fun<Class,Type,Key>
,Key
的类型为 Type (Class::*)()&
(带有或不带有 noexcept
规范),则解析为 ref_mem_fun<Class,Type,Key>
,Key
的类型为 Type (Class::*)()volatile&
(带有或不带有 noexcept
规范),则解析为 vref_mem_fun<Class,Type,Key>
,Key
的类型为 Type (*)(Value)
(带有或不带有 noexcept
规范),则解析为 global_fun<Value,Type,Key>
,key<Key0,...,Keyn>
解析为 composite_key<Value,KeyFromValue0,...,KeyFromValuen>
,其中i = 0,...,n
,KeyFromValuei
= key<Keyi>
Value
= std::decay_t<Value0>
⊗ std::decay_t<Value1>
⊗ ··· ⊗ std::decay_t<Valuen>
,Valuei
对应于 KeyFromValuei
的关联 Class
或 Value
类型,而 T
⊗ Q
是 T
和 Q
之间最不通用的类型,定义为:如果 std::is_convertible_v<const T&,const Q&>
,则为 T
;如果 std::is_convertible_v<const Q&,const T&>
,则为 Q
;否则为未定义。
修订于 2020 年 4 月 19 日
© 版权所有 2003-2020 Joaquín M López Muñoz。 根据 Boost 软件许可协议 1.0 版本分发。(请参阅随附文件 LICENSE_1_0.txt 或在 https://boost.ac.cn/LICENSE_1_0.txt 复制)