Changeset 63943


Ignore:
Timestamp:
Jul 13, 2010, 8:24:53 AM (8 years ago)
Author:
cppljevans
Message:

added functor_bad_args as alternative to using can_be_called

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/apply_unpack.hpp

    r63404 r63943  
    1212#include <boost/mpl/package_range_c.hpp>
    1313#include <boost/type_traits/remove_cv.hpp>
    14 #include <boost/function_types/can_be_called.hpp>
    1514#include <exception>
     15#ifndef APPLY_UNPACK_USER_CHECKED_ARGS
     16  #include <boost/function_types/can_be_called.hpp>
     17#endif 
    1618
    1719namespace boost
     
    3032  }; 
    3133 
    32   template <typename Functor, typename... Args>
    33     typename functor_result_type<Functor>::type
    34   apply_ftor_callable_args( mpl::bool_<true>, Functor& ftor
    35     , Args const&... args)
    36   {
    37       return ftor(args...);
    38   };
    39  
    4034  template<typename FunctorArgs>
    4135  struct bad_functor_args
     
    5044  };
    5145     
     46#ifdef APPLY_UNPACK_USER_CHECKED_ARGS
     47    template
     48    < typename Functor
     49    , typename ResultType
     50    >
     51  struct functor_bad_args
     52  {
     53      typedef ResultType result_type;
     54     
     55      template<typename... Args>
     56      result_type operator()(Args&... args)FUNCTOR_CONSTANCY throw()
     57      {
     58          throw bad_functor_args<Functor(Args&...)>();
     59          return result_type();
     60      }
     61  };
     62
     63#else
     64  template <typename Functor, typename... Args>
     65    typename functor_result_type<Functor>::type
     66  apply_ftor_callable_args( mpl::bool_<true>, Functor& ftor
     67    , Args const&... args)
     68  {
     69      return ftor(args...);
     70  };
     71 
    5272  template <typename Functor, typename... Args>
    5373    typename functor_result_type<Functor>::type
     
    7898        , ftor, args...);
    7999  };
     100#endif 
    80101 
    81102  template <typename Indices>
     
    90111      {
    91112          return
    92           #ifndef APPLY_UNPACK_DEMO_UNCHECK_ARGS
     113          #ifndef APPLY_UNPACK_USER_CHECKED_ARGS
    93114            apply_ftor_check_args( a_functor
    94115              , a_args.template project<Indices>()...);
Note: See TracChangeset for help on using the changeset viewer.