File indexing completed on 2025-01-18 09:42:11
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_MULTI_INDEX_MEM_FUN_HPP
0010 #define BOOST_MULTI_INDEX_MEM_FUN_HPP
0011
0012 #if defined(_MSC_VER)
0013 #pragma once
0014 #endif
0015
0016 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
0017 #include <boost/core/enable_if.hpp>
0018 #include <boost/mpl/if.hpp>
0019 #include <boost/type_traits/remove_reference.hpp>
0020
0021 #if !defined(BOOST_NO_SFINAE)
0022 #include <boost/type_traits/is_convertible.hpp>
0023 #endif
0024
0025 namespace boost{
0026
0027 template<class T> class reference_wrapper;
0028
0029 namespace multi_index{
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 namespace detail{
0051
0052 template<
0053 class Class,typename Type,
0054 typename PtrToMemberFunctionType,PtrToMemberFunctionType PtrToMemberFunction
0055 >
0056 struct const_mem_fun_impl
0057 {
0058 typedef typename remove_reference<Type>::type result_type;
0059
0060 template<typename ChainedPtr>
0061
0062 #if !defined(BOOST_NO_SFINAE)
0063 typename disable_if<
0064 is_convertible<const ChainedPtr&,const Class&>,Type>::type
0065 #else
0066 Type
0067 #endif
0068
0069 operator()(const ChainedPtr& x)const
0070 {
0071 return operator()(*x);
0072 }
0073
0074 Type operator()(const Class& x)const
0075 {
0076 return (x.*PtrToMemberFunction)();
0077 }
0078
0079 Type operator()(const reference_wrapper<const Class>& x)const
0080 {
0081 return operator()(x.get());
0082 }
0083
0084 Type operator()(const reference_wrapper<Class>& x)const
0085 {
0086 return operator()(x.get());
0087 }
0088 };
0089
0090 template<
0091 class Class,typename Type,
0092 typename PtrToMemberFunctionType,PtrToMemberFunctionType PtrToMemberFunction
0093 >
0094 struct mem_fun_impl
0095 {
0096 typedef typename remove_reference<Type>::type result_type;
0097
0098 template<typename ChainedPtr>
0099
0100 #if !defined(BOOST_NO_SFINAE)
0101 typename disable_if<
0102 is_convertible<ChainedPtr&,Class&>,Type>::type
0103 #else
0104 Type
0105 #endif
0106
0107 operator()(const ChainedPtr& x)const
0108 {
0109 return operator()(*x);
0110 }
0111
0112 Type operator()(Class& x)const
0113 {
0114 return (x.*PtrToMemberFunction)();
0115 }
0116
0117 Type operator()(const reference_wrapper<Class>& x)const
0118 {
0119 return operator()(x.get());
0120 }
0121 };
0122
0123 }
0124
0125 template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()const>
0126 struct const_mem_fun:detail::const_mem_fun_impl<
0127 Class,Type,Type (Class::*)()const,PtrToMemberFunction
0128 >{};
0129
0130 template<
0131 class Class,typename Type,
0132 Type (Class::*PtrToMemberFunction)()const volatile
0133 >
0134 struct cv_mem_fun:detail::const_mem_fun_impl<
0135 Class,Type,Type (Class::*)()const volatile,PtrToMemberFunction
0136 >{};
0137
0138 template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()>
0139 struct mem_fun:
0140 detail::mem_fun_impl<Class,Type,Type (Class::*)(),PtrToMemberFunction>{};
0141
0142 template<
0143 class Class,typename Type,Type (Class::*PtrToMemberFunction)()volatile
0144 >
0145 struct volatile_mem_fun:detail::mem_fun_impl<
0146 Class,Type,Type (Class::*)()volatile,PtrToMemberFunction
0147 >{};
0148
0149 #if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
0150
0151 template<
0152 class Class,typename Type,Type (Class::*PtrToMemberFunction)()const&
0153 >
0154 struct cref_mem_fun:detail::const_mem_fun_impl<
0155 Class,Type,Type (Class::*)()const&,PtrToMemberFunction
0156 >{};
0157
0158 template<
0159 class Class,typename Type,
0160 Type (Class::*PtrToMemberFunction)()const volatile&
0161 >
0162 struct cvref_mem_fun:detail::const_mem_fun_impl<
0163 Class,Type,Type (Class::*)()const volatile&,PtrToMemberFunction
0164 >{};
0165
0166 template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()&>
0167 struct ref_mem_fun:
0168 detail::mem_fun_impl<Class,Type,Type (Class::*)()&,PtrToMemberFunction>{};
0169
0170 template<
0171 class Class,typename Type,Type (Class::*PtrToMemberFunction)()volatile&
0172 >
0173 struct vref_mem_fun:detail::mem_fun_impl<
0174 Class,Type,Type (Class::*)()volatile&,PtrToMemberFunction
0175 >{};
0176
0177 #endif
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192 template<
0193 class Class,typename Type,
0194 typename PtrToMemberFunctionType,PtrToMemberFunctionType PtrToMemberFunction
0195 >
0196 struct const_mem_fun_explicit
0197 {
0198 typedef typename remove_reference<Type>::type result_type;
0199
0200 template<typename ChainedPtr>
0201
0202 #if !defined(BOOST_NO_SFINAE)
0203 typename disable_if<
0204 is_convertible<const ChainedPtr&,const Class&>,Type>::type
0205 #else
0206 Type
0207 #endif
0208
0209 operator()(const ChainedPtr& x)const
0210 {
0211 return operator()(*x);
0212 }
0213
0214 Type operator()(const Class& x)const
0215 {
0216 return (x.*PtrToMemberFunction)();
0217 }
0218
0219 Type operator()(const reference_wrapper<const Class>& x)const
0220 {
0221 return operator()(x.get());
0222 }
0223
0224 Type operator()(const reference_wrapper<Class>& x)const
0225 {
0226 return operator()(x.get());
0227 }
0228 };
0229
0230 template<
0231 class Class,typename Type,
0232 typename PtrToMemberFunctionType,PtrToMemberFunctionType PtrToMemberFunction
0233 >
0234 struct mem_fun_explicit
0235 {
0236 typedef typename remove_reference<Type>::type result_type;
0237
0238 template<typename ChainedPtr>
0239
0240 #if !defined(BOOST_NO_SFINAE)
0241 typename disable_if<
0242 is_convertible<ChainedPtr&,Class&>,Type>::type
0243 #else
0244 Type
0245 #endif
0246
0247 operator()(const ChainedPtr& x)const
0248 {
0249 return operator()(*x);
0250 }
0251
0252 Type operator()(Class& x)const
0253 {
0254 return (x.*PtrToMemberFunction)();
0255 }
0256
0257 Type operator()(const reference_wrapper<Class>& x)const
0258 {
0259 return operator()(x.get());
0260 }
0261 };
0262
0263
0264
0265
0266
0267
0268
0269
0270 #define BOOST_MULTI_INDEX_CONST_MEM_FUN(Class,Type,MemberFunName) \
0271 ::boost::multi_index::const_mem_fun< Class,Type,&Class::MemberFunName >
0272 #define BOOST_MULTI_INDEX_MEM_FUN(Class,Type,MemberFunName) \
0273 ::boost::multi_index::mem_fun< Class,Type,&Class::MemberFunName >
0274
0275 }
0276
0277 }
0278
0279 #endif