]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/multi_index/mem_fun.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / multi_index / mem_fun.hpp
index 111c386c5f555f2cdabe65317d4fc1f02320e576..aa116f0379e062e2cc305e1572b13feba0a8e81f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright 2003-2015 Joaquin M Lopez Munoz.
+/* 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)
@@ -30,17 +30,30 @@ namespace multi_index{
 
 /* mem_fun implements a read-only key extractor based on a given non-const
  * member function of a class.
- * const_mem_fun does the same for const member functions.
- * Additionally, mem_fun  and const_mem_fun are overloaded to support
- * referece_wrappers of T and "chained pointers" to T's. By chained pointer
- * to T we  mean a type P such that, given a p of Type P
+ * Also, the following variations are provided:
+ *   const_mem_fun:    const member functions
+ *   volatile_mem_fun: volatile member functions
+ *   cv_mem_fun:       const volatile member functions
+ *   ref_mem_fun:      ref-qualifed member functions (C++11)
+ *   cref_mem_fun:     const ref-qualifed member functions (C++11)
+ *   vref_mem_fun:     volatile ref-qualifed member functions (C++11)
+ *   cvref_mem_fun:    const volatile ref-qualifed member functions (C++11)
+ *
+ * All of these classes are overloaded to support boost::referece_wrappers
+ * of T and "chained pointers" to T's. By chained pointer to T we mean a type
+ * P such that, given a p of Type P
  *   *...n...*x is convertible to T&, for some n>=1.
  * Examples of chained pointers are raw and smart pointers, iterators and
  * arbitrary combinations of these (vg. T** or unique_ptr<T*>.)
  */
 
-template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()const>
-struct const_mem_fun
+namespace detail{
+
+template<
+  class Class,typename Type,
+  typename PtrToMemberFunctionType,PtrToMemberFunctionType PtrToMemberFunction
+>
+struct const_mem_fun_impl
 {
   typedef typename remove_reference<Type>::type result_type;
 
@@ -74,8 +87,11 @@ struct const_mem_fun
   }
 };
 
-template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()>
-struct mem_fun
+template<
+  class Class,typename Type,
+  typename PtrToMemberFunctionType,PtrToMemberFunctionType PtrToMemberFunction
+>
+struct mem_fun_impl
 {
   typedef typename remove_reference<Type>::type result_type;
 
@@ -104,6 +120,62 @@ struct mem_fun
   }
 };
 
+} /* namespace multi_index::detail */
+
+template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()const>
+struct const_mem_fun:detail::const_mem_fun_impl<
+  Class,Type,Type (Class::*)()const,PtrToMemberFunction
+>{};
+
+template<
+  class Class,typename Type,
+  Type (Class::*PtrToMemberFunction)()const volatile
+>
+struct cv_mem_fun:detail::const_mem_fun_impl<
+  Class,Type,Type (Class::*)()const volatile,PtrToMemberFunction
+>{};
+
+template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()>
+struct mem_fun:
+  detail::mem_fun_impl<Class,Type,Type (Class::*)(),PtrToMemberFunction>{};
+
+template<
+  class Class,typename Type,Type (Class::*PtrToMemberFunction)()volatile
+>
+struct volatile_mem_fun:detail::mem_fun_impl<
+  Class,Type,Type (Class::*)()volatile,PtrToMemberFunction
+>{};
+
+#if !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
+
+template<
+  class Class,typename Type,Type (Class::*PtrToMemberFunction)()const&
+>
+struct cref_mem_fun:detail::const_mem_fun_impl<
+  Class,Type,Type (Class::*)()const&,PtrToMemberFunction
+>{};
+
+template<
+  class Class,typename Type,
+  Type (Class::*PtrToMemberFunction)()const volatile&
+>
+struct cvref_mem_fun:detail::const_mem_fun_impl<
+  Class,Type,Type (Class::*)()const volatile&,PtrToMemberFunction
+>{};
+
+template<class Class,typename Type,Type (Class::*PtrToMemberFunction)()&>
+struct ref_mem_fun:
+  detail::mem_fun_impl<Class,Type,Type (Class::*)()&,PtrToMemberFunction>{};
+
+template<
+  class Class,typename Type,Type (Class::*PtrToMemberFunction)()volatile&
+>
+struct vref_mem_fun:detail::mem_fun_impl<
+  Class,Type,Type (Class::*)()volatile&,PtrToMemberFunction
+>{};
+
+#endif
+
 /* MSVC++ 6.0 has problems with const member functions as non-type template
  * parameters, somehow it takes them as non-const. const_mem_fun_explicit
  * workarounds this deficiency by accepting an extra type parameter that
@@ -119,7 +191,8 @@ struct mem_fun
 
 template<
   class Class,typename Type,
-  typename PtrToMemberFunctionType,PtrToMemberFunctionType PtrToMemberFunction>
+  typename PtrToMemberFunctionType,PtrToMemberFunctionType PtrToMemberFunction
+>
 struct const_mem_fun_explicit
 {
   typedef typename remove_reference<Type>::type result_type;
@@ -156,7 +229,8 @@ struct const_mem_fun_explicit
 
 template<
   class Class,typename Type,
-  typename PtrToMemberFunctionType,PtrToMemberFunctionType PtrToMemberFunction>
+  typename PtrToMemberFunctionType,PtrToMemberFunctionType PtrToMemberFunction
+>
 struct mem_fun_explicit
 {
   typedef typename remove_reference<Type>::type result_type;