|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63404 - sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch
From: cppljevans_at_[hidden]
Date: 2010-06-27 23:29:49
Author: cppljevans
Date: 2010-06-27 23:29:45 EDT (Sun, 27 Jun 2010)
New Revision: 63404
URL: http://svn.boost.org/trac/boost/changeset/63404
Log:
convert to 'more common' coding style
Text files modified:
sandbox/variadic_templates/boost/composite_storage/pack/multiple_dispatch/apply_unpack.hpp | 197 +++++++++++++++------------------------
1 files changed, 78 insertions(+), 119 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-06-27 23:29:45 EDT (Sun, 27 Jun 2010)
@@ -22,126 +22,85 @@
{
namespace multiple_dispatch
{
- template
- < typename Functor
- >
-struct functor_result_type
-{
- typedef
- typename remove_cv<Functor>::type
- functor_type
- ;
- 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 Functor>
+ struct functor_result_type
+ {
+ typedef typename remove_cv<Functor>::type functor_type;
+ 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
-{
- virtual const char * what() const throw()
- {
- return "boost::composite_storage::pack::multiple_dispatch::bad_functor_args: "
- "Functor not defined for Args.";
- }
-};
- template
- < typename Functor
- , typename... Args
- >
- typename functor_result_type<Functor>::type
-apply_ftor_callable_args
- ( mpl::bool_<false>
- , Functor& ftor
- , Args const&... args
- )
-{
- throw bad_functor_args<Functor(Args const&...)>();
- return typename functor_result_type<Functor>::type();
-};
-
- template
- < typename Functor
- , typename... Args
- >
- typename functor_result_type<Functor>::type
-apply_ftor_check_args
- ( Functor& ftor
- , Args const&... args
- )
- /**@brief
- * If ftor is callable with args..., does so.
- * If not, then issues error message and returns
- * default value.
- */
-{
- typedef
- typename function_types::can_be_called<Functor(Args const&...)>::type
- is_ftor_args_callable;
- return apply_ftor_callable_args
- ( is_ftor_args_callable()
- , ftor
- , args...
- );
-};
-
- template
- < typename Indices
- >
-struct apply_unpack
-;
- template
- < unsigned... Indices
- //0...Arity-1, where Arity is arity of Functor arg to this->operator()(_,_).
- >
-struct apply_unpack
- < mpl::package_c<unsigned, Indices...>
- >
-{
- template
- < typename Functor
- , typename ArgsPacked
- >
- typename functor_result_type<Functor>::type
- operator()
- ( Functor& a_functor
- , ArgsPacked const& a_args
- )
- {
- return
- #ifndef APPLY_UNPACK_DEMO_UNCHECK_ARGS
- apply_ftor_check_args
- ( a_functor
- , a_args.template project<Indices>()...
- )
- #else
- //This branch of #if...#endif can cause compile errors
- //about "no match for for call to 'SomeFunCall'"
- //where SomdFunCall is some function name and
- //parameter type list.
- a_functor
- ( a_args.template project<Indices>()...
- )
- #endif
- ;
- }
-};
+ struct bad_functor_args
+ : public std::exception
+ {
+ virtual const char * what() const throw()
+ {
+ return "boost::composite_storage::pack::multiple_dispatch"
+ "::bad_functor_args:\n"
+ " Functor not defined for Args.";
+ }
+ };
+
+ template <typename Functor, typename... Args>
+ typename functor_result_type<Functor>::type
+ apply_ftor_callable_args( mpl::bool_<false>, Functor& ftor
+ , Args const&... args
+ )
+ {
+ throw bad_functor_args<Functor(Args const&...)>();
+ return typename functor_result_type<Functor>::type();
+ };
+
+ template <typename Functor, typename... Args>
+ typename functor_result_type<Functor>::type
+ apply_ftor_check_args
+ ( Functor& ftor
+ , Args const&... args
+ )
+ /**@brief
+ * If ftor is callable with args..., does so.
+ * If not, then issues error message and returns
+ * default value.
+ */
+ {
+ typedef typename function_types
+ ::can_be_called<Functor(Args const&...)>::type
+ is_ftor_args_callable;
+ return apply_ftor_callable_args( is_ftor_args_callable()
+ , ftor, args...);
+ };
+
+ template <typename Indices>
+ struct apply_unpack;
+
+ template <unsigned... Indices>
+ struct apply_unpack< mpl::package_c<unsigned, Indices...> >
+ {
+ template <typename Functor, typename ArgsPacked>
+ typename functor_result_type<Functor>::type
+ operator()( Functor& a_functor, ArgsPacked const& a_args)
+ {
+ return
+ #ifndef APPLY_UNPACK_DEMO_UNCHECK_ARGS
+ apply_ftor_check_args( a_functor
+ , a_args.template project<Indices>()...);
+ #else
+ //This branch of #if...#endif can cause compile errors
+ //about "no match for for call to 'SomeFunCall'"
+ //where SomdFunCall is some function name and
+ //parameter type list.
+ a_functor( a_args.template project<Indices>()...);
+ #endif
+ }
+ };
}//exit multiple_dispatch namespace
}//exit pack namespace
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