From a39d5404d67ca2f23055f7494ce8806da4b84420 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 5 Jun 2024 16:33:38 +0300 Subject: [PATCH 1/2] Add result_arg_n_types_test. Refs #51. --- test/Jamfile.v2 | 1 + test/result_arg_n_types_test.cpp | 146 +++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 test/result_arg_n_types_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 717a163..13f411e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -46,6 +46,7 @@ run rvalues_test.cpp ; compile function_typeof_test.cpp : 03:no 98:no 0x:no ; run result_arg_types_test.cpp ; +run result_arg_n_types_test.cpp ; lib throw_bad_function_call : throw_bad_function_call.cpp : shared:THROW_BAD_FUNCTION_CALL_DYN_LINK=1 ; diff --git a/test/result_arg_n_types_test.cpp b/test/result_arg_n_types_test.cpp new file mode 100644 index 0000000..c7e5780 --- /dev/null +++ b/test/result_arg_n_types_test.cpp @@ -0,0 +1,146 @@ +// Copyright 2024 Peter Dimov +// Use, modification and distribution is subject to +// the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include + +struct R {}; + +struct A1 {}; +struct A2 {}; +struct A3 {}; +struct A4 {}; +struct A5 {}; +struct A6 {}; +struct A7 {}; +struct A8 {}; +struct A9 {}; +struct A10 {}; + +int main() +{ + { + typedef boost::function F; + + BOOST_TEST_TRAIT_SAME(F::result_type, R); + } + + { + typedef boost::function F; + + BOOST_TEST_TRAIT_SAME(F::result_type, R); + BOOST_TEST_TRAIT_SAME(F::arg1_type, A1); + } + + { + typedef boost::function F; + + BOOST_TEST_TRAIT_SAME(F::result_type, R); + BOOST_TEST_TRAIT_SAME(F::arg1_type, A1); + BOOST_TEST_TRAIT_SAME(F::arg2_type, A2); + } + + { + typedef boost::function F; + + BOOST_TEST_TRAIT_SAME(F::result_type, R); + BOOST_TEST_TRAIT_SAME(F::arg1_type, A1); + BOOST_TEST_TRAIT_SAME(F::arg2_type, A2); + BOOST_TEST_TRAIT_SAME(F::arg3_type, A3); + } + + { + typedef boost::function F; + + BOOST_TEST_TRAIT_SAME(F::result_type, R); + BOOST_TEST_TRAIT_SAME(F::arg1_type, A1); + BOOST_TEST_TRAIT_SAME(F::arg2_type, A2); + BOOST_TEST_TRAIT_SAME(F::arg3_type, A3); + BOOST_TEST_TRAIT_SAME(F::arg4_type, A4); + } + + { + typedef boost::function F; + + BOOST_TEST_TRAIT_SAME(F::result_type, R); + BOOST_TEST_TRAIT_SAME(F::arg1_type, A1); + BOOST_TEST_TRAIT_SAME(F::arg2_type, A2); + BOOST_TEST_TRAIT_SAME(F::arg3_type, A3); + BOOST_TEST_TRAIT_SAME(F::arg4_type, A4); + BOOST_TEST_TRAIT_SAME(F::arg5_type, A5); + } + + { + typedef boost::function F; + + BOOST_TEST_TRAIT_SAME(F::result_type, R); + BOOST_TEST_TRAIT_SAME(F::arg1_type, A1); + BOOST_TEST_TRAIT_SAME(F::arg2_type, A2); + BOOST_TEST_TRAIT_SAME(F::arg3_type, A3); + BOOST_TEST_TRAIT_SAME(F::arg4_type, A4); + BOOST_TEST_TRAIT_SAME(F::arg5_type, A5); + BOOST_TEST_TRAIT_SAME(F::arg6_type, A6); + } + + { + typedef boost::function F; + + BOOST_TEST_TRAIT_SAME(F::result_type, R); + BOOST_TEST_TRAIT_SAME(F::arg1_type, A1); + BOOST_TEST_TRAIT_SAME(F::arg2_type, A2); + BOOST_TEST_TRAIT_SAME(F::arg3_type, A3); + BOOST_TEST_TRAIT_SAME(F::arg4_type, A4); + BOOST_TEST_TRAIT_SAME(F::arg5_type, A5); + BOOST_TEST_TRAIT_SAME(F::arg6_type, A6); + BOOST_TEST_TRAIT_SAME(F::arg7_type, A7); + } + + { + typedef boost::function F; + + BOOST_TEST_TRAIT_SAME(F::result_type, R); + BOOST_TEST_TRAIT_SAME(F::arg1_type, A1); + BOOST_TEST_TRAIT_SAME(F::arg2_type, A2); + BOOST_TEST_TRAIT_SAME(F::arg3_type, A3); + BOOST_TEST_TRAIT_SAME(F::arg4_type, A4); + BOOST_TEST_TRAIT_SAME(F::arg5_type, A5); + BOOST_TEST_TRAIT_SAME(F::arg6_type, A6); + BOOST_TEST_TRAIT_SAME(F::arg7_type, A7); + BOOST_TEST_TRAIT_SAME(F::arg8_type, A8); + } + + { + typedef boost::function F; + + BOOST_TEST_TRAIT_SAME(F::result_type, R); + BOOST_TEST_TRAIT_SAME(F::arg1_type, A1); + BOOST_TEST_TRAIT_SAME(F::arg2_type, A2); + BOOST_TEST_TRAIT_SAME(F::arg3_type, A3); + BOOST_TEST_TRAIT_SAME(F::arg4_type, A4); + BOOST_TEST_TRAIT_SAME(F::arg5_type, A5); + BOOST_TEST_TRAIT_SAME(F::arg6_type, A6); + BOOST_TEST_TRAIT_SAME(F::arg7_type, A7); + BOOST_TEST_TRAIT_SAME(F::arg8_type, A8); + BOOST_TEST_TRAIT_SAME(F::arg9_type, A9); + } + + { + typedef boost::function F; + + BOOST_TEST_TRAIT_SAME(F::result_type, R); + BOOST_TEST_TRAIT_SAME(F::arg1_type, A1); + BOOST_TEST_TRAIT_SAME(F::arg2_type, A2); + BOOST_TEST_TRAIT_SAME(F::arg3_type, A3); + BOOST_TEST_TRAIT_SAME(F::arg4_type, A4); + BOOST_TEST_TRAIT_SAME(F::arg5_type, A5); + BOOST_TEST_TRAIT_SAME(F::arg6_type, A6); + BOOST_TEST_TRAIT_SAME(F::arg7_type, A7); + BOOST_TEST_TRAIT_SAME(F::arg8_type, A8); + BOOST_TEST_TRAIT_SAME(F::arg9_type, A9); + BOOST_TEST_TRAIT_SAME(F::arg10_type, A10); + } + + return boost::report_errors(); +} From 1204b7d20091c1ac65fb02a1d5991a82098e4f77 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 5 Jun 2024 16:48:43 +0300 Subject: [PATCH 2/2] Add missing argN_type typedefs. Fixes #51. --- include/boost/function/function_template.hpp | 109 +++++++++++++++++-- 1 file changed, 102 insertions(+), 7 deletions(-) diff --git a/include/boost/function/function_template.hpp b/include/boost/function/function_template.hpp index 48329c2..f21a395 100644 --- a/include/boost/function/function_template.hpp +++ b/include/boost/function/function_template.hpp @@ -586,17 +586,112 @@ namespace boost { struct variadic_function_base {}; - template - struct variadic_function_base + template + struct variadic_function_base { - typedef T argument_type; + typedef T1 argument_type; + typedef T1 arg1_type; }; - template - struct variadic_function_base + template + struct variadic_function_base { - typedef T0 first_argument_type; - typedef T1 second_argument_type; + typedef T1 first_argument_type; + typedef T2 second_argument_type; + typedef T1 arg1_type; + typedef T2 arg2_type; + }; + + template + struct variadic_function_base + { + typedef T1 arg1_type; + typedef T2 arg2_type; + typedef T3 arg3_type; + }; + + template + struct variadic_function_base + { + typedef T1 arg1_type; + typedef T2 arg2_type; + typedef T3 arg3_type; + typedef T4 arg4_type; + }; + + template + struct variadic_function_base + { + typedef T1 arg1_type; + typedef T2 arg2_type; + typedef T3 arg3_type; + typedef T4 arg4_type; + typedef T5 arg5_type; + }; + + template + struct variadic_function_base + { + typedef T1 arg1_type; + typedef T2 arg2_type; + typedef T3 arg3_type; + typedef T4 arg4_type; + typedef T5 arg5_type; + typedef T6 arg6_type; + }; + + template + struct variadic_function_base + { + 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; + }; + + template + struct variadic_function_base + { + 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; + }; + + template + struct variadic_function_base + { + 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; + }; + + template + struct variadic_function_base + { + 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; }; #if defined( BOOST_LIBSTDCXX_VERSION ) && BOOST_LIBSTDCXX_VERSION < 50000