]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/function/function_template.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / function / function_template.hpp
index 0b05940b227fba9e131a0650c728f6272ee877de..56f6bb491a78f00e8422413674c17646914ab358 100644 (file)
@@ -11,7 +11,7 @@
 // Note: this header is a header template and must NOT have multiple-inclusion
 // protection.
 #include <boost/function/detail/prologue.hpp>
-#include <boost/detail/no_exceptions_support.hpp>
+#include <boost/core/no_exceptions_support.hpp>
 
 #if defined(BOOST_MSVC)
 #   pragma warning( push )
@@ -29,8 +29,7 @@
 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
 #   define BOOST_FUNCTION_ARGS BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS, a)
 #else
-#   include <boost/move/utility_core.hpp>
-#   define BOOST_FUNCTION_ARG(J,I,D) ::boost::forward< BOOST_PP_CAT(T,I) >(BOOST_PP_CAT(a,I))
+#   define BOOST_FUNCTION_ARG(J,I,D) static_cast<BOOST_PP_CAT(T,I)&&>(BOOST_PP_CAT(a,I))
 #   define BOOST_FUNCTION_ARGS BOOST_PP_ENUM(BOOST_FUNCTION_NUM_ARGS,BOOST_FUNCTION_ARG,BOOST_PP_EMPTY)
 #endif
 
@@ -240,7 +239,7 @@ namespace boost {
       >
       struct BOOST_FUNCTION_GET_FUNCTION_INVOKER
       {
-        typedef typename mpl::if_c<(is_void<R>::value),
+        typedef typename conditional<(is_void<R>::value),
                             BOOST_FUNCTION_VOID_FUNCTION_INVOKER<
                             FunctionPtr,
                             R BOOST_FUNCTION_COMMA
@@ -261,7 +260,7 @@ namespace boost {
        >
       struct BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER
       {
-        typedef typename mpl::if_c<(is_void<R>::value),
+        typedef typename conditional<(is_void<R>::value),
                             BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER<
                             FunctionObj,
                             R BOOST_FUNCTION_COMMA
@@ -282,7 +281,7 @@ namespace boost {
        >
       struct BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER
       {
-        typedef typename mpl::if_c<(is_void<R>::value),
+        typedef typename conditional<(is_void<R>::value),
                             BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER<
                             FunctionObj,
                             R BOOST_FUNCTION_COMMA
@@ -305,7 +304,7 @@ namespace boost {
        >
       struct BOOST_FUNCTION_GET_MEMBER_INVOKER
       {
-        typedef typename mpl::if_c<(is_void<R>::value),
+        typedef typename conditional<(is_void<R>::value),
                             BOOST_FUNCTION_VOID_MEMBER_INVOKER<
                             MemberPtr,
                             R BOOST_FUNCTION_COMMA
@@ -350,9 +349,8 @@ namespace boost {
           typedef functor_manager<FunctionPtr> manager_type;
         };
 
-        template<typename FunctionPtr,
-                 typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
-                 typename Allocator>
+        template<typename FunctionPtr, typename Allocator,
+                 typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
         struct apply_a
         {
           typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER<
@@ -385,9 +383,8 @@ namespace boost {
           typedef functor_manager<MemberPtr> manager_type;
         };
 
-        template<typename MemberPtr,
-                 typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
-                 typename Allocator>
+        template<typename MemberPtr, typename Allocator,
+                 typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
         struct apply_a
         {
           typedef typename BOOST_FUNCTION_GET_MEMBER_INVOKER<
@@ -420,9 +417,8 @@ namespace boost {
           typedef functor_manager<FunctionObj> manager_type;
         };
 
-        template<typename FunctionObj,
-                 typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
-                 typename Allocator>
+        template<typename FunctionObj, typename Allocator,
+                 typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
         struct apply_a
         {
           typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
@@ -454,9 +450,8 @@ namespace boost {
           typedef reference_manager<typename RefWrapper::type> manager_type;
         };
 
-        template<typename RefWrapper,
-                 typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
-                 typename Allocator>
+        template<typename RefWrapper, typename Allocator,
+                 typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
         struct apply_a
         {
           typedef typename BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER<
@@ -567,27 +562,27 @@ namespace boost {
         // Assign to a function object using the small object optimization
         template<typename FunctionObj>
         void
-        assign_functor(FunctionObj f, function_buffer& functor, mpl::true_) const
+        assign_functor(FunctionObj f, function_buffer& functor, true_type) const
         {
           new (reinterpret_cast<void*>(functor.data)) FunctionObj(f);
         }
         template<typename FunctionObj,typename Allocator>
         void
-        assign_functor_a(FunctionObj f, function_buffer& functor, Allocator, mpl::true_) const
+        assign_functor_a(FunctionObj f, function_buffer& functor, Allocator, true_type) const
         {
-          assign_functor(f,functor,mpl::true_());
+          assign_functor(f,functor,true_type());
         }
 
         // Assign to a function object allocated on the heap.
         template<typename FunctionObj>
         void
-        assign_functor(FunctionObj f, function_buffer& functor, mpl::false_) const
+        assign_functor(FunctionObj f, function_buffer& functor, false_type) const
         {
           functor.members.obj_ptr = new FunctionObj(f);
         }
         template<typename FunctionObj,typename Allocator>
         void
-        assign_functor_a(FunctionObj f, function_buffer& functor, Allocator a, mpl::false_) const
+        assign_functor_a(FunctionObj f, function_buffer& functor, Allocator a, false_type) const
         {
           typedef functor_wrapper<FunctionObj,Allocator> functor_wrapper_type;
 #if defined(BOOST_NO_CXX11_ALLOCATOR)
@@ -615,7 +610,7 @@ namespace boost {
         {
           if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
             assign_functor(f, functor,
-                           mpl::bool_<(function_allows_small_object_optimization<FunctionObj>::value)>());
+                           integral_constant<bool, (function_allows_small_object_optimization<FunctionObj>::value)>());
             return true;
           } else {
             return false;
@@ -627,7 +622,7 @@ namespace boost {
         {
           if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
             assign_functor_a(f, functor, a,
-                           mpl::bool_<(function_allows_small_object_optimization<FunctionObj>::value)>());
+                           integral_constant<bool, (function_allows_small_object_optimization<FunctionObj>::value)>());
             return true;
           } else {
             return false;
@@ -708,14 +703,14 @@ namespace boost {
 
     typedef BOOST_FUNCTION_FUNCTION self_type;
 
-    BOOST_FUNCTION_FUNCTION() : function_base() { }
+    BOOST_DEFAULTED_FUNCTION(BOOST_FUNCTION_FUNCTION(), : function_base() {})
 
     // MSVC chokes if the following two constructors are collapsed into
     // one with a default parameter.
     template<typename Functor>
     BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f
 #ifndef BOOST_NO_SFINAE
-                            ,typename boost::enable_if_c<
+                            ,typename boost::enable_if_<
                              !(is_integral<Functor>::value),
                                         int>::type = 0
 #endif // BOOST_NO_SFINAE
@@ -727,7 +722,7 @@ namespace boost {
     template<typename Functor,typename Allocator>
     BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f, Allocator a
 #ifndef BOOST_NO_SFINAE
-                            ,typename boost::enable_if_c<
+                            ,typename boost::enable_if_<
                               !(is_integral<Functor>::value),
                                         int>::type = 0
 #endif // BOOST_NO_SFINAE
@@ -776,7 +771,7 @@ namespace boost {
     // construct.
     template<typename Functor>
 #ifndef BOOST_NO_SFINAE
-    typename boost::enable_if_c<
+    typename boost::enable_if_<
                   !(is_integral<Functor>::value),
                BOOST_FUNCTION_FUNCTION&>::type
 #else
@@ -904,7 +899,9 @@ namespace boost {
       if (!f.empty()) {
         this->vtable = f.vtable;
         if (this->has_trivial_copy_and_destroy())
-          this->functor = f.functor;
+          // Don't operate on storage directly since union type doesn't relax
+          // strict aliasing rules, despite of having member char type.
+          std::memcpy(this->functor.data, f.functor.data, sizeof(boost::detail::function::function_buffer));
         else
           get_vtable()->base.manager(f.functor, this->functor,
                                      boost::detail::function::clone_functor_tag);
@@ -953,9 +950,8 @@ namespace boost {
       typedef typename boost::detail::function::get_function_tag<Functor>::type tag;
       typedef boost::detail::function::BOOST_FUNCTION_GET_INVOKER<tag> get_invoker;
       typedef typename get_invoker::
-                         template apply_a<Functor, R BOOST_FUNCTION_COMMA
-                         BOOST_FUNCTION_TEMPLATE_ARGS,
-                         Allocator>
+                         template apply_a<Functor, Allocator, R BOOST_FUNCTION_COMMA
+                         BOOST_FUNCTION_TEMPLATE_ARGS>
         handler_type;
 
       typedef typename handler_type::invoker_type invoker_type;
@@ -992,7 +988,9 @@ namespace boost {
         if (!f.empty()) {
           this->vtable = f.vtable;
           if (this->has_trivial_copy_and_destroy())
-            this->functor = f.functor;
+            // Don't operate on storage directly since union type doesn't relax
+            // strict aliasing rules, despite of having member char type.
+            std::memcpy(this->functor.data, f.functor.data, sizeof(this->functor.data));
           else
             get_vtable()->base.manager(f.functor, this->functor,
                                      boost::detail::function::move_functor_tag);
@@ -1042,7 +1040,7 @@ template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
 #if BOOST_FUNCTION_NUM_ARGS == 0
 #define BOOST_FUNCTION_PARTIAL_SPEC R (void)
 #else
-#define BOOST_FUNCTION_PARTIAL_SPEC R (BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS,T))
+#define BOOST_FUNCTION_PARTIAL_SPEC R (BOOST_FUNCTION_TEMPLATE_ARGS)
 #endif
 
 template<typename R BOOST_FUNCTION_COMMA
@@ -1057,12 +1055,12 @@ class function<BOOST_FUNCTION_PARTIAL_SPEC>
 
 public:
 
-  function() : base_type() {}
+  BOOST_DEFAULTED_FUNCTION(function(), : base_type() {})
 
   template<typename Functor>
   function(Functor f
 #ifndef BOOST_NO_SFINAE
-           ,typename boost::enable_if_c<
+           ,typename boost::enable_if_<
                           !(is_integral<Functor>::value),
                        int>::type = 0
 #endif
@@ -1073,7 +1071,7 @@ public:
   template<typename Functor,typename Allocator>
   function(Functor f, Allocator a
 #ifndef BOOST_NO_SFINAE
-           ,typename boost::enable_if_c<
+           ,typename boost::enable_if_<
                            !(is_integral<Functor>::value),
                        int>::type = 0
 #endif
@@ -1112,7 +1110,7 @@ public:
 
   template<typename Functor>
 #ifndef BOOST_NO_SFINAE
-  typename boost::enable_if_c<
+  typename boost::enable_if_<
                          !(is_integral<Functor>::value),
                       self_type&>::type
 #else