diff --git a/include/boost/function.hpp b/include/boost/function.hpp index 01e3fb3..ac2b5d9 100644 --- a/include/boost/function.hpp +++ b/include/boost/function.hpp @@ -20,6 +20,7 @@ #define BOOST_FUNCTION_HPP #include +#include #include #include #include @@ -35,6 +36,217 @@ namespace boost { namespace detail { namespace function { + template + struct function_traits + { + BOOST_STATIC_CONSTANT(int, arity = 0); + typedef void result_type; + typedef void arg1_type; + typedef void arg2_type; + typedef void arg3_type; + typedef void arg4_type; + typedef void arg5_type; + typedef void arg6_type; + typedef void arg7_type; + typedef void arg8_type; + typedef void arg9_type; + typedef void arg10_type; + }; + + template + struct function_traits + { + BOOST_STATIC_CONSTANT(int, arity = 0); + typedef R result_type; + typedef unusable arg1_type; + typedef unusable arg2_type; + typedef unusable arg3_type; + typedef unusable arg4_type; + typedef unusable arg5_type; + typedef unusable arg6_type; + typedef unusable arg7_type; + typedef unusable arg8_type; + typedef unusable arg9_type; + typedef unusable arg10_type; + }; + + template + struct function_traits + { + BOOST_STATIC_CONSTANT(int, arity = 1); + typedef R result_type; + typedef T1 arg1_type; + typedef unusable arg2_type; + typedef unusable arg3_type; + typedef unusable arg4_type; + typedef unusable arg5_type; + typedef unusable arg6_type; + typedef unusable arg7_type; + typedef unusable arg8_type; + typedef unusable arg9_type; + typedef unusable arg10_type; + }; + + template + struct function_traits + { + BOOST_STATIC_CONSTANT(int, arity = 2); + typedef R result_type; + typedef T1 arg1_type; + typedef T2 arg2_type; + typedef unusable arg3_type; + typedef unusable arg4_type; + typedef unusable arg5_type; + typedef unusable arg6_type; + typedef unusable arg7_type; + typedef unusable arg8_type; + typedef unusable arg9_type; + typedef unusable arg10_type; + }; + + template + struct function_traits + { + BOOST_STATIC_CONSTANT(int, arity = 3); + typedef R result_type; + typedef T1 arg1_type; + typedef T2 arg2_type; + typedef T3 arg3_type; + typedef unusable arg4_type; + typedef unusable arg5_type; + typedef unusable arg6_type; + typedef unusable arg7_type; + typedef unusable arg8_type; + typedef unusable arg9_type; + typedef unusable arg10_type; + }; + + template + struct function_traits + { + BOOST_STATIC_CONSTANT(int, arity = 4); + typedef R result_type; + typedef T1 arg1_type; + typedef T2 arg2_type; + typedef T3 arg3_type; + typedef T4 arg4_type; + typedef unusable arg5_type; + typedef unusable arg6_type; + typedef unusable arg7_type; + typedef unusable arg8_type; + typedef unusable arg9_type; + typedef unusable arg10_type; + }; + + template + struct function_traits + { + BOOST_STATIC_CONSTANT(int, arity = 5); + typedef R result_type; + typedef T1 arg1_type; + typedef T2 arg2_type; + typedef T3 arg3_type; + typedef T4 arg4_type; + typedef T5 arg5_type; + typedef unusable arg6_type; + typedef unusable arg7_type; + typedef unusable arg8_type; + typedef unusable arg9_type; + typedef unusable arg10_type; + }; + + template + struct function_traits + { + BOOST_STATIC_CONSTANT(int, arity = 6); + typedef R result_type; + typedef T1 arg1_type; + typedef T2 arg2_type; + typedef T3 arg3_type; + typedef T4 arg4_type; + typedef T5 arg5_type; + typedef T6 arg6_type; + typedef unusable arg7_type; + typedef unusable arg8_type; + typedef unusable arg9_type; + typedef unusable arg10_type; + }; + + template + struct function_traits + { + BOOST_STATIC_CONSTANT(int, arity = 7); + typedef R result_type; + typedef T1 arg1_type; + typedef T2 arg2_type; + typedef T3 arg3_type; + typedef T4 arg4_type; + typedef T5 arg5_type; + typedef T6 arg6_type; + typedef T7 arg7_type; + typedef unusable arg8_type; + typedef unusable arg9_type; + typedef unusable arg10_type; + }; + + template + struct function_traits + { + BOOST_STATIC_CONSTANT(int, arity = 8); + typedef R result_type; + typedef T1 arg1_type; + typedef T2 arg2_type; + typedef T3 arg3_type; + typedef T4 arg4_type; + typedef T5 arg5_type; + typedef T6 arg6_type; + typedef T7 arg7_type; + typedef T8 arg8_type; + typedef unusable arg9_type; + typedef unusable arg10_type; + }; + + template + struct function_traits + { + BOOST_STATIC_CONSTANT(int, arity = 9); + typedef R result_type; + typedef T1 arg1_type; + typedef T2 arg2_type; + typedef T3 arg3_type; + typedef T4 arg4_type; + typedef T5 arg5_type; + typedef T6 arg6_type; + typedef T7 arg7_type; + typedef T8 arg8_type; + typedef T9 arg9_type; + typedef unusable arg10_type; + }; + + template + struct function_traits + { + BOOST_STATIC_CONSTANT(int, arity = 10); + typedef R result_type; + typedef T1 arg1_type; + typedef T2 arg2_type; + typedef T3 arg3_type; + typedef T4 arg4_type; + typedef T5 arg5_type; + typedef T6 arg6_type; + typedef T7 arg7_type; + typedef T8 arg8_type; + typedef T9 arg9_type; + typedef T10 arg10_type; + }; + // Choose the appropriate underlying implementation template struct real_get_function_impl {}; @@ -320,23 +532,73 @@ namespace boost { }; template< - typename R, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename Policy = empty_function_policy, - typename Mixin = empty_function_mixin, - typename Allocator = std::allocator + typename InR, + typename InT1, + typename InT2, + typename InT3, + typename InT4, + typename InT5, + typename InT6, + typename InT7, + typename InT8, + typename InT9, + typename InT10, + typename InPolicy = empty_function_policy, + typename InMixin = empty_function_mixin, + typename InAllocator = std::allocator > - struct get_function_impl + class get_function_impl { + BOOST_STATIC_CONSTANT(bool, encoded_param = is_function::value); + typedef function_traits traits; + public: + + typedef typename ct_if::type R; + typedef typename ct_if::type T1; + typedef typename ct_if::type T2; + typedef typename ct_if::type T3; + typedef typename ct_if::type T4; + typedef typename ct_if::type T5; + typedef typename ct_if::type T6; + typedef typename ct_if::type T7; + typedef typename ct_if::type T8; + typedef typename ct_if::type T9; + typedef typename ct_if::type T10; + typedef typename ct_if<(encoded_param && + !is_same::value), + InT1, + InPolicy>::type Policy; + typedef typename ct_if<(encoded_param && + !is_same::value), + InT2, + InMixin>::type Mixin; + typedef typename ct_if<(encoded_param && + !is_same::value), + InT3, + InAllocator>::type Allocator; + typedef typename real_get_function_impl< (count_used_args::value) >::template params + typename InR, + typename InT1, + typename InT2, + typename InT3, + typename InT4, + typename InT5, + typename InT6, + typename InT7, + typename InT8, + typename InT9, + typename InT10, + typename InMyPolicy = empty_function_policy, + typename InMyMixin = empty_function_mixin, + typename InMyAllocator = std::allocator > - struct function_traits_builder + class function_traits_builder { - typedef typename get_function_impl::type - type; + typedef get_function_impl + impl; + typedef typename impl::R MyR; + typedef typename impl::T1 MyT1; + typedef typename impl::T2 MyT2; + typedef typename impl::T3 MyT3; + typedef typename impl::T4 MyT4; + typedef typename impl::T5 MyT5; + typedef typename impl::T6 MyT6; + typedef typename impl::T7 MyT7; + typedef typename impl::T8 MyT8; + typedef typename impl::T9 MyT9; + typedef typename impl::T10 MyT10; + typedef typename impl::Policy MyPolicy; + typedef typename impl::Mixin MyMixin; + typedef typename impl::Allocator MyAllocator; + + public: + typedef typename impl::type type; typedef MyPolicy policy_type; typedef MyMixin mixin_type; typedef MyAllocator allocator_type; @@ -374,28 +653,28 @@ namespace boost { #ifndef BOOST_NO_DEPENDENT_NESTED_DERIVATIONS template struct policy : - public function_traits_builder {}; + public function_traits_builder {}; template struct mixin : - public function_traits_builder {}; + public function_traits_builder {}; template struct allocator : - public function_traits_builder {}; + public function_traits_builder {}; #else template struct policy { - typedef typename function_traits_builder::type type; }; @@ -403,8 +682,9 @@ namespace boost { template struct mixin { - typedef typename function_traits_builder::type type; }; @@ -412,9 +692,10 @@ namespace boost { template struct allocator { - typedef typename function_traits_builder::type + typedef typename function_traits_builder::type type; }; #endif