Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63943 - sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch
From: cppljevans_at_[hidden]
Date: 2010-07-13 04:24:55


Author: cppljevans
Date: 2010-07-13 04:24:53 EDT (Tue, 13 Jul 2010)
New Revision: 63943
URL: http://svn.boost.org/trac/boost/changeset/63943

Log:
added functor_bad_args as alternative to using can_be_called
Text files modified:
   sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/apply_unpack.hpp | 41 ++++++++++++++++++++++++++++++---------
   1 files changed, 31 insertions(+), 10 deletions(-)

Modified: sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/apply_unpack.hpp
==============================================================================
--- sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/apply_unpack.hpp (original)
+++ sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/apply_unpack.hpp 2010-07-13 04:24:53 EDT (Tue, 13 Jul 2010)
@@ -11,8 +11,10 @@
 
 #include <boost/mpl/package_range_c.hpp>
 #include <boost/type_traits/remove_cv.hpp>
-#include <boost/function_types/can_be_called.hpp>
 #include <exception>
+#ifndef APPLY_UNPACK_USER_CHECKED_ARGS
+ #include <boost/function_types/can_be_called.hpp>
+#endif
 
 namespace boost
 {
@@ -29,14 +31,6 @@
       typedef typename functor_type::result_type type;
   };
   
- template <typename Functor, typename... Args>
- typename functor_result_type<Functor>::type
- apply_ftor_callable_args( mpl::bool_<true>, Functor& ftor
- , Args const&... args)
- {
- return ftor(args...);
- };
-
   template<typename FunctorArgs>
   struct bad_functor_args
     : public std::exception
@@ -49,6 +43,32 @@
       }
   };
       
+#ifdef APPLY_UNPACK_USER_CHECKED_ARGS
+ template
+ < typename Functor
+ , typename ResultType
+ >
+ struct functor_bad_args
+ {
+ typedef ResultType result_type;
+
+ template<typename... Args>
+ result_type operator()(Args&... args)FUNCTOR_CONSTANCY throw()
+ {
+ throw bad_functor_args<Functor(Args&...)>();
+ return result_type();
+ }
+ };
+
+#else
+ template <typename Functor, typename... Args>
+ typename functor_result_type<Functor>::type
+ apply_ftor_callable_args( mpl::bool_<true>, Functor& ftor
+ , Args const&... args)
+ {
+ return ftor(args...);
+ };
+
   template <typename Functor, typename... Args>
     typename functor_result_type<Functor>::type
   apply_ftor_callable_args( mpl::bool_<false>, Functor& ftor
@@ -77,6 +97,7 @@
       return apply_ftor_callable_args( is_ftor_args_callable()
         , ftor, args...);
   };
+#endif
   
   template <typename Indices>
   struct apply_unpack;
@@ -89,7 +110,7 @@
       operator()( Functor& a_functor, ArgsPacked const& a_args)
       {
           return
- #ifndef APPLY_UNPACK_DEMO_UNCHECK_ARGS
+ #ifndef APPLY_UNPACK_USER_CHECKED_ARGS
             apply_ftor_check_args( a_functor
               , a_args.template project<Indices>()...);
           #else


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