$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r66290 - in sandbox/function/boost/function: . detail
From: dsaritz_at_[hidden]
Date: 2010-10-30 19:08:45
Author: psiha
Date: 2010-10-30 19:08:44 EDT (Sat, 30 Oct 2010)
New Revision: 66290
URL: http://svn.boost.org/trac/boost/changeset/66290
Log:
Added BF_HAS_NOTHROW information to platform_specifics.hpp.
Further tweaked the code in safe_bool.hpp.
Forced-inlined invoker helper wrappers (only slightly improves but does not solve the problems with functions taking objects with non-trivial destructors as parameters).
Minor stylistic changes.
Text files modified: 
   sandbox/function/boost/function/detail/platform_specifics.hpp |     4                                         
   sandbox/function/boost/function/detail/safe_bool.hpp          |   173 +++++++++++++++++++++++---------------- 
   sandbox/function/boost/function/function_base.hpp             |     8                                         
   sandbox/function/boost/function/function_template.hpp         |    11 +-                                      
   4 files changed, 115 insertions(+), 81 deletions(-)
Modified: sandbox/function/boost/function/detail/platform_specifics.hpp
==============================================================================
--- sandbox/function/boost/function/detail/platform_specifics.hpp	(original)
+++ sandbox/function/boost/function/detail/platform_specifics.hpp	2010-10-30 19:08:44 EDT (Sat, 30 Oct 2010)
@@ -37,6 +37,8 @@
     #define BF_NOTHROWNOALIAS           __declspec( nothrow noalias          )
     #define BF_NOTHROWNORESTRICTNOALIAS __declspec( nothrow restrict noalias )
 
+    #define BF_HAS_NOTHROW
+
     #define BF_SELECTANY __declspec( selectany )
 
     #define BF_CDECL    __cdecl
@@ -67,6 +69,8 @@
     #define BF_NOTHROWNOALIAS           NOTHROW
     #define BF_NOTHROWNORESTRICTNOALIAS NOTHROW
 
+    #define BF_HAS_NOTHROW
+
     #ifdef _WIN32
         #define BF_SELECTANY __declspec( selectany )
     #else
