Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77891 - in trunk: boost/functional/overloaded_function/detail libs/functional/overloaded_function/test
From: lorcaminiti_at_[hidden]
Date: 2012-04-10 15:17:42


Author: lcaminiti
Date: 2012-04-10 15:17:41 EDT (Tue, 10 Apr 2012)
New Revision: 77891
URL: http://svn.boost.org/trac/boost/changeset/77891

Log:
Added a specialization to deduced F from boost::function<F> removing the need to register boost::function for type-of emulation (because it required to register boost::functionN instead of boost::function and that was confusing).
Text files modified:
   trunk/boost/functional/overloaded_function/detail/function_type.hpp | 12 +++++++++++-
   trunk/libs/functional/overloaded_function/test/identity.hpp | 7 -------
   trunk/libs/functional/overloaded_function/test/make_decl.cpp | 2 ++
   3 files changed, 13 insertions(+), 8 deletions(-)

Modified: trunk/boost/functional/overloaded_function/detail/function_type.hpp
==============================================================================
--- trunk/boost/functional/overloaded_function/detail/function_type.hpp (original)
+++ trunk/boost/functional/overloaded_function/detail/function_type.hpp 2012-04-10 15:17:41 EDT (Tue, 10 Apr 2012)
@@ -16,6 +16,7 @@
 #include <boost/function_types/result_type.hpp>
 #include <boost/type_traits/remove_pointer.hpp>
 #include <boost/type_traits/remove_reference.hpp>
+#include <boost/function.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/mpl/identity.hpp>
 #include <boost/mpl/pop_front.hpp>
@@ -46,6 +47,15 @@
     type;
 };
 
+// NOTE: When using boost::function in Boost.Typeof emulation mode, the user
+// has to register boost::functionN instead of boost::function in oder to
+// do TYPEOF(F::operator()). That is confusing, so boost::function is handled
+// separately so it does not require any Boost.Typeof registration at all.
+template<typename F>
+struct functor_type< boost::function<F> > {
+ typedef F type;
+};
+
 // Requires: F is a function type, pointer, reference, or monomorphic functor.
 // Returns: F's function type `result_type (arg1_type, arg2_type, ...)`.
 template<typename F>
@@ -61,7 +71,7 @@
                 typename boost::mpl::if_<boost::function_types::
                         is_function_reference<F>,
                     boost::remove_reference<F>
- , // Requires, it's a functor.
+ , // Else, requires that F is a functor.
                     functor_type<F>
>::type
>::type

Modified: trunk/libs/functional/overloaded_function/test/identity.hpp
==============================================================================
--- trunk/libs/functional/overloaded_function/test/identity.hpp (original)
+++ trunk/libs/functional/overloaded_function/test/identity.hpp 2012-04-10 15:17:41 EDT (Tue, 10 Apr 2012)
@@ -19,13 +19,6 @@
 
 double identity_d_impl(double x) { return x; }
 boost::function<double (double)> identity_d = identity_d_impl; // Functor.
-
-// For type-of emulation on compilers without native type-of.
-#include <boost/typeof/typeof.hpp>
-#include <boost/typeof/std/string.hpp>
-#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function, 1)
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function1, 2) // Also `functionN`.
 //]
 
 #endif // #include guard

Modified: trunk/libs/functional/overloaded_function/test/make_decl.cpp
==============================================================================
--- trunk/libs/functional/overloaded_function/test/make_decl.cpp (original)
+++ trunk/libs/functional/overloaded_function/test/make_decl.cpp 2012-04-10 15:17:41 EDT (Tue, 10 Apr 2012)
@@ -7,6 +7,8 @@
 
 #include "identity.hpp"
 #include <boost/functional/overloaded_function.hpp>
+#include <boost/typeof/typeof.hpp> // For `BOOST_AUTO`.
+#include <boost/typeof/std/string.hpp> // No need to register `boost::function`.
 #include <boost/detail/lightweight_test.hpp>
 
 int main() {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk