diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6bd1d69b..393691dd 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -57,3 +57,8 @@ local check14 = [ check-target-builds mixed_cxxstd/14 : : no ] ; run test_mixed_cxxstd.cpp mixed_cxxstd/14 : : : shared $(check14) : mixed_cxxstd_shared_14 ; run test_mixed_cxxstd.cpp mixed_cxxstd/14 : : : static $(check14) : mixed_cxxstd_static_14 ; + +lib return_function : return_function.cpp : shared:RETURN_FUNCTION_DYN_LINK=1 ; + +run test_return_function.cpp return_function : : : shared : return_function_shared ; +run test_return_function.cpp return_function : : : static : return_function_static ; diff --git a/test/return_function.cpp b/test/return_function.cpp new file mode 100644 index 00000000..3fca7bbd --- /dev/null +++ b/test/return_function.cpp @@ -0,0 +1,27 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include +#include + +#if defined(RETURN_FUNCTION_DYN_LINK) +# define EXPORT BOOST_SYMBOL_EXPORT +#else +# define EXPORT +#endif + +int f( int x, int y ) +{ + return x + y; +} + +EXPORT boost::function get_fn_1() +{ + return f; +} + +EXPORT boost::function2 get_fn_2() +{ + return f; +} diff --git a/test/test_return_function.cpp b/test/test_return_function.cpp new file mode 100644 index 00000000..05712ed2 --- /dev/null +++ b/test/test_return_function.cpp @@ -0,0 +1,21 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include +#include + +// + +boost::function get_fn_1(); +boost::function2 get_fn_2(); + +// + +int main() +{ + BOOST_TEST_EQ( get_fn_1()( 1, 2 ), 3 ); + BOOST_TEST_EQ( get_fn_2()( 1, 2 ), 3 ); + + return boost::report_errors(); +}