Modified: sandbox/function/boost/function/detail/safe_bool.hpp
==============================================================================
--- sandbox/function/boost/function/detail/safe_bool.hpp	(original)
+++ sandbox/function/boost/function/detail/safe_bool.hpp	2010-10-30 19:08:44 EDT (Sat, 30 Oct 2010)
@@ -27,8 +27,9 @@
 {
 //------------------------------------------------------------------------------
 
-// Taken from funtion/function_template.hpp
-#if (defined __SUNPRO_CC) && (__SUNPRO_CC <= 0x530) && !(defined BOOST_NO_COMPILER_CONFIG)
+#if BOOST_WORKAROUND( BOOST_MSVC, >= 1600 )
+    #define BOOST_COMPILER_RECOGNIZES_SAFE_BOOL_IDIOM
+#elif (defined __SUNPRO_CC) && (__SUNPRO_CC <= 0x530) && !(defined BOOST_NO_COMPILER_CONFIG)
     // Sun C++ 5.3 can't handle the safe_bool idiom, so don't use it
     #define BOOST_NO_SAFE_BOOL
 #endif
@@ -41,81 +42,103 @@
     struct unspecified_bool_type_helper
     {
         void member_function() {};
-        int member_data_;
+        int  member_data_;
     };
 
     typedef void (unspecified_bool_type_helper::*unspecified_bool_type_function) ();
     typedef int   unspecified_bool_type_helper::*unspecified_bool_type_data        ;
 
-    union fast_safe_bool
-    {
-        unsigned long                  plain_pointer_placeholder;
-        unspecified_bool_type_function pointer_to_member        ;
-    };
-
-    //   It is assumed that if the compiler is able to fit a plain, single
-    // inheritance member function pointer into sizeof( void * ) that its null
-    // binary representation is identical to a plain null void pointer (all bits
-    // zeroed). Without a way to check this at compile time this asserted at
-    // runtime.
-    //   The above need not hold for data member pointers (e.g. MSVC++ uses -1
-    // for null-data member pointers).
-    typedef mpl::bool_
-        <
-            ( sizeof( fast_safe_bool ) <= sizeof( unsigned long ) )
-        > can_use_fast_bool_hack;
-
-protected:
-    typedef typename mpl::if_
-        <
-            can_use_fast_bool_hack,
-            unspecified_bool_type_function,
-            unspecified_bool_type_data
-        >::type unspecified_bool_type;
-
-private:
-    static
-    unspecified_bool_type_function
-    make_safe_bool_standard_worker( bool const bool_value, unspecified_bool_type_function const null_value )
-    {
-        return bool_value ? &unspecified_bool_type_helper::member_function : null_value;
-    }
-    static
-    unspecified_bool_type_data
-    make_safe_bool_standard_worker( bool const bool_value, unspecified_bool_type_data     const null_value )
-    {
-        return bool_value ? &unspecified_bool_type_helper::member_data_    : null_value;
-    }
-
-    static
-    unspecified_bool_type make_safe_bool_worker( bool const value, mpl::false_ /*use standard version*/ )
-    {
-        return make_safe_bool_standard_worker( value, unspecified_bool_type( 0 ) );
-    }
-
-    static
-    unspecified_bool_type make_safe_bool_worker( bool const value, mpl::true_ /*use fast-hack version*/ )
-    {
-        fast_safe_bool const fastSafeBool = { value };
-        BOOST_ASSERT
-        (
-            ( !!fastSafeBool.pointer_to_member == !!value ) &&
-            "The void-pointer-sized member pointer null binary"
-            "representation assumption does not hold for this"
-            "compiler/platform."
-        );
-        return fastSafeBool.pointer_to_member;
-    }
-
-public:
-    typedef unspecified_bool_type type;
-
-    template <typename implicit_bool>
-    static type make( implicit_bool const value )
-    {
-        return make_safe_bool_worker( !!value, can_use_fast_bool_hack() );
-    }
-
+    #ifndef BOOST_COMPILER_RECOGNIZES_SAFE_BOOL_IDIOM
+        union fast_safe_bool
+        {
+            unsigned long                  plain_pointer_placeholder;
+            unspecified_bool_type_function pointer_to_member        ;
+        };
+
+        //   It is assumed that if the compiler is able to fit a plain, single
+        // inheritance member function pointer into sizeof( void * ) that its null
+        // binary representation is identical to a plain null void pointer (all bits
+        // zeroed). Without a way to check this at compile time this is asserted at
+        // runtime.
+        //   The above need not hold for data member pointers (e.g. MSVC++ uses -1
+        // for null-data member pointers).
+        typedef mpl::bool_
+            <
+                ( sizeof( fast_safe_bool ) <= sizeof( unsigned long ) )
+            > can_use_fast_bool_hack;
+
+    protected:
+        typedef typename mpl::if_
+            <
+                can_use_fast_bool_hack,
+                unspecified_bool_type_function,
+                unspecified_bool_type_data
+            >::type unspecified_bool_type;
+
+    private:
+        static
+        unspecified_bool_type_function
+        make_safe_bool_standard_worker( bool const bool_value, unspecified_bool_type_function const null_value )
+        {
+            return bool_value ? &unspecified_bool_type_helper::member_function : null_value;
+        }
+        static
+        unspecified_bool_type_data
+        make_safe_bool_standard_worker( bool const bool_value, unspecified_bool_type_data     const null_value )
+        {
+            return bool_value ? &unspecified_bool_type_helper::member_data_    : null_value;
+        }
+
+        static
+        unspecified_bool_type make_safe_bool_worker( bool const value, mpl::false_ /*use standard version*/ )
+        {
+            return make_safe_bool_standard_worker( value, unspecified_bool_type( 0 ) );
+        }
+
+        static
+        unspecified_bool_type make_safe_bool_worker( bool const value, mpl::true_ /*use fast-hack version*/ )
+        {
+            fast_safe_bool const & fastSafeBool( *static_cast<fast_safe_bool const *>( static_cast<void const *>( &value ) ) );
+            BOOST_ASSERT
+            (
+                ( !!fastSafeBool.pointer_to_member == !!value ) &&
+                "The void-pointer-sized member pointer null binary"
+                "representation assumption does not hold for this"
+                "compiler/platform."
+            );
+            return fastSafeBool.pointer_to_member;
+        }
+
+    public:
+        typedef unspecified_bool_type type;
+
+        template <typename implicit_bool>
+        static type make( implicit_bool const value )
+        {
+            return make_safe_bool_worker( !!value, can_use_fast_bool_hack() );
+        }
+
+        template <>
+        static type make<bool>( bool const value )
+        {
+            return make_safe_bool_worker( value, can_use_fast_bool_hack() );
+        }
+    #else // BOOST_COMPILER_RECOGNIZES_SAFE_BOOL_IDIOM
+    public:
+        typedef unspecified_bool_type_data type;
+
+        template <typename implicit_bool>
+        static type make( implicit_bool const value )
+        {
+            return make_safe_bool_worker( !!value );
+        }
+
+        template <>
+        static type make<bool>( bool const value )
+        {
+            return value ? &unspecified_bool_type_helper::member_data_ : 0;
+        }
+    #endif // BOOST_COMPILER_RECOGNIZES_SAFE_BOOL_IDIOM
 #else // BOOST_NO_SAFE_BOOL
 public:
     typedef bool unspecified_bool_type;
@@ -126,6 +149,12 @@
     {
         return !!value;
     }
+
+    template <>
+    static type make<bool>( bool const value )
+    {
+        return value;
+    }
 #endif // BOOST_NO_SAFE_BOOL
 }; // namespace detail
 
Modified: sandbox/function/boost/function/function_base.hpp
==============================================================================
--- sandbox/function/boost/function/function_base.hpp	(original)
+++ sandbox/function/boost/function/function_base.hpp	2010-10-30 19:08:44 EDT (Sat, 30 Oct 2010)
@@ -232,10 +232,10 @@
           template <typename Functor>
           typed_functor( Functor & functor )
               :
-              pFunctor          ( boost::addressof( functor )  ),
-              type_id           ( BOOST_SP_TYPEID( Functor )   ),
-              const_qualified   ( is_const   <Functor>::value  ),
-              volatile_qualified( is_volatile<Functor>::value  )
+              pFunctor          ( boost::addressof( functor ) ),
+              type_id           ( BOOST_SP_TYPEID( Functor )  ),
+              const_qualified   ( is_const   <Functor>::value ),
+              volatile_qualified( is_volatile<Functor>::value )
           {
               BOOST_ASSERT( pFunctor );
           }
Modified: sandbox/function/boost/function/function_template.hpp
==============================================================================
--- sandbox/function/boost/function/function_template.hpp	(original)
+++ sandbox/function/boost/function/function_template.hpp	2010-10-30 19:08:44 EDT (Sat, 30 Oct 2010)
@@ -477,30 +477,31 @@
                 #endif
     }
 
-
-    #ifdef BOOST_MSVC
-        __declspec( nothrow )
+    #ifdef BF_HAS_NOTHROW
+        BF_NOTHROW
     #endif
     result_type invoke( BOOST_FUNCTION_PARMS BOOST_FUNCTION_COMMA mpl::true_ /*no throw invoker*/ ) const
-    #ifndef BOOST_MSVC
+    #ifndef BF_HAS_NOTHROW
         throw()
     #endif
     {
         return do_invoke( BOOST_FUNCTION_ARGS BOOST_FUNCTION_COMMA detail::function::thiscall_optimization_available() );
     }
 
+    BF_FORCEINLINE
     result_type invoke( BOOST_FUNCTION_PARMS BOOST_FUNCTION_COMMA mpl::false_ /*throwable invoker*/ ) const
     {
         return do_invoke( BOOST_FUNCTION_ARGS BOOST_FUNCTION_COMMA detail::function::thiscall_optimization_available() );
     }
 
-
+    BF_FORCEINLINE
     result_type do_invoke( BOOST_FUNCTION_PARMS BOOST_FUNCTION_COMMA mpl::true_ /*this call*/ ) const
     {
         typedef result_type (detail::function::function_buffer::* invoker_type)(BOOST_FUNCTION_TEMPLATE_ARGS);
         return (functor_.*(get_vtable(). BOOST_NESTED_TEMPLATE invoker<invoker_type>()))(BOOST_FUNCTION_ARGS);
     }
 
+    BF_FORCEINLINE
     result_type do_invoke( BOOST_FUNCTION_PARMS BOOST_FUNCTION_COMMA mpl::false_ /*free call*/ ) const
     {
         typedef result_type (* invoker_type)( BOOST_FUNCTION_TEMPLATE_ARGS BOOST_FUNCTION_COMMA detail::function::function_buffer & );