diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/parameter | |
parent | Initial commit. (diff) | |
download | ceph-upstream/16.2.11+ds.tar.xz ceph-upstream/16.2.11+ds.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/parameter')
72 files changed, 10661 insertions, 0 deletions
diff --git a/src/boost/libs/parameter/CMakeLists.txt b/src/boost/libs/parameter/CMakeLists.txt new file mode 100644 index 000000000..5bf4f2ebb --- /dev/null +++ b/src/boost/libs/parameter/CMakeLists.txt @@ -0,0 +1,36 @@ +# Copyright 2019 Mike Dev +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt +# +# NOTE: CMake support for Boost.Parameter is currently experimental at best +# and the interface is likely to change in the future + +cmake_minimum_required( VERSION 3.5 ) +project( BoostParameter LANGUAGES CXX) + +option(BOOST_PARAMETER_INCLUDE_TESTS OFF "Include Boost.Parameter tests") + +add_library( boost_parameter INTERFACE ) +add_library( Boost::parameter ALIAS boost_parameter ) + +target_include_directories( boost_parameter INTERFACE include ) + +target_link_libraries( boost_parameter + INTERFACE + Boost::config + Boost::core + Boost::function + Boost::fusion + # TODO: we only need mp11 or mpl + Boost::mp11 + Boost::mpl + Boost::optional + Boost::preprocessor + Boost::type_traits + Boost::utility +) + +if(BOOST_PARAMETER_INCLUDE_TESTS) + enable_testing() + add_subdirectory(test) +endif() diff --git a/src/boost/libs/parameter/index.html b/src/boost/libs/parameter/index.html new file mode 100644 index 000000000..672aaab79 --- /dev/null +++ b/src/boost/libs/parameter/index.html @@ -0,0 +1,12 @@ +<!-- Copyright David Abrahams 2005. Distributed under the Boost --> +<!-- Software License, Version 1.0. (See accompanying --> +<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> +<html> +<head> +<meta http-equiv="refresh" content="0; URL=doc/html/index.html"> +</head> +<body> +Automatically loading index page... if nothing happens, please go to +<a href="doc/html/index.html">doc/html/index.html</a>. +</body> +</html> diff --git a/src/boost/libs/parameter/meta/libraries.json b/src/boost/libs/parameter/meta/libraries.json new file mode 100644 index 000000000..2d894515e --- /dev/null +++ b/src/boost/libs/parameter/meta/libraries.json @@ -0,0 +1,17 @@ +{ + "key": "parameter", + "name": "Parameter", + "authors": [ + "David Abrahams", + "Daniel Wallin" + ], + "description": "Boost.Parameter Library - Write functions that accept arguments by name.", + "category": [ + "Emulation", + "Programming" + ], + "maintainers": [ + "David Abrahams <dave -at- boost-consulting.com>", + "Daniel Wallin <daniel -at- boostpro.com>" + ] +} diff --git a/src/boost/libs/parameter/test/CMakeLists.txt b/src/boost/libs/parameter/test/CMakeLists.txt new file mode 100644 index 000000000..d5086b6ed --- /dev/null +++ b/src/boost/libs/parameter/test/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright 2019 Mike Dev +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt +# +# NOTE: CMake support for Boost.Parameter is currently experimental at best +# and the interface is likely to change in the future + +# TODO: Also process literate tests +file(GLOB test_files *.cpp) + +# remove some test for which the dependencies are not yet available or have special requirements +# TODO: enable more tests +list(FILTER test_files EXCLUDE REGEX + efficiency|deduced_unmatched_arg|python_test|duplicates) + +foreach(file IN LISTS test_files) + + get_filename_component(core_name ${file} NAME_WE) + set(test_name test_boost_parameter_${core_name}) + + add_executable(${test_name} ${file}) + # add Boost.Parameter and any libraries that are only needed by the tests (none at the moment) + target_link_libraries(${test_name} Boost::parameter) + + add_test(NAME ${test_name} COMMAND ${test_name}) + +endforeach()
\ No newline at end of file diff --git a/src/boost/libs/parameter/test/Jamfile.v2 b/src/boost/libs/parameter/test/Jamfile.v2 new file mode 100644 index 000000000..d9ccdbf0e --- /dev/null +++ b/src/boost/libs/parameter/test/Jamfile.v2 @@ -0,0 +1,947 @@ +# Copyright David Abrahams, Daniel Wallin 2006. +# Copyright Cromwell D. Enage 2017. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# Boost Parameter Library test Jamfile + +import testing ; + +project boost/parameter + : + default-build + <warnings>off + ; + +import python ; + +alias parameter_standard_tests + : + [ run maybe.cpp : : : : : <preserve-target-tests>off ] + [ run singular.cpp : : : : : <preserve-target-tests>off ] + [ run tutorial.cpp : : : : : <preserve-target-tests>off ] + [ run compose.cpp + : + : + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run sfinae.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run efficiency.cpp + : + : + : + : + : + <variant>release + <preserve-target-tests>off + ] + [ run evaluate_category.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + : + : + <preserve-target-tests>off + ] + [ run evaluate_category_16.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=16 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=0 + : + : + <preserve-target-tests>off + ] + [ run parameterized_inheritance.cpp + : + : + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run preprocessor_eval_cat_no_spec.cpp + : + : + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=8 + : + : + <preserve-target-tests>off + ] + [ run optional_deduced_sfinae.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=2 + : + : + <preserve-target-tests>off + ] + [ run preprocessor_eval_category.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + : + : + <preserve-target-tests>off + ] + [ run normalized_argument_types.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run basics.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + : + : + <preserve-target-tests>off + ] + [ run mpl.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + : + : + <preserve-target-tests>off + ] + [ run preprocessor.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + : + : + <preserve-target-tests>off + ] + [ run preprocessor_deduced.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + : + : + <preserve-target-tests>off + ] + [ run deduced.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + : + : + <preserve-target-tests>off + ] + [ run deduced_dependent_predicate.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + : + : + <preserve-target-tests>off + ] + [ run earwicker.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + : + : + <preserve-target-tests>off + ] + [ run macros.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + : + : + <preserve-target-tests>off + ] + [ compile unwrap_cv_reference.cpp ] + [ compile ntp.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=0 + ] + [ compile function_type_tpl_param.cpp ] + [ compile-fail duplicates.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + : + duplicates_fail + ] + [ compile-fail deduced_unmatched_arg.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + : + deduced_unmatched_arg_fail + ] + [ compile-fail basics.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE + : + basics_fail + ] + [ compile-fail compose.cpp + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=3 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_0 + : + compose_fail_0 + ] + [ compile-fail compose.cpp + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=3 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_1 + : + compose_fail_1 + ] + [ compile-fail evaluate_category.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE + : + evaluate_category_fail + ] + [ compile-fail preprocessor_deduced.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE + : + preprocessor_deduced_fail + ] + [ compile-fail deduced.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE + : + deduced_fail + ] + ; + +alias parameter_literate_tests + : + [ run literate/building-argumentpacks0.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run literate/deduced-parameters0.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=5 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=6 + : + : + <preserve-target-tests>off + ] + [ run literate/deduced-template-parameters0.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + : + : + <preserve-target-tests>off + ] + [ run literate/default-expression-evaluation0.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=5 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=6 + : + : + <preserve-target-tests>off + ] + [ run literate/extracting-parameter-types0.cpp + : + : + : + : + : + <preserve-target-tests>off + ] + [ run literate/extracting-parameter-types1.cpp + : + : + : + : + : + <preserve-target-tests>off + ] + [ run literate/fine-grained-name-control0.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run literate/lazy-default-computation0.cpp + : + : + : + : + : + <preserve-target-tests>off + ] + [ run literate/lazy-default-computation1.cpp + : + : + : + : + : + <preserve-target-tests>off + ] + [ run literate/namespaces0.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run literate/namespaces1.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run literate/namespaces2.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run literate/namespaces3.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run literate/parameter-enabled-constructors0.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run literate/parameter-enabled-function-call-operators0.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run literate/parameter-enabled-member-functions0.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run literate/predicate-requirements0.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=5 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=6 + : + : + <preserve-target-tests>off + ] + [ run literate/static-member-functions0.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + : + : + <preserve-target-tests>off + ] + [ run literate/top-level0.cpp + : + : + : + <define>BOOST_PARAMETER_MAX_ARITY=3 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=4 + : + : + <preserve-target-tests>off + ] + [ compile literate/class-template-skeleton0.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + ] + [ compile literate/defining-the-keywords0.cpp ] + [ compile literate/defining-the-keywords1.cpp ] + [ compile literate/exercising-the-code-so-far0.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + ] + [ compile literate/handling-out-parameters0.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=5 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=6 + ] + [ compile literate/headers-and-namespaces0.cpp ] + [ compile literate/optional-parameters0.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=5 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=6 + ] + [ compile literate/parameter-enabled-member-functions1.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + ] + [ compile literate/required-parameters0.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=2 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=3 + ] + [ compile literate/template-keywords0.cpp ] + [ compile literate/template-keywords1.cpp ] + [ compile literate/writing-the-function0.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=5 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=6 + ] + ; + +alias parameter_python_test + : + : + # Python fails for clang on linux with cxxstd set to 14 + <target-os>linux + <toolset>clang + <cxxstd>14 + ; + +alias parameter_python_test + : + : + # Python fails for clang on linux with cxxstd set to 1z + <target-os>linux + <toolset>clang + <cxxstd>1z + ; + +alias parameter_python_test + : + : + # Python fails for xcode 8.3.0 on osx + # so we turn off this test for this compiler completely for now + <target-os>darwin + # TODO: Differentiate by xcode version or by clang version + ; + +alias parameter_python_test + : + : + # Python fails for mingw compilers with cxxstd set to 11 or higher + # because of a Python header problem + # so we turn off this test for this compiler completely + <target-os>windows + <toolset>gcc + <address-model>32 + ; + +alias parameter_python_test + : + : + # Python fails for clang-linux compilers with cxxstd set to 11 or higher + # because of a Python header problem + # so we turn off this test for this compiler completely + <target-os>windows + <toolset>clang-linux + <address-model>32 + ; + +alias parameter_python_test + : + : + # Python fails for windows compilers with 64-bit addressing set + # because of a Python header problem + <target-os>windows + <address-model>64 + ; + +alias parameter_python_test + : + [ bpl-test python_test ] + ; + +alias parameter_macros_eval_category + : + : + <target-os>linux + <toolset>gcc + <toolset-gcc:version>4.8 + ; + +alias parameter_macros_eval_category + : + : + # This test fails for xcode 7.3.0 on osx + # so we turn off this test for this compiler for now + <target-os>darwin + <cxxstd>03 + # TODO: Differentiate by xcode version or by clang version + ; + +alias parameter_macros_eval_category + : + : + <target-os>windows + <toolset>gcc + ; + +alias parameter_macros_eval_category + : + [ run macros_eval_category.cpp + : + : + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=10 + <define>BOOST_PARAMETER_MAX_ARITY=10 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=0 + : + macros_eval_category_cxx98 + : + <preserve-target-tests>off + ] + : + <cxxstd>98 + ; + +alias parameter_macros_eval_category + : + [ run macros_eval_category.cpp + : + : + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=10 + <define>BOOST_PARAMETER_MAX_ARITY=10 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=0 + : + macros_eval_category_cxx03 + : + <preserve-target-tests>off + ] + : + <cxxstd>03 + ; + +alias parameter_macros_eval_category + : + [ run macros_eval_category.cpp + : + : + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=10 + <define>BOOST_PARAMETER_MAX_ARITY=10 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=11 + : + : + <preserve-target-tests>off + ] + ; + +alias parameter_evaluate_category_10 + : + [ run evaluate_category_10.cpp + : + : + : + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=0 + : + evaluate_category_10_gcc_4_8_linux + : + <preserve-target-tests>off + ] + : + <target-os>linux + <toolset>gcc + <toolset-gcc:version>4.8 + ; + +alias parameter_evaluate_category_10 + : + [ run evaluate_category_10.cpp + : + : + : + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=0 + : + evaluate_category_10_mingw + : + <preserve-target-tests>off + ] + : + <target-os>windows + <toolset>gcc + ; + +alias parameter_evaluate_category_10 + : + [ run evaluate_category_10.cpp + : + : + : + : + evaluate_category_10_cxx98 + : + <preserve-target-tests>off + ] + : + <cxxstd>98 + ; + +alias parameter_evaluate_category_10 + : + [ run evaluate_category_10.cpp + : + : + : + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=0 + : + evaluate_category_10_cxx03 + : + <preserve-target-tests>off + ] + : + <cxxstd>03 + ; + +alias parameter_evaluate_category_10 + : + [ run evaluate_category_10.cpp + : + : + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=10 + <define>BOOST_PARAMETER_MAX_ARITY=10 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=11 + : + : + <preserve-target-tests>off + ] + ; + +alias parameter_preprocessor_eval_cat_8 + : + [ run preprocessor_eval_cat_8.cpp + : + : + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=8 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=0 + : + preproc_eval_cat_8_mingw + : + <preserve-target-tests>off + ] + : + <target-os>windows + <toolset>gcc + ; + +alias parameter_preprocessor_eval_cat_8 + : + [ run preprocessor_eval_cat_8.cpp + : + : + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=8 + <define>BOOST_PARAMETER_MAX_ARITY=8 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=9 + : + : + <preserve-target-tests>off + ] + ; + +alias parameter_preprocessor_eval_cat_fail + : + : + # This test fails for xcode 7.3.0 and xcode 8.3.0 on osx + # so we turn off this test for this compiler for now + <target-os>darwin + <cxxstd>03 + # TODO: Differentiate by xcode version or by clang version + ; + +alias parameter_preprocessor_eval_cat_fail + : + : + <target-os>windows + <toolset>gcc + ; + +alias parameter_preprocessor_eval_cat_fail + : + [ compile-fail preprocessor_eval_category.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=8 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=9 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE + : + preproc_eval_cat_fail + ] + ; + +alias parameter_vendor_specific_fail_tests ; + +alias parameter_vendor_specific_fail_tests + : + [ compile-fail preprocessor_deduced.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + preproc_deduced_fail_msvc08 + ] + : + <toolset>msvc + <toolset-msvc:version>8.0 + ; + +alias parameter_vendor_specific_fail_tests + : + [ compile-fail preprocessor_deduced.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + preproc_deduced_fail_msvc09 + ] + : + <toolset>msvc + <toolset-msvc:version>9.0 + ; + +alias parameter_vendor_specific_fail_tests + : + [ compile-fail preprocessor_deduced.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + preproc_deduced_fail_msvc10 + ] + : + <toolset>msvc + <toolset-msvc:version>10.0 + ; + +alias parameter_vendor_specific_fail_tests + : + [ compile-fail compose.cpp + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=3 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + compose_fail_msvc11 + ] + [ compile-fail preprocessor_deduced.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + preproc_deduced_fail_msvc11 + ] + : + <toolset>msvc + <toolset-msvc:version>11.0 + ; + +alias parameter_vendor_specific_fail_tests + : + [ compile-fail evaluate_category.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + evaluate_category_fail_msvc12 + ] + [ compile-fail preprocessor_eval_category.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=8 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=9 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + preproc_eval_cat_fail_msvc12 + ] + [ compile-fail preprocessor_eval_cat_no_spec.cpp + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=8 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + preproc_eval_cat_no_spec_fail_msvc12 + ] + : + <toolset>msvc + <toolset-msvc:version>12.0 + ; + +alias parameter_vendor_specific_fail_tests + : + [ compile-fail evaluate_category.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + evaluate_category_fail_msvc14_0 + ] + [ compile-fail preprocessor_eval_category.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=8 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=9 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + preproc_eval_cat_fail_msvc14_0 + ] + [ compile-fail preprocessor_eval_cat_no_spec.cpp + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=8 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + preproc_eval_cat_no_spec_fail_msvc14_0 + ] + : + <toolset>msvc + <toolset-msvc:version>14.0 + ; + +alias parameter_vendor_specific_fail_tests + : + [ compile-fail evaluate_category.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=4 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=5 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + evaluate_category_fail_msvc14_1 + ] + [ compile-fail preprocessor_eval_category.cpp + : + <define>BOOST_PARAMETER_MAX_ARITY=8 + <define>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY=9 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + preproc_eval_cat_fail_msvc14_1 + ] + [ compile-fail preprocessor_eval_cat_no_spec.cpp + : + <define>BOOST_PARAMETER_COMPOSE_MAX_ARITY=8 + <define>LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC + : + preproc_eval_cat_no_spec_fail_msvc14_1 + ] + : + <toolset>msvc + <toolset-msvc:version>14.1 + ; + +# TODO: Replace with "undeprecated" version. +test-suite "parameter" + : + parameter_macros_eval_category + parameter_evaluate_category_10 + parameter_preprocessor_eval_cat_8 + parameter_preprocessor_eval_cat_fail + parameter_standard_tests + parameter_literate_tests + parameter_python_test + parameter_vendor_specific_fail_tests + ; diff --git a/src/boost/libs/parameter/test/basics.cpp b/src/boost/libs/parameter/test/basics.cpp new file mode 100644 index 000000000..5f698036d --- /dev/null +++ b/src/boost/libs/parameter/test/basics.cpp @@ -0,0 +1,115 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Copyright Cromwell D. Enage 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter.hpp> +#include <boost/bind.hpp> +#include "basics.hpp" + +namespace test { + + // A separate function for getting the "value" key, so we can deduce F + // and use lazy_binding on it. + template <typename Params, typename F> + typename boost::parameter::lazy_binding<Params,tag::value,F>::type + extract_value(Params const& p, F const& f) + { + typename boost::parameter::lazy_binding< + Params,test::tag::value,F + >::type v = p[test::_value || f]; + return v; + } + + template <typename Params> + int f_impl(Params const& p) + { + typename boost::parameter::binding<Params,test::tag::name>::type + n = p[test::_name]; + + typename boost::parameter::binding< + Params,test::tag::value,double + >::type v = test::extract_value(p, boost::bind(&test::value_default)); + + typename boost::parameter::binding<Params,test::tag::index,int>::type + i = p[test::_index | 999]; + + p[test::_tester](n, v, i); + + return 1; + } + +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + template <typename ...Args> + int f(Args const&... args) + { + return test::f_impl(test::f_parameters()(args...)); + } +#else + template <typename A0, typename A1, typename A2, typename A3> + int f(A0 const& a0, A1 const& a1, A2 const& a2, A3 const& a3) + { + return test::f_impl(test::f_parameters()(a0, a1, a2, a3)); + } + + template <typename A0, typename A1, typename A2> + int f(A0 const& a0, A1 const& a1, A2 const& a2) + { + return test::f_impl(test::f_parameters()(a0, a1, a2)); + } + + template <typename A0, typename A1> + int f(A0 const& a0, A1 const& a1) + { + return test::f_impl(test::f_parameters()(a0, a1)); + } +#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING + + template <typename Params> + int f_list(Params const& params) + { + return test::f_impl(params); + } +} + +#include <boost/core/ref.hpp> +#include <boost/config/workaround.hpp> +#include <string> + +int main() +{ + test::f( + test::values( + std::string("foo") + , std::string("bar") + , std::string("baz") + ) + , std::string("foo") + , std::string("bar") + , std::string("baz") + ); + + int x = 56; + test::f( + test::values(std::string("foo"), 666.222, 56) + , test::_index = boost::ref(x) + , test::_name = std::string("foo") + ); + +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + x = 56; + test::f_list(( + test::_tester = test::values(std::string("foo"), 666.222, 56) + , test::_index = boost::ref(x) + , test::_name = std::string("foo") + )); +#endif // No comma operator available on Borland. + +#if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE) + test::f(test::_index = 56, test::_name = 55); // won't compile +#endif + + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/basics.hpp b/src/boost/libs/parameter/test/basics.hpp new file mode 100644 index 000000000..5fda1dab1 --- /dev/null +++ b/src/boost/libs/parameter/test/basics.hpp @@ -0,0 +1,129 @@ +// Copyright David Abrahams, Daniel Wallin 2005. +// Copyright Cromwell D. Enage 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_TEST_BASICS_HPP +#define BOOST_PARAMETER_TEST_BASICS_HPP + +#include <boost/parameter.hpp> + +#if (BOOST_PARAMETER_MAX_ARITY < 4) +#error Define BOOST_PARAMETER_MAX_ARITY as 4 or greater. +#endif +#if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ + (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 5) +#error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \ +as 5 or greater. +#endif + +#if !defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/type_traits/is_same.hpp> +#endif + +#include <boost/core/lightweight_test.hpp> + +namespace test { + + BOOST_PARAMETER_NAME(name) + BOOST_PARAMETER_NAME(value) + BOOST_PARAMETER_NAME(index) + BOOST_PARAMETER_NAME(tester) + + struct f_parameters // vc6 is happier with inheritance than with a typedef + : boost::parameter::parameters< + test::tag::tester + , test::tag::name + , test::tag::value + , test::tag::index + > + { + }; + + inline double value_default() + { + return 666.222; + } + + template <typename T> + inline bool equal(T const& x, T const& y) + { + return x == y; + } + + template <typename Name, typename Value, typename Index> + struct values_t + { + values_t(Name const& n_, Value const& v_, Index const& i_) + : n(n_), v(v_), i(i_) + { + } + + template <typename Name_, typename Value_, typename Index_> + void + operator()( + Name_ const& n_ + , Value_ const& v_ + , Index_ const& i_ + ) const + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_same<Index,Index_>::value + , "Index == Index_" + ); + static_assert( + std::is_same<Value,Value_>::value + , "Value == Value_" + ); + static_assert( + std::is_same<Name,Name_>::value + , "Name == Name_" + ); +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same<Index,Index_> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same<Value,Value_> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same<Name,Name_> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif // BOOST_PARAMETER_CAN_USE_MP11 + BOOST_TEST(test::equal(n, n_)); + BOOST_TEST(test::equal(v, v_)); + BOOST_TEST(test::equal(i, i_)); + } + + Name const& n; + Value const& v; + Index const& i; + }; + + template <typename Name, typename Value, typename Index> + inline test::values_t<Name,Value,Index> + values(Name const& n, Value const& v, Index const& i) + { + return test::values_t<Name,Value,Index>(n, v, i); + } +} // namespace test + +#endif // include guard + diff --git a/src/boost/libs/parameter/test/compose.cpp b/src/boost/libs/parameter/test/compose.cpp new file mode 100644 index 000000000..069f0cb0c --- /dev/null +++ b/src/boost/libs/parameter/test/compose.cpp @@ -0,0 +1,746 @@ +// Copyright Rene Rivera 2006. +// Copyright Cromwell D. Enage 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/nested_keyword.hpp> +#include <boost/parameter/name.hpp> +#include <boost/parameter/config.hpp> + +namespace param { + + BOOST_PARAMETER_NESTED_KEYWORD(tag, a0, a_zero) + BOOST_PARAMETER_NESTED_KEYWORD(tag, a1, a_one) + BOOST_PARAMETER_NAME(a2) + BOOST_PARAMETER_NAME(a3) + BOOST_PARAMETER_NAME(in(lrc)) + BOOST_PARAMETER_NAME(out(lr)) +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_PARAMETER_NAME(consume(rr)) +#else + BOOST_PARAMETER_NAME(rr) +#endif +} + +#include <boost/parameter/is_argument_pack.hpp> +#include <boost/mpl/void.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/has_key.hpp> +#include <boost/mpl/key_type.hpp> +#include <boost/mpl/order.hpp> +#include <boost/mpl/count.hpp> +#include <boost/mpl/equal_to.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/type_traits/is_same.hpp> + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/mp11/list.hpp> +#include <boost/mp11/map.hpp> +#include <type_traits> +#endif + +#if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) +#include <boost/function.hpp> +#else +#include <functional> +#endif + +namespace test { + + struct A + { + int i; + int j; + + template <typename ArgPack> + A(ArgPack const& args) : i(args[param::a0]), j(args[param::a1]) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + boost::mp11::mp_map_contains<ArgPack,param::tag::a0>::value + , "param::tag::a0 must be in ArgPack" + ); + static_assert( + boost::mp11::mp_map_contains<ArgPack,param::tag::a1>::value + , "param::tag::a1 must be in ArgPack" + ); + static_assert( + !boost::mp11::mp_map_contains<ArgPack,param::tag::lrc>::value + , "param::tag::lrc must not be in ArgPack" + ); + static_assert( + !boost::mp11::mp_map_contains<ArgPack,param::tag::lr>::value + , "param::tag::lr must not be in ArgPack" + ); + static_assert( + !boost::mp11::mp_map_contains<ArgPack,param::tag::rr>::value + , "param::tag::rr must not be in ArgPack" + ); + static_assert( + !std::is_same< + ::boost::mp11::mp_map_find<ArgPack,param::tag::a0> + , void + >::value + , "param::tag::a0 must be found in ArgPack" + ); + static_assert( + !std::is_same< + ::boost::mp11::mp_map_find<ArgPack,param::tag::a1> + , void + >::value + , "param::tag::a1 must be found in ArgPack" + ); + static_assert( + std::is_same< + ::boost::mp11::mp_map_find<ArgPack,param::tag::lrc> + , void + >::value + , "param::tag::lrc must not be found in ArgPack" + ); + static_assert( + std::is_same< + ::boost::mp11::mp_map_find<ArgPack,param::tag::lr> + , void + >::value + , "param::tag::lr must not be found in ArgPack" + ); + static_assert( + std::is_same< + ::boost::mp11::mp_map_find<ArgPack,param::tag::rr> + , void + >::value + , "param::tag::rr must not be found in ArgPack" + ); +#endif // BOOST_PARAMETER_CAN_USE_MP11 + BOOST_MPL_ASSERT((boost::parameter::is_argument_pack<ArgPack>)); + BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::a0>)); + BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::a1>)); + BOOST_MPL_ASSERT_NOT(( + boost::mpl::has_key<ArgPack,param::tag::lrc> + )); + BOOST_MPL_ASSERT_NOT(( + boost::mpl::has_key<ArgPack,param::tag::lr> + )); + BOOST_MPL_ASSERT_NOT(( + boost::mpl::has_key<ArgPack,param::tag::rr> + )); + BOOST_MPL_ASSERT(( + boost::mpl::equal_to< + typename boost::mpl::count<ArgPack,param::tag::a0>::type + , boost::mpl::int_<1> + > + )); + BOOST_MPL_ASSERT(( + boost::mpl::equal_to< + typename boost::mpl::count<ArgPack,param::tag::a1>::type + , boost::mpl::int_<1> + > + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::key_type<ArgPack,param::tag::a0>::type + , param::tag::a0 + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::key_type<ArgPack,param::tag::a1>::type + , param::tag::a1 + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::order<ArgPack,param::tag::a0>::type + , boost::mpl::void_ + > + , boost::mpl::false_ + , boost::mpl::true_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::order<ArgPack,param::tag::a1>::type + , boost::mpl::void_ + > + , boost::mpl::false_ + , boost::mpl::true_ + >::type + )); + } + }; + + float F() + { + return 4.0f; + } + + float E() + { + return 4.625f; + } + + double D() + { + return 198.9; + } + + struct C + { + struct result_type + { + double operator()() const + { + return 2.5; + } + }; + + result_type operator()() const + { + return result_type(); + } + }; + + struct B : A + { +#if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) + boost::function<float()> k; + boost::function<double()> l; +#else + std::function<float()> k; + std::function<double()> l; +#endif + + template <typename ArgPack> + B(ArgPack const& args) + : A((args, param::tag::a0::a_zero = 1)) + , k(args[param::_a2 | E]) + , l(args[param::_a3 || C()]) + { + } + }; + + struct G + { + int i; + int& j; + int const& k; + + template <typename ArgPack> + G(ArgPack const& args) + : i(args[param::_rr]) + , j(args[param::_lr]) + , k(args[param::_lrc]) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + boost::mp11::mp_map_contains<ArgPack,param::tag::lrc>::value + , "param::tag::lrc must be in ArgPack" + ); + static_assert( + boost::mp11::mp_map_contains<ArgPack,param::tag::lr>::value + , "param::tag::lr must be in ArgPack" + ); + static_assert( + boost::mp11::mp_map_contains<ArgPack,param::tag::rr>::value + , "param::tag::rr must be in ArgPack" + ); + static_assert( + !boost::mp11::mp_map_contains<ArgPack,param::tag::a0>::value + , "param::tag::a0 must not be in ArgPack" + ); + static_assert( + !boost::mp11::mp_map_contains<ArgPack,param::tag::a1>::value + , "param::tag::a1 must not be in ArgPack" + ); + static_assert( + !boost::mp11::mp_map_contains<ArgPack,param::tag::a2>::value + , "param::tag::a2 must not be in ArgPack" + ); + static_assert( + !boost::mp11::mp_map_contains<ArgPack,param::tag::a3>::value + , "param::tag::a3 must not be in ArgPack" + ); + static_assert( + !std::is_same< + boost::mp11::mp_map_find<ArgPack,param::tag::lrc> + , void + >::value + , "param::tag::lrc must be found in ArgPack" + ); + static_assert( + !std::is_same< + boost::mp11::mp_map_find<ArgPack,param::tag::lr> + , void + >::value + , "param::tag::lr must be found in ArgPack" + ); + static_assert( + !std::is_same< + boost::mp11::mp_map_find<ArgPack,param::tag::rr> + , void + >::value + , "param::tag::rr must be found in ArgPack" + ); + static_assert( + std::is_same< + boost::mp11::mp_map_find<ArgPack,param::tag::a0> + , void + >::value + , "param::tag::a0 must not be found in ArgPack" + ); + static_assert( + std::is_same< + boost::mp11::mp_map_find<ArgPack,param::tag::a1> + , void + >::value + , "param::tag::a1 must not be found in ArgPack" + ); + static_assert( + std::is_same< + boost::mp11::mp_map_find<ArgPack,param::tag::a2> + , void + >::value + , "param::tag::a2 must not be found in ArgPack" + ); + static_assert( + std::is_same< + boost::mp11::mp_map_find<ArgPack,param::tag::a3> + , void + >::value + , "param::tag::a3 must not be found in ArgPack" + ); +#endif // BOOST_PARAMETER_CAN_USE_MP11 + BOOST_MPL_ASSERT((boost::parameter::is_argument_pack<ArgPack>)); + BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::rr>)); + BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::lr>)); + BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::lrc>)); + BOOST_MPL_ASSERT_NOT(( + boost::mpl::has_key<ArgPack,param::tag::a0> + )); + BOOST_MPL_ASSERT_NOT(( + boost::mpl::has_key<ArgPack,param::tag::a1> + )); + BOOST_MPL_ASSERT_NOT(( + boost::mpl::has_key<ArgPack,param::tag::a2> + )); + BOOST_MPL_ASSERT_NOT(( + boost::mpl::has_key<ArgPack,param::tag::a3> + )); + BOOST_MPL_ASSERT(( + boost::mpl::equal_to< + typename boost::mpl::count<ArgPack,param::tag::rr>::type + , boost::mpl::int_<1> + > + )); + BOOST_MPL_ASSERT(( + boost::mpl::equal_to< + typename boost::mpl::count<ArgPack,param::tag::lr>::type + , boost::mpl::int_<1> + > + )); + BOOST_MPL_ASSERT(( + boost::mpl::equal_to< + typename boost::mpl::count<ArgPack,param::tag::lrc>::type + , boost::mpl::int_<1> + > + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::key_type<ArgPack,param::tag::rr>::type + , param::tag::rr + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::key_type<ArgPack,param::tag::lr>::type + , param::tag::lr + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::key_type<ArgPack,param::tag::lrc>::type + , param::tag::lrc + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::order<ArgPack,param::tag::rr>::type + , boost::mpl::void_ + > + , boost::mpl::false_ + , boost::mpl::true_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::order<ArgPack,param::tag::lr>::type + , boost::mpl::void_ + > + , boost::mpl::false_ + , boost::mpl::true_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::order<ArgPack,param::tag::lrc>::type + , boost::mpl::void_ + > + , boost::mpl::false_ + , boost::mpl::true_ + >::type + )); + } + }; +} // namespace test + +#include <utility> + +namespace test { + + std::pair<int,int> const& lvalue_const_pair() + { + static std::pair<int,int> const clp = std::pair<int,int>(7, 10); + return clp; + } + + struct H + { + std::pair<int,int> i; + std::pair<int,int>& j; + std::pair<int,int> const& k; + + template <typename ArgPack> + H(ArgPack const& args) + : i(args[param::_rr | test::lvalue_const_pair()]) + , j(args[param::_lr]) + , k(args[param::_lrc]) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + boost::mp11::mp_map_contains<ArgPack,param::tag::lrc>::value + , "param::tag::lrc must be in ArgPack" + ); + static_assert( + boost::mp11::mp_map_contains<ArgPack,param::tag::lr>::value + , "param::tag::lr must be in ArgPack" + ); + static_assert( + !std::is_same< + boost::mp11::mp_map_find<ArgPack,param::tag::lrc> + , void + >::value + , "param::tag::lrc must be found in ArgPack" + ); + static_assert( + !std::is_same< + boost::mp11::mp_map_find<ArgPack,param::tag::lr> + , void + >::value + , "param::tag::lr must be found in ArgPack" + ); +#endif // BOOST_PARAMETER_CAN_USE_MP11 + BOOST_MPL_ASSERT((boost::parameter::is_argument_pack<ArgPack>)); + BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::lr>)); + BOOST_MPL_ASSERT((boost::mpl::has_key<ArgPack,param::tag::lrc>)); + BOOST_MPL_ASSERT(( + boost::mpl::equal_to< + typename boost::mpl::count<ArgPack,param::tag::lr>::type + , boost::mpl::int_<1> + > + )); + BOOST_MPL_ASSERT(( + boost::mpl::equal_to< + typename boost::mpl::count<ArgPack,param::tag::lrc>::type + , boost::mpl::int_<1> + > + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::key_type<ArgPack,param::tag::lr>::type + , param::tag::lr + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::key_type<ArgPack,param::tag::lrc>::type + , param::tag::lrc + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::order<ArgPack,param::tag::lr>::type + , boost::mpl::void_ + > + , boost::mpl::false_ + , boost::mpl::true_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::order<ArgPack,param::tag::lrc>::type + , boost::mpl::void_ + > + , boost::mpl::false_ + , boost::mpl::true_ + >::type + )); + } + }; +} // namespace test + +#include <boost/core/lightweight_test.hpp> + +void test_compose0() +{ +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1700) && \ + BOOST_WORKAROUND(BOOST_MSVC, < 1800) + // MSVC 11.0 on AppVeyor fails without this workaround. + test::A a(( + param::a0 = 1 + , param::a1 = 13 + , param::_a2 = std::function<double()>(test::D) + )); +#else + test::A a((param::a0 = 1, param::a1 = 13, param::_a2 = test::D)); +#endif + BOOST_TEST_EQ(1, a.i); + BOOST_TEST_EQ(13, a.j); +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1700) && \ + BOOST_WORKAROUND(BOOST_MSVC, < 1800) + // MSVC 11.0 on AppVeyor fails without this workaround. + test::B b0(( + param::tag::a1::a_one = 13 + , param::_a2 = std::function<float()>(test::F) + )); +#else + test::B b0((param::tag::a1::a_one = 13, param::_a2 = test::F)); +#endif + BOOST_TEST_EQ(1, b0.i); + BOOST_TEST_EQ(13, b0.j); + BOOST_TEST_EQ(4.0f, b0.k()); + BOOST_TEST_EQ(2.5, b0.l()); +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1700) && \ + BOOST_WORKAROUND(BOOST_MSVC, < 1800) + // MSVC 11.0 on AppVeyor fails without this workaround. + test::B b1(( + param::_a3 = std::function<double()>(test::D) + , param::a1 = 13 + )); +#else + test::B b1((param::_a3 = test::D, param::a1 = 13)); +#endif + BOOST_TEST_EQ(1, b1.i); + BOOST_TEST_EQ(13, b1.j); + BOOST_TEST_EQ(4.625f, b1.k()); + BOOST_TEST_EQ(198.9, b1.l()); + int x = 23; + int const y = 42; +#if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_0) + test::G g((param::_lr = 15, param::_rr = 16, param::_lrc = y)); +#else + test::G g((param::_lr = x, param::_rr = 16, param::_lrc = y)); +#endif + BOOST_TEST_EQ(16, g.i); + BOOST_TEST_EQ(23, g.j); + BOOST_TEST_EQ(42, g.k); + x = 1; + BOOST_TEST_EQ(1, g.j); + std::pair<int,int> p1(8, 9); + std::pair<int,int> const p2(11, 12); + test::H h0((param::_lr = p1, param::_lrc = p2)); +#if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_1) + test::H h1(( + param::_lr = p2 + , param::_rr = std::make_pair(7, 10) + , param::_lrc = p2 + )); +#else + test::H h1(( + param::_lr = p1 + , param::_rr = std::make_pair(7, 10) + , param::_lrc = p2 + )); +#endif + BOOST_TEST_EQ(h0.i.first, h1.i.first); + BOOST_TEST_EQ(h0.i.second, h1.i.second); + BOOST_TEST_EQ(p1.first, h1.j.first); + BOOST_TEST_EQ(p1.second, h1.j.second); + BOOST_TEST_EQ(p2.first, h1.k.first); + BOOST_TEST_EQ(p2.second, h1.k.second); + p1.first = 1; + BOOST_TEST_EQ(p1.first, h1.j.first); +} + +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) || \ + (2 < BOOST_PARAMETER_COMPOSE_MAX_ARITY) +#include <boost/parameter/compose.hpp> + +void test_compose1() +{ +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1700) && \ + BOOST_WORKAROUND(BOOST_MSVC, < 1800) + // MSVC 11.0 on AppVeyor fails without this workaround. + test::A a(boost::parameter::compose( + param::a0 = 1 + , param::a1 = 13 + , param::_a2 = std::function<double()>(test::D) + )); +#else + test::A a(boost::parameter::compose( + param::a0 = 1 + , param::a1 = 13 + , param::_a2 = test::D + )); +#endif + BOOST_TEST_EQ(1, a.i); + BOOST_TEST_EQ(13, a.j); +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1700) && \ + BOOST_WORKAROUND(BOOST_MSVC, < 1800) + // MSVC 11.0 on AppVeyor fails without this workaround. + test::B b0(boost::parameter::compose( + param::tag::a1::a_one = 13 + , param::_a2 = std::function<float()>(test::F) + )); +#else + test::B b0(boost::parameter::compose( + param::tag::a1::a_one = 13 + , param::_a2 = test::F + )); +#endif + BOOST_TEST_EQ(1, b0.i); + BOOST_TEST_EQ(13, b0.j); + BOOST_TEST_EQ(4.0f, b0.k()); + BOOST_TEST_EQ(2.5, b0.l()); +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1700) && \ + BOOST_WORKAROUND(BOOST_MSVC, < 1800) + // MSVC 11.0 on AppVeyor fails without this workaround. + test::B b1(boost::parameter::compose( + param::_a3 = std::function<double()>(test::D) + , param::a1 = 13 + )); +#else + test::B b1(boost::parameter::compose( + param::_a3 = test::D + , param::a1 = 13 + )); +#endif + BOOST_TEST_EQ(1, b1.i); + BOOST_TEST_EQ(13, b1.j); + BOOST_TEST_EQ(4.625f, b1.k()); + BOOST_TEST_EQ(198.9, b1.l()); + int x = 23; + int const y = 42; +#if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_0) + test::G g(boost::parameter::compose( + param::_lr = 15 + , param::_rr = 16 + , param::_lrc = y + )); +#else + test::G g(boost::parameter::compose( + param::_lr = x + , param::_rr = 16 + , param::_lrc = y + )); +#endif + BOOST_TEST_EQ(16, g.i); + BOOST_TEST_EQ(23, g.j); + BOOST_TEST_EQ(42, g.k); + x = 1; + BOOST_TEST_EQ(1, g.j); + std::pair<int,int> p1(8, 9); + std::pair<int,int> const p2(11, 12); + test::H h0(boost::parameter::compose(param::_lr = p1, param::_lrc = p2)); +#if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_1) + test::H h1(boost::parameter::compose( + param::_lr = p2 + , param::_rr = std::make_pair(7, 10) + , param::_lrc = p2 + )); +#else + test::H h1(boost::parameter::compose( + param::_lr = p1 + , param::_rr = std::make_pair(7, 10) + , param::_lrc = p2 + )); +#endif + BOOST_TEST_EQ(h0.i.first, h1.i.first); + BOOST_TEST_EQ(h0.i.second, h1.i.second); + BOOST_TEST_EQ(p1.first, h1.j.first); + BOOST_TEST_EQ(p1.second, h1.j.second); + BOOST_TEST_EQ(p2.first, h1.k.first); + BOOST_TEST_EQ(p2.second, h1.k.second); + p1.first = 1; + BOOST_TEST_EQ(p1.first, h1.j.first); +} + +#endif // can invoke boost::parameter::compose + +int main() +{ + test_compose0(); +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) || \ + (2 < BOOST_PARAMETER_COMPOSE_MAX_ARITY) + test_compose1(); +#endif + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/deduced.cpp b/src/boost/libs/parameter/test/deduced.cpp new file mode 100644 index 000000000..359685fda --- /dev/null +++ b/src/boost/libs/parameter/test/deduced.cpp @@ -0,0 +1,182 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/parameters.hpp> +#include <boost/parameter/name.hpp> +#include <boost/parameter/binding.hpp> +#include <boost/parameter/config.hpp> +#include "deduced.hpp" + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <type_traits> +#else +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_convertible.hpp> +#endif + +#if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE) +#include <boost/parameter/aux_/preprocessor/nullptr.hpp> +#endif + +namespace test { + + BOOST_PARAMETER_NAME(x) + BOOST_PARAMETER_NAME(y) + BOOST_PARAMETER_NAME(z) + + template <typename To> + struct predicate + { + template <typename From, typename Args> +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + using fn = std::is_convertible<From,To>; +#else + struct apply + : boost::mpl::if_< + boost::is_convertible<From,To> + , boost::mpl::true_ + , boost::mpl::false_ + > + { + }; +#endif + }; +} // namespace test + +#include <boost/core/lightweight_test.hpp> +#include <string> + +int main() +{ + test::check< + boost::parameter::parameters<test::tag::x,test::tag::y> + >((test::_x = 0, test::_y = 1), 0, 1); + + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::required< + boost::parameter::deduced<test::tag::y> + , test::predicate<int> + > + , boost::parameter::optional< + boost::parameter::deduced<test::tag::z> + , test::predicate<std::string> + > + > + >( + ( + test::_x = 0 + , test::_y = test::not_present + , test::_z = std::string("foo") + ) + , test::_x = 0 + , std::string("foo") + ); + + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::required< + boost::parameter::deduced<test::tag::y> + , test::predicate<int> + > + , boost::parameter::optional< + boost::parameter::deduced<test::tag::z> + , test::predicate<std::string> + > + > + >( + (test::_x = 0, test::_y = 1, test::_z = std::string("foo")) + , 0 + , std::string("foo") + , 1 + ); + + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::required< + boost::parameter::deduced<test::tag::y> + , test::predicate<int> + > + , boost::parameter::optional< + boost::parameter::deduced<test::tag::z> + , test::predicate<std::string> + > + > + >( + (test::_x = 0, test::_y = 1, test::_z = std::string("foo")) + , 0 + , 1 + , std::string("foo") + ); + + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::required< + boost::parameter::deduced<test::tag::y> + , test::predicate<int> + > + , boost::parameter::optional< + boost::parameter::deduced<test::tag::z> + , test::predicate<std::string> + > + > + >( + (test::_x = 0, test::_y = 1, test::_z = std::string("foo")) + , 0 + , test::_y = 1 + , std::string("foo") + ); + + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::required< + boost::parameter::deduced<test::tag::y> + , test::predicate<int> + > + , boost::parameter::optional< + boost::parameter::deduced<test::tag::z> + , test::predicate<std::string> + > + > + >( + (test::_x = 0, test::_y = 1, test::_z = std::string("foo")) + , test::_z = std::string("foo") + , test::_x = 0 + , 1 + ); + +#if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE) + // Fails because boost::parameter::aux::make_arg_list<> evaluates + // boost::parameter::aux::is_named_argument<> to boost::mpl::false_ + // for static_cast<long*>(BOOST_PARAMETER_AUX_PP_NULLPTR). + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::required< + boost::parameter::deduced<test::tag::y> + , test::predicate<int> + > + , boost::parameter::optional< + boost::parameter::deduced<test::tag::z> + , test::predicate<std::string> + > + > + >( + (test::_x = 0, test::_y = 1, test::_z = std::string("foo")) + , test::_x = 0 + , static_cast<long*>(BOOST_PARAMETER_AUX_PP_NULLPTR) + , 1 + ); +#endif + + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/deduced.hpp b/src/boost/libs/parameter/test/deduced.hpp new file mode 100644 index 000000000..551bf1e59 --- /dev/null +++ b/src/boost/libs/parameter/test/deduced.hpp @@ -0,0 +1,131 @@ +// Copyright Daniel Wallin 2006. +// Copyright Cromwell D. Enage 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_DEDUCED_060920_HPP +#define BOOST_DEDUCED_060920_HPP + +#include <boost/parameter/config.hpp> +#include "basics.hpp" + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/mp11/map.hpp> +#include <boost/mp11/algorithm.hpp> +#else +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/for_each.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/type_traits/is_same.hpp> +#endif + +namespace test { + + struct not_present_tag + { + }; + + not_present_tag not_present; + + template <typename E, typename ArgPack> + class assert_expected + { + E const& _expected; + ArgPack const& _args; + + public: + assert_expected(E const& e, ArgPack const& args_) + : _expected(e), _args(args_) + { + } + + template <typename T> + static bool check_not_present(T const&) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_same<T,test::not_present_tag>::value + , "T == test::not_present_tag" + ); +#else + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same<T,test::not_present_tag> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif + return true; + } + + template <typename K> + bool check1(K const& k, test::not_present_tag const& t, long) const + { + return assert_expected<E,ArgPack>::check_not_present( + this->_args[k | t] + ); + } + + template <typename K, typename Expected> + bool check1(K const& k, Expected const& e, int) const + { + return test::equal(this->_args[k], e); + } + + template <typename K> +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + void operator()(K&&) const +#else + void operator()(K) const +#endif + { + boost::parameter::keyword<K> const& + k = boost::parameter::keyword<K>::instance; + BOOST_TEST(this->check1(k, this->_expected[k], 0L)); + } + }; + + template <typename E, typename A> + void check0(E const& e, A const& args) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + boost::mp11::mp_for_each<boost::mp11::mp_map_keys<E> >( + test::assert_expected<E,A>(e, args) + ); +#else + boost::mpl::for_each<E>(test::assert_expected<E,A>(e, args)); +#endif + } + +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + template <typename P, typename E, typename ...Args> + void check(E const& e, Args const&... args) + { + test::check0(e, P()(args...)); + } +#else + template <typename P, typename E, typename A0> + void check(E const& e, A0 const& a0) + { + test::check0(e, P()(a0)); + } + + template <typename P, typename E, typename A0, typename A1> + void check(E const& e, A0 const& a0, A1 const& a1) + { + test::check0(e, P()(a0, a1)); + } + + template <typename P, typename E, typename A0, typename A1, typename A2> + void check(E const& e, A0 const& a0, A1 const& a1, A2 const& a2) + { + test::check0(e, P()(a0, a1, a2)); + } +#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING +} // namespace test + +#endif // include guard + diff --git a/src/boost/libs/parameter/test/deduced_dependent_predicate.cpp b/src/boost/libs/parameter/test/deduced_dependent_predicate.cpp new file mode 100644 index 000000000..a6dc62a0e --- /dev/null +++ b/src/boost/libs/parameter/test/deduced_dependent_predicate.cpp @@ -0,0 +1,162 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> +#include <boost/parameter/parameters.hpp> +#include <boost/parameter/name.hpp> +#include <boost/parameter/binding.hpp> +#include "deduced.hpp" + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/mp11/bind.hpp> +#include <boost/mp11/utility.hpp> +#include <type_traits> +#else +#include <boost/mpl/bool.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_convertible.hpp> +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +#include <boost/type_traits/remove_reference.hpp> +#else +#include <boost/type_traits/add_lvalue_reference.hpp> +#endif // Borland workarounds needed +#endif // BOOST_PARAMETER_CAN_USE_MP11 + +namespace test { + + BOOST_PARAMETER_NAME(x) + BOOST_PARAMETER_NAME(y) + BOOST_PARAMETER_NAME(z) +} // namespace test + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::optional< + boost::parameter::deduced<test::tag::y> +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + , boost::mp11::mp_bind< + std::is_same + , boost::mp11::_1 + , boost::mp11::mp_bind< + test::tag::x::binding_fn + , boost::mp11::_2 + > + > +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + , boost::mpl::if_< + boost::is_same< +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + boost::mpl::_1 + , boost::remove_reference< + boost::parameter::binding< + boost::mpl::_2 + , test::tag::x + > + > +#else + boost::add_lvalue_reference<boost::mpl::_1> + , boost::parameter::binding<boost::mpl::_2,test::tag::x> +#endif // Borland workarounds needed + > + , boost::mpl::true_ + , boost::mpl::false_ + > +#endif // BOOST_PARAMETER_CAN_USE_MP11 + > + > + >((test::_x = 0, test::_y = 1), 0, 1); + + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::optional< + boost::parameter::deduced<test::tag::y> +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + , boost::mp11::mp_bind< + std::is_same + , boost::mp11::_1 + , boost::mp11::mp_bind< + test::tag::x::binding_fn + , boost::mp11::_2 + > + > +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + , boost::mpl::if_< + boost::is_same< +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + boost::mpl::_1 + , boost::remove_reference< + boost::parameter::binding< + boost::mpl::_2 + , test::tag::x + > + > +#else + boost::add_lvalue_reference<boost::mpl::_1> + , boost::parameter::binding<boost::mpl::_2,test::tag::x> +#endif // Borland workarounds needed + > + , boost::mpl::true_ + , boost::mpl::false_ + > +#endif // BOOST_PARAMETER_CAN_USE_MP11 + > + > + >((test::_x = 0U, test::_y = 1U), 0U, 1U); + + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::optional< + boost::parameter::deduced<test::tag::y> +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + , boost::mp11::mp_bind< + std::is_convertible + , boost::mp11::_1 + , boost::mp11::mp_bind_q<test::tag::x,boost::mp11::_2> + > +#else + , boost::mpl::if_< + boost::is_convertible<boost::mpl::_1,test::tag::x::_> + , boost::mpl::true_ + , boost::mpl::false_ + > +#endif + > + > + >((test::_x = 0, test::_y = 1), 0, 1); + + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::optional< + boost::parameter::deduced<test::tag::y> +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + , boost::mp11::mp_bind< + std::is_convertible + , boost::mp11::_1 + , boost::mp11::mp_bind_q<test::tag::x,boost::mp11::_2> + > +#else + , boost::mpl::if_< + boost::is_convertible<boost::mpl::_1,test::tag::x::_1> + , boost::mpl::true_ + , boost::mpl::false_ + > +#endif + > + > + >((test::_x = 0U, test::_y = 1U), 0U, 1U); + + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/deduced_unmatched_arg.cpp b/src/boost/libs/parameter/test/deduced_unmatched_arg.cpp new file mode 100644 index 000000000..aa4644717 --- /dev/null +++ b/src/boost/libs/parameter/test/deduced_unmatched_arg.cpp @@ -0,0 +1,25 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/parameters.hpp> +#include <boost/parameter/optional.hpp> +#include <boost/parameter/deduced.hpp> +#include <boost/parameter/name.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_convertible.hpp> + +BOOST_PARAMETER_NAME(x) + +int main() +{ + boost::parameter::parameters< + boost::parameter::optional< + boost::parameter::deduced<tag::x> + , boost::is_convertible<boost::mpl::_,int> + > + >()("foo"); + return 0; +} + diff --git a/src/boost/libs/parameter/test/duplicates.cpp b/src/boost/libs/parameter/test/duplicates.cpp new file mode 100644 index 000000000..413f1b9a7 --- /dev/null +++ b/src/boost/libs/parameter/test/duplicates.cpp @@ -0,0 +1,28 @@ +// Copyright Daniel Wallin 2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter.hpp> +#include "basics.hpp" + +namespace test { + + template <typename Params> + void f(Params const &) + { + } +} + +int main() +{ + test::f(( + test::_name = 1 + , test::_value = 1 + , test::_index = 1 + , test::_tester = 1 + , test::_value = 1 // repeated keyword: should not compile + )); + return 0; +} + diff --git a/src/boost/libs/parameter/test/earwicker.cpp b/src/boost/libs/parameter/test/earwicker.cpp new file mode 100644 index 000000000..16c87123e --- /dev/null +++ b/src/boost/libs/parameter/test/earwicker.cpp @@ -0,0 +1,125 @@ +// Copyright David Abrahams, Daniel Wallin 2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> + +#if (BOOST_PARAMETER_MAX_ARITY < 4) +#error Define BOOST_PARAMETER_MAX_ARITY as 4 or greater. +#endif +#if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ + (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 5) +#error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \ +as 5 or greater. +#endif + +#include <boost/parameter/name.hpp> + +namespace test { + + BOOST_PARAMETER_NAME(w) + BOOST_PARAMETER_NAME(x) + BOOST_PARAMETER_NAME(y) + BOOST_PARAMETER_NAME(z) +} // namespace test + +#if !defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_convertible.hpp> + +namespace test { + + struct f_predicate + { + template <typename T, typename Args> + struct apply + : boost::mpl::if_< + boost::is_convertible<T,int> + , boost::mpl::true_ + , boost::mpl::false_ + > + { + }; + }; +} // namespace test + +#endif // BOOST_PARAMETER_CAN_USE_MP11 + +#include <boost/parameter/parameters.hpp> + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/mp11/bind.hpp> +#include <type_traits> +#endif + +namespace test { + + struct f_parameters // vc6 is happier with inheritance than with a typedef + : boost::parameter::parameters< + boost::parameter::required<test::tag::w> +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + , boost::parameter::optional< + test::tag::x + , boost::mp11::mp_bind<std::is_convertible,boost::mp11::_1,int> + > + , boost::parameter::optional< + test::tag::y + , boost::mp11::mp_bind<std::is_convertible,boost::mp11::_1,int> + > + , boost::parameter::optional< + test::tag::z + , boost::mp11::mp_bind<std::is_convertible,boost::mp11::_1,int> + > +#else + , boost::parameter::optional<test::tag::x,test::f_predicate> + , boost::parameter::optional<test::tag::y,test::f_predicate> + , boost::parameter::optional<test::tag::z,test::f_predicate> +#endif // BOOST_PARAMETER_CAN_USE_MP11 + > + { + }; +} // namespace test + +#include <boost/parameter/macros.hpp> +#include <boost/core/lightweight_test.hpp> + +namespace test { + +#if defined(BOOST_NO_VOID_RETURNS) + BOOST_PARAMETER_FUN(int, f, 1, 4, f_parameters) +#else + BOOST_PARAMETER_FUN(void, f, 1, 4, f_parameters) +#endif + { + BOOST_TEST_EQ(p[test::_w][0], p[test::_x | -1]); + BOOST_TEST_EQ(p[test::_w][1], p[test::_y | -2]); + BOOST_TEST_EQ(p[test::_w][2], p[test::_z | -3]); +#if defined(BOOST_NO_VOID_RETURNS) + return 0; +#endif + } +} // namespace test + +int main() +{ + int a[3]; + a[0] = 1; + a[1] = 2; + a[2] = 3; + test::f(test::_x = 1, test::_y = 2, test::_z = 3, test::_w = a); + a[1] = -2; + a[2] = -3; + test::f(test::_x = 1, test::_w = a); + a[0] = -1; + a[1] = 2; + test::f(test::_y = 2, test::_w = a); + a[1] = -2; + a[2] = 3; + test::f(test::_z = 3, test::_w = a); + a[0] = 1; + test::f(test::_z = 3, test::_x = 1, test::_w = a); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/efficiency.cpp b/src/boost/libs/parameter/test/efficiency.cpp new file mode 100644 index 000000000..ddfb62a17 --- /dev/null +++ b/src/boost/libs/parameter/test/efficiency.cpp @@ -0,0 +1,195 @@ +// Copyright David Abrahams, Matthias Troyer, Michael Gauckler 2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/name.hpp> +#include <boost/config/workaround.hpp> +#include <boost/timer.hpp> +#include <iostream> + +namespace test { + + // + // This test measures the abstraction overhead of using the named + // parameter interface. Some actual test results have been recorded + // in timings.txt in this source file's directory, or + // http://www.boost.org/libs/parameter/test/timings.txt. + // + // Caveats: + // + // 1. This test penalizes the named parameter library slightly, by + // passing two arguments through the named interface, while + // only passing one through the plain C++ interface. + // + // 2. This test does not measure the case where an ArgumentPack is + // so large that it doesn't fit in the L1 cache. + // + // 3. Although we've tried to make this test as general as possible, + // we are targeting it at a specific application. Where that + // affects design decisions, we've noted it below in ***...***. + // + // 4. The first time you run this program, the time may not be + // representative because of disk and memory cache effects, so + // always run it multiple times and ignore the first + // measurement. This approach will also allow you to estimate + // the statistical error of your test by observing the + // variation in the valid times. + // + // 5. Try to run this program on a machine that's otherwise idle, + // or other processes and even device hardware interrupts may + // interfere by causing caches to be flushed. + + // Accumulator function object with plain C++ interface + template <typename T> + struct plain_weight_running_total + { + plain_weight_running_total() +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + : sum(T()) +#else + : sum() +#endif + { + } + + void operator()(T w) + { + this->sum += w; + } + + T sum; + }; + + BOOST_PARAMETER_NAME(weight) + BOOST_PARAMETER_NAME(value) + + // Accumulator function object with named parameter interface + template <typename T> + struct named_param_weight_running_total + { + named_param_weight_running_total() +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + : sum(T()) +#else + : sum() +#endif + { + } + + template <typename ArgumentPack> + void operator()(ArgumentPack const& variates) + { + this->sum += variates[test::_weight]; + } + + T sum; + }; + + // This value is required to ensure that a smart compiler's dead code + // elimination doesn't optimize away anything we're testing. We'll use it + // to compute the return code of the executable to make sure it's needed. + double live_code; + + // Call objects of the given Accumulator type repeatedly + // with x an argument. + template <typename Accumulator, typename Arg> + void hammer(Arg const& x, long const repeats) + { + // Strategy: because the sum in an accumulator after each call + // depends on the previous value of the sum, the CPU's pipeline + // might be stalled while waiting for the previous addition to + // complete. Therefore, we allocate an array of accumulators, + // and update them in sequence, so that there's no dependency + // between adjacent addition operations. + // + // Additionally, if there were only one accumulator, the compiler or + // CPU might decide to update the value in a register rather than + // writing it back to memory. We want each operation to at least + // update the L1 cache. *** Note: This concern is specific to the + // particular application at which we're targeting the test. *** + + // This has to be at least as large as the number of simultaneous + // accumulations that can be executing in the compiler pipeline. A + // safe number here is larger than the machine's maximum pipeline + // depth. If you want to test the L2 or L3 cache, or main memory, + // you can increase the size of this array. 1024 is an upper limit + // on the pipeline depth of current vector machines. + std::size_t const number_of_accumulators = 1024; + + Accumulator a[number_of_accumulators]; + + for (long iteration = 0; iteration < repeats; ++iteration) + { + for (Accumulator* ap = a; ap < a + number_of_accumulators; ++ap) + { + (*ap)(x); + } + } + + // Accumulate all the partial sums to avoid dead code elimination. + for (Accumulator* ap = a; ap < a + number_of_accumulators; ++ap) + { + test::live_code += ap->sum; + } + } + + // Measure the time required to hammer accumulators of the given + // type with the argument x. + template <typename Accumulator, typename T> + double measure(T const& x, long const repeats) + { + // Hammer accumulators a couple of times to ensure the instruction + // cache is full of our test code, and that we don't measure the cost + // of a page fault for accessing the data page containing the memory + // where the accumulators will be allocated. + test::hammer<Accumulator>(x, repeats); + test::hammer<Accumulator>(x, repeats); + + // Now start a timer. + boost::timer time; + test::hammer<Accumulator>(x, repeats); // This time, we'll measure. + return time.elapsed(); + } +} + +int main() +{ + // First decide how many repetitions to measure. + long repeats = 100; + double measured = 0; + + while (measured < 1.0 && repeats <= 10000000) + { + repeats *= 10; + + boost::timer time; + + test::hammer<test::plain_weight_running_total<double> >(.1, repeats); + test::hammer<test::named_param_weight_running_total<double> >( + (test::_weight = .1, test::_value = .2), repeats + ); + + measured = time.elapsed(); + } + + std::cout + << "plain time: " + << test::measure<test::plain_weight_running_total<double> >( + .1, repeats + ) + << std::endl; + + std::cout + << "named parameter time: " + << test::measure<test::named_param_weight_running_total<double> >( + (test::_weight = .1, test::_value = .2), repeats + ) + << std::endl; + + // This is ultimately responsible for preventing all the test code + // from being optimized away. Change this to return 0 and you + // unplug the whole test's life support system. + return test::live_code < 0.; +} + diff --git a/src/boost/libs/parameter/test/evaluate_category.cpp b/src/boost/libs/parameter/test/evaluate_category.cpp new file mode 100644 index 000000000..73cab9f7a --- /dev/null +++ b/src/boost/libs/parameter/test/evaluate_category.cpp @@ -0,0 +1,350 @@ +// Copyright Cromwell D. Enage 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> + +#if (BOOST_PARAMETER_MAX_ARITY < 4) +#error Define BOOST_PARAMETER_MAX_ARITY as 4 or greater. +#endif +#if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ + (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 5) +#error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \ +as 5 or greater. +#endif + +#include <boost/parameter/name.hpp> + +namespace test { + + BOOST_PARAMETER_NAME((_lrc0, keywords) in(lrc0)) + BOOST_PARAMETER_NAME((_lr0, keywords) in_out(lr0)) + BOOST_PARAMETER_NAME((_rrc0, keywords) in(rrc0)) +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_PARAMETER_NAME((_rr0, keywords) consume(rr0)) +#else + BOOST_PARAMETER_NAME((_rr0, keywords) rr0) +#endif +} // namespace test + +#include <boost/parameter/parameters.hpp> +#include <boost/parameter/required.hpp> + +namespace test { + + struct f_parameters + : boost::parameter::parameters< + boost::parameter::required<test::keywords::lrc0> + , boost::parameter::required<test::keywords::lr0> + , boost::parameter::required<test::keywords::rrc0> + , boost::parameter::required<test::keywords::rr0> + > + { + }; +} // namespace test + +#include <boost/core/lightweight_test.hpp> +#include "evaluate_category.hpp" + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <type_traits> +#else +#include <boost/type_traits/is_scalar.hpp> +#endif + +namespace test { + + template <typename T> + struct B + { + template <typename Args> + static void evaluate(Args const& args) + { + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::A<T>::evaluate_category(args[test::_lrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::A<T>::evaluate_category(args[test::_lr0]) + ); +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + if (std::is_scalar<T>::value) +#else + if (boost::is_scalar<T>::value) +#endif + { + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::A<T>::evaluate_category(args[test::_rrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::A<T>::evaluate_category(args[test::_rr0]) + ); + } + else + { + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::A<T>::evaluate_category(args[test::_rrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference + , test::A<T>::evaluate_category(args[test::_rr0]) + ); + } +#else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::A<T>::evaluate_category(args[test::_rrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::A<T>::evaluate_category(args[test::_rr0]) + ); +#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING + } + }; +} // namespace test + +#include <boost/parameter/deduced.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_convertible.hpp> + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/mp11/bind.hpp> +#endif + +namespace test { + + struct e_parameters + : boost::parameter::parameters< + boost::parameter::required< + boost::parameter::deduced<test::keywords::lrc0> +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + , boost::mp11::mp_bind< + std::is_convertible + , boost::mp11::_1 + , float + > +#else + , boost::mpl::if_< + boost::is_convertible<boost::mpl::_1,float> + , boost::mpl::true_ + , boost::mpl::false_ + > +#endif + > + , boost::parameter::required< + boost::parameter::deduced<test::keywords::lr0> + , boost::mpl::if_< + boost::is_convertible<boost::mpl::_1,char const*> + , boost::mpl::true_ + , boost::mpl::false_ + > + > + , boost::parameter::required< + boost::parameter::deduced<test::keywords::rr0> + , test::string_predicate<test::keywords::lr0> + > + > + { + }; +} // namespace test + +#include <boost/parameter/value_type.hpp> + +#if !defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/type_traits/remove_const.hpp> +#endif + +namespace test { + + struct E + { + template <typename Args> + static void evaluate(Args const& args) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename std::remove_const< + typename boost::parameter::value_type< + Args + , test::keywords::lrc0 + >::type + >::type + >::evaluate_category(args[test::_lrc0]) + )); + BOOST_TEST(( + test::passed_by_lvalue_reference == test::A< + typename std::remove_const< + typename boost::parameter::value_type< + Args + , test::keywords::lr0 + >::type + >::type + >::evaluate_category(args[test::_lr0]) + )); +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::keywords::lrc0 + >::type + >::type + >::evaluate_category(args[test::_lrc0]) + )); + BOOST_TEST(( + test::passed_by_lvalue_reference == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::keywords::lr0 + >::type + >::type + >::evaluate_category(args[test::_lr0]) + )); +#endif // BOOST_PARAMETER_CAN_USE_MP11 + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + BOOST_TEST(( + test::passed_by_rvalue_reference == test::A< + typename std::remove_const< + typename boost::parameter::value_type< + Args + , test::keywords::rr0 + >::type + >::type + >::evaluate_category(args[test::_rr0]) + )); +#elif defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST(( + test::passed_by_rvalue_reference == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::keywords::rr0 + >::type + >::type + >::evaluate_category(args[test::_rr0]) + )); +#else // no MP11 or perfect forwarding support + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::keywords::rr0 + >::type + >::type + >::evaluate_category(args[test::_rr0]) + )); +#endif // MP11 or perfect forwarding support + } + }; +} // namespace test + +int main() +{ + test::B<float>::evaluate( + test::f_parameters()( + test::lvalue_const_float() + , test::lvalue_float() + , test::rvalue_const_float() + , test::rvalue_float() + ) + ); + test::B<char const*>::evaluate( + test::f_parameters()( + test::lvalue_const_char_ptr() + , test::lvalue_char_ptr() + , test::rvalue_const_char_ptr() + , test::rvalue_char_ptr() + ) + ); + test::B<std::string>::evaluate( + test::f_parameters()( + test::lvalue_const_str() + , test::lvalue_str() + , test::rvalue_const_str() + , test::rvalue_str() + ) + ); + test::B<float>::evaluate(( + test::_lr0 = test::lvalue_float() + , test::_rrc0 = test::rvalue_const_float() + , test::_rr0 = test::rvalue_float() + , test::_lrc0 = test::lvalue_const_float() + )); + test::B<char const*>::evaluate(( + test::_lr0 = test::lvalue_char_ptr() + , test::_rrc0 = test::rvalue_const_char_ptr() + , test::_rr0 = test::rvalue_char_ptr() + , test::_lrc0 = test::lvalue_const_char_ptr() + )); + test::B<std::string>::evaluate(( + test::_lr0 = test::lvalue_str() + , test::_rrc0 = test::rvalue_const_str() + , test::_rr0 = test::rvalue_str() + , test::_lrc0 = test::lvalue_const_str() + )); + + char baz_arr[4] = "qux"; + typedef char char_arr[4]; + +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1800) + // MSVC-12+ treats static_cast<char_arr&&>(baz_arr) as an lvalue. +#else + test::B<char_arr>::evaluate( + test::f_parameters()( + "crg" + , baz_arr +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + , static_cast<char_arr const&&>("uir") + , static_cast<char_arr&&>(baz_arr) +#else + , "grl" + , "grp" +#endif + ) + ); + test::B<char_arr>::evaluate(( + test::_lr0 = baz_arr +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + , test::_rrc0 = static_cast<char_arr const&&>("wld") + , test::_rr0 = static_cast<char_arr&&>(baz_arr) +#else + , test::_rrc0 = "frd" + , test::_rr0 = "plg" +#endif + , test::_lrc0 = "mos" + )); +#endif // MSVC-12+ + + test::E::evaluate( + test::e_parameters()( + test::lvalue_char_ptr() + , test::rvalue_str() + , test::lvalue_const_float() + ) + ); + test::E::evaluate( + test::e_parameters()( + test::rvalue_str() + , test::lvalue_const_float() + , test::lvalue_char_ptr() + ) + ); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/evaluate_category.hpp b/src/boost/libs/parameter/test/evaluate_category.hpp new file mode 100644 index 000000000..d5ddbada9 --- /dev/null +++ b/src/boost/libs/parameter/test/evaluate_category.hpp @@ -0,0 +1,290 @@ +// Copyright Cromwell D. Enage 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef LIBS_PARAMETER_TEST_EVALUTE_CATEGORY_HPP +#define LIBS_PARAMETER_TEST_EVALUTE_CATEGORY_HPP + +namespace test { + + enum invoked + { + passed_by_lvalue_reference_to_const + , passed_by_lvalue_reference + , passed_by_rvalue_reference_to_const + , passed_by_rvalue_reference + }; + + float rvalue_float() + { + return 0.0f; + } + + float const rvalue_const_float() + { + return 0.0f; + } + + float& lvalue_float() + { + static float lfloat = 0.0f; + return lfloat; + } + + float const& lvalue_const_float() + { + static float const clfloat = 0.0f; + return clfloat; + } + + char const* rvalue_char_ptr() + { + return "foo"; + } + + char const* const rvalue_const_char_ptr() + { + return "foo"; + } + + char const*& lvalue_char_ptr() + { + static char const* larr = "foo"; + return larr; + } + + char const* const& lvalue_const_char_ptr() + { + static char const* const clarr = "foo"; + return clarr; + } +} // namespace test + +#include <string> + +namespace test { + + std::string rvalue_str() + { + return std::string("bar"); + } + + std::string const rvalue_const_str() + { + return std::string("bar"); + } + + std::string& lvalue_str() + { + static std::string lstr = std::string("bar"); + return lstr; + } + + std::string const& lvalue_const_str() + { + static std::string const clstr = std::string("bar"); + return clstr; + } +} // namespace test + +#include <bitset> + +namespace test { + + template <std::size_t N> + std::bitset<N + 1> rvalue_bitset() + { + return std::bitset<N + 1>(); + } + + template <std::size_t N> + std::bitset<N + 1> const rvalue_const_bitset() + { + return std::bitset<N + 1>(); + } + + template <std::size_t N> + std::bitset<N + 1>& lvalue_bitset() + { + static std::bitset<N + 1> lset = std::bitset<N + 1>(); + return lset; + } + + template <std::size_t N> + std::bitset<N + 1> const& lvalue_const_bitset() + { + static std::bitset<N + 1> const clset = std::bitset<N + 1>(); + return clset; + } + + template <std::size_t N> + struct lvalue_bitset_function + { + typedef std::bitset<N + 1>& result_type; + + result_type operator()() const + { + return test::lvalue_bitset<N>(); + } + }; + + template <std::size_t N> + struct lvalue_const_bitset_function + { + typedef std::bitset<N + 1> const& result_type; + + result_type operator()() const + { + return test::lvalue_const_bitset<N>(); + } + }; + + template <std::size_t N> + struct rvalue_bitset_function + { + typedef std::bitset<N + 1> result_type; + + result_type operator()() const + { + return test::rvalue_bitset<N>(); + } + }; + + template <std::size_t N> + struct rvalue_const_bitset_function + { + typedef std::bitset<N + 1> const result_type; + + result_type operator()() const + { + return test::rvalue_const_bitset<N>(); + } + }; +} // namespace test + +#include <boost/parameter/config.hpp> + +namespace test { + + template <typename T> + struct A + { + static test::invoked evaluate_category(T const&) + { + return test::passed_by_lvalue_reference_to_const; + } + + static test::invoked evaluate_category(T&) + { + return test::passed_by_lvalue_reference; + } + +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + static test::invoked evaluate_category(T const&&) + { + return test::passed_by_rvalue_reference_to_const; + } + + static test::invoked evaluate_category(T&&) + { + return test::passed_by_rvalue_reference; + } +#endif + }; + + struct U + { + template <std::size_t N> + static test::invoked evaluate_category(std::bitset<N + 1> const&) + { + return test::passed_by_lvalue_reference_to_const; + } + + template <std::size_t N> + static test::invoked evaluate_category(std::bitset<N + 1>&) + { + return test::passed_by_lvalue_reference; + } + +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + template <std::size_t N> + static test::invoked evaluate_category(std::bitset<N + 1> const&&) + { + return test::passed_by_rvalue_reference_to_const; + } + + template <std::size_t N> + static test::invoked evaluate_category(std::bitset<N + 1>&&) + { + return test::passed_by_rvalue_reference; + } +#endif + }; +} // namespace test + +#include <boost/parameter/value_type.hpp> + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <type_traits> +#else +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_convertible.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/type_traits/remove_pointer.hpp> +#endif + +namespace test { + + template <typename CharConstPtrParamTag> + struct string_predicate + { + template <typename Arg, typename Args> +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + using fn = std::is_convertible< + Arg + , std::basic_string< + typename std::remove_const< + typename std::remove_pointer< + typename boost::parameter::value_type< + Args + , CharConstPtrParamTag +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE) + , char const* +#endif + >::type + >::type + >::type + > + >; +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + struct apply + : boost::mpl::if_< + boost::is_convertible< + Arg + , std::basic_string< + typename boost::remove_const< + typename boost::remove_pointer< + typename boost::parameter::value_type< + Args + , CharConstPtrParamTag +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE) + , char const* +#endif + >::type + >::type + >::type + > + > + , boost::mpl::true_ + , boost::mpl::false_ + > + { + }; +#endif // BOOST_PARAMETER_CAN_USE_MP11 + }; +} // namespace test + +#endif // include guard + diff --git a/src/boost/libs/parameter/test/evaluate_category_10.cpp b/src/boost/libs/parameter/test/evaluate_category_10.cpp new file mode 100644 index 000000000..efc82582c --- /dev/null +++ b/src/boost/libs/parameter/test/evaluate_category_10.cpp @@ -0,0 +1,268 @@ +// Copyright Cromwell D. Enage 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> + +#if ( \ + defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ + !defined(__MINGW32__) \ + ) || ( \ + !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ + (10 < BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY) \ + ) +#if (BOOST_PARAMETER_MAX_ARITY < 10) +#error Define BOOST_PARAMETER_MAX_ARITY as 10 or greater. +#endif +#endif + +#include <boost/parameter/name.hpp> + +namespace test { + + BOOST_PARAMETER_NAME((_lrc0, keywords) in(lrc0)) + BOOST_PARAMETER_NAME((_lr0, keywords) in_out(lr0)) + BOOST_PARAMETER_NAME((_rrc0, keywords) in(rrc0)) +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_PARAMETER_NAME((_rr0, keywords) consume(rr0)) +#else + BOOST_PARAMETER_NAME((_rr0, keywords) rr0) +#endif + BOOST_PARAMETER_NAME((_lrc1, keywords) in(lrc1)) + BOOST_PARAMETER_NAME((_lr1, keywords) out(lr1)) + BOOST_PARAMETER_NAME((_rrc1, keywords) in(rrc1)) + BOOST_PARAMETER_NAME((_lrc2, keywords) in(lrc2)) + BOOST_PARAMETER_NAME((_lr2, keywords) out(lr2)) + BOOST_PARAMETER_NAME((_rr2, keywords) rr2) +} // namespace test + +#if ( \ + defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ + !defined(__MINGW32__) \ + ) || ( \ + !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ + (10 < BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY) \ + ) +#include <boost/parameter/parameters.hpp> +#include <boost/parameter/required.hpp> +#include <boost/parameter/optional.hpp> + +namespace test { + + struct g_parameters + : boost::parameter::parameters< + boost::parameter::required<test::keywords::lrc0> + , boost::parameter::required<test::keywords::lr0> + , boost::parameter::required<test::keywords::rrc0> + , boost::parameter::required<test::keywords::rr0> + , boost::parameter::required<test::keywords::lrc1> + , boost::parameter::required<test::keywords::lr1> + , boost::parameter::required<test::keywords::rrc1> + , boost::parameter::optional<test::keywords::lrc2> + , boost::parameter::optional<test::keywords::lr2> + , boost::parameter::optional<test::keywords::rr2> + > + { + }; +} // namespace test + +#endif + +#include <boost/core/lightweight_test.hpp> +#include "evaluate_category.hpp" + +namespace test { + + struct C + { + template <typename Args> + static void evaluate(Args const& args) + { + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<0>(args[test::_lrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::U::evaluate_category<0>(args[test::_lr0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<1>(args[test::_lrc1]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::U::evaluate_category<1>(args[test::_lr1]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<2>( + args[test::_lrc2 | test::lvalue_const_bitset<2>()] + ) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::U::evaluate_category<2>( + args[test::_lr2 || test::lvalue_bitset_function<2>()] + ) + ); +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<0>(args[test::_rrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference + , test::U::evaluate_category<0>(args[test::_rr0]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<1>(args[test::_rrc1]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference + , test::U::evaluate_category<2>( + args[test::_rr2 || test::rvalue_bitset_function<2>()] + ) + ); +#else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<0>(args[test::_rrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<0>(args[test::_rr0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<1>(args[test::_rrc1]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<2>( + args[test::_rr2 || test::rvalue_bitset_function<2>()] + ) + ); +#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING + } + }; +} // namespace test + +#if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) +#include <boost/parameter/aux_/as_lvalue.hpp> +#endif + +int main() +{ +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) +#if defined(__MINGW32__) + test::C::evaluate(( + test::_rrc1 = test::rvalue_const_bitset<1>() + , test::_lrc0 = test::lvalue_const_bitset<0>() + , test::_lr0 = test::lvalue_bitset<0>() + , test::_rrc0 = test::rvalue_const_bitset<0>() + , test::_rr0 = test::rvalue_bitset<0>() + , test::_lrc1 = test::lvalue_const_bitset<1>() + , test::_lr1 = test::lvalue_bitset<1>() + )); + test::C::evaluate(( + test::_lr0 = test::lvalue_bitset<0>() + , test::_rrc0 = test::rvalue_const_bitset<0>() + , test::_rr0 = test::rvalue_bitset<0>() + , test::_lrc1 = test::lvalue_const_bitset<1>() + , test::_lr1 = test::lvalue_bitset<1>() + , test::_rrc1 = test::rvalue_const_bitset<1>() + , test::_lrc2 = test::lvalue_const_bitset<2>() + , test::_lr2 = test::lvalue_bitset<2>() + , test::_rr2 = test::rvalue_bitset<2>() + , test::_lrc0 = test::lvalue_const_bitset<0>() + )); +#else // !defined(__MINGW32__) + test::C::evaluate( + test::g_parameters()( + test::lvalue_const_bitset<0>() + , test::lvalue_bitset<0>() + , test::rvalue_const_bitset<0>() + , test::rvalue_bitset<0>() + , test::lvalue_const_bitset<1>() + , test::lvalue_bitset<1>() + , test::rvalue_const_bitset<1>() + ) + ); + test::C::evaluate( + test::g_parameters()( + test::lvalue_const_bitset<0>() + , test::lvalue_bitset<0>() + , test::rvalue_const_bitset<0>() + , test::rvalue_bitset<0>() + , test::lvalue_const_bitset<1>() + , test::lvalue_bitset<1>() + , test::rvalue_const_bitset<1>() + , test::lvalue_const_bitset<2>() + , test::lvalue_bitset<2>() + , test::rvalue_bitset<2>() + ) + ); +#endif // __MINGW32__ +#else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) +#if (10 < BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY) + test::C::evaluate( + test::g_parameters()( + test::lvalue_const_bitset<0>() + , test::lvalue_bitset<0>() + , test::rvalue_const_bitset<0>() + , boost::parameter::aux::as_lvalue(test::rvalue_bitset<0>()) + , test::lvalue_const_bitset<1>() + , test::lvalue_bitset<1>() + , test::rvalue_const_bitset<1>() + ) + ); + test::C::evaluate( + test::g_parameters()( + test::lvalue_const_bitset<0>() + , test::lvalue_bitset<0>() + , test::rvalue_const_bitset<0>() + , boost::parameter::aux::as_lvalue(test::rvalue_bitset<0>()) + , test::lvalue_const_bitset<1>() + , test::lvalue_bitset<1>() + , test::rvalue_const_bitset<1>() + , test::lvalue_const_bitset<2>() + , test::lvalue_bitset<2>() + , boost::parameter::aux::as_lvalue(test::rvalue_bitset<2>()) + ) + ); +#else // !(10 < BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY) + test::C::evaluate(( + test::_lrc0 = test::lvalue_const_bitset<0>() + , test::_lr0 = test::lvalue_bitset<0>() + , test::_rrc0 = test::rvalue_const_bitset<0>() + , test::_rr0 = boost::parameter::aux::as_lvalue( + test::rvalue_bitset<0>() + ) + , test::_lrc1 = test::lvalue_const_bitset<1>() + , test::_lr1 = test::lvalue_bitset<1>() + , test::_rrc1 = test::rvalue_const_bitset<1>() + )); + test::C::evaluate(( + test::_lrc0 = test::lvalue_const_bitset<0>() + , test::_lr0 = test::lvalue_bitset<0>() + , test::_rrc0 = test::rvalue_const_bitset<0>() + , test::_rr0 = boost::parameter::aux::as_lvalue( + test::rvalue_bitset<0>() + ) + , test::_lrc1 = test::lvalue_const_bitset<1>() + , test::_lr1 = test::lvalue_bitset<1>() + , test::_rrc1 = test::rvalue_const_bitset<1>() + , test::_lrc2 = test::lvalue_const_bitset<2>() + , test::_lr2 = test::lvalue_bitset<2>() + , test::_rr2 = boost::parameter::aux::as_lvalue( + test::rvalue_bitset<2>() + ) + )); +#endif // (10 < BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY) +#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/evaluate_category_16.cpp b/src/boost/libs/parameter/test/evaluate_category_16.cpp new file mode 100644 index 000000000..d80c7b2bd --- /dev/null +++ b/src/boost/libs/parameter/test/evaluate_category_16.cpp @@ -0,0 +1,248 @@ +// Copyright Cromwell D. Enage 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> + +#if (BOOST_PARAMETER_MAX_ARITY < 16) +#error Define BOOST_PARAMETER_MAX_ARITY as 16 or greater. +#endif + +#include <boost/parameter/name.hpp> + +namespace test { + + BOOST_PARAMETER_NAME((_lrc0, keywords) in(lrc0)) + BOOST_PARAMETER_NAME((_lr1, keywords) out(lr1)) + BOOST_PARAMETER_NAME((_lr2, keywords) out(lr2)) + BOOST_PARAMETER_NAME((_lrc3, keywords) in(lrc3)) + BOOST_PARAMETER_NAME((_lrc4, keywords) in(lrc4)) + BOOST_PARAMETER_NAME((_lr5, keywords) out(lr5)) + BOOST_PARAMETER_NAME((_lr6, keywords) out(lr6)) + BOOST_PARAMETER_NAME((_lrc7, keywords) in(lrc7)) + BOOST_PARAMETER_NAME((_rrc0, keywords) in(rrc0)) + BOOST_PARAMETER_NAME((_rrc1, keywords) in(rrc1)) + BOOST_PARAMETER_NAME((_rrc2, keywords) in(rrc2)) + BOOST_PARAMETER_NAME((_rrc3, keywords) in(rrc3)) + BOOST_PARAMETER_NAME((_rrc4, keywords) in(rrc4)) + BOOST_PARAMETER_NAME((_rrc5, keywords) in(rrc5)) + BOOST_PARAMETER_NAME((_rrc6, keywords) in(rrc6)) + BOOST_PARAMETER_NAME((_rrc7, keywords) in(rrc7)) +} // namespace test + +#include <boost/parameter/parameters.hpp> +#include <boost/parameter/required.hpp> +#include <boost/parameter/optional.hpp> + +namespace test { + + struct h_parameters + : boost::parameter::parameters< + boost::parameter::required<test::keywords::lrc0> + , boost::parameter::required<test::keywords::rrc0> + , boost::parameter::required<test::keywords::lr1> + , boost::parameter::required<test::keywords::rrc1> + , boost::parameter::required<test::keywords::lr2> + , boost::parameter::required<test::keywords::rrc2> + , boost::parameter::required<test::keywords::lrc3> + , boost::parameter::required<test::keywords::rrc3> + , boost::parameter::optional<test::keywords::lrc4> + , boost::parameter::optional<test::keywords::rrc4> + , boost::parameter::optional<test::keywords::lr5> + , boost::parameter::optional<test::keywords::rrc5> + , boost::parameter::optional<test::keywords::lr6> + , boost::parameter::optional<test::keywords::rrc6> + , boost::parameter::optional<test::keywords::lrc7> + , boost::parameter::optional<test::keywords::rrc7> + > + { + }; +} // namespace test + +#include <boost/core/lightweight_test.hpp> +#include "evaluate_category.hpp" + +namespace test { + + struct D + { + template <typename Args> + static void evaluate(Args const& args) + { + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<0>(args[test::_lrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::U::evaluate_category<1>(args[test::_lr1]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::U::evaluate_category<2>(args[test::_lr2]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<3>(args[test::_lrc3]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<4>( + args[test::_lrc4 | test::lvalue_const_bitset<4>()] + ) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::U::evaluate_category<5>( + args[ + test::_lr5 || test::lvalue_bitset_function<5>() + ] + ) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::U::evaluate_category<6>( + args[test::_lr6 | test::lvalue_bitset<6>()] + ) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<7>( + args[ + test::_lrc7 || test::lvalue_const_bitset_function<7>() + ] + ) + ); +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<0>(args[test::_rrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<1>(args[test::_rrc1]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<2>(args[test::_rrc2]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<3>(args[test::_rrc3]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<4>( + args[test::_rrc4 | test::rvalue_const_bitset<4>()] + ) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<5>( + args[ + test::_rrc5 || test::rvalue_const_bitset_function<5>() + ] + ) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<6>( + args[test::_rrc6 | test::rvalue_const_bitset<6>()] + ) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<7>( + args[ + test::_rrc7 || test::rvalue_const_bitset_function<7>() + ] + ) + ); +#else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<0>(args[test::_rrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<1>(args[test::_rrc1]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<2>(args[test::_rrc2]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<3>(args[test::_rrc3]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<4>( + args[test::_rrc4 | test::rvalue_const_bitset<4>()] + ) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<5>( + args[ + test::_rrc5 || test::rvalue_const_bitset_function<5>() + ] + ) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<6>( + args[test::_rrc6 | test::rvalue_const_bitset<6>()] + ) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<7>( + args[ + test::_rrc7 || test::rvalue_const_bitset_function<7>() + ] + ) + ); +#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING + } + }; +} // namespace test + +int main() +{ + test::D::evaluate( + test::h_parameters()( + test::lvalue_const_bitset<0>() + , test::rvalue_const_bitset<0>() + , test::lvalue_bitset<1>() + , test::rvalue_const_bitset<1>() + , test::lvalue_bitset<2>() + , test::rvalue_const_bitset<2>() + , test::lvalue_const_bitset<3>() + , test::rvalue_const_bitset<3>() + ) + ); + test::D::evaluate( + test::h_parameters()( + test::lvalue_const_bitset<0>() + , test::rvalue_const_bitset<0>() + , test::lvalue_bitset<1>() + , test::rvalue_const_bitset<1>() + , test::lvalue_bitset<2>() + , test::rvalue_const_bitset<2>() + , test::lvalue_const_bitset<3>() + , test::rvalue_const_bitset<3>() + , test::lvalue_const_bitset<4>() + , test::rvalue_const_bitset<4>() + , test::lvalue_bitset<5>() + , test::rvalue_const_bitset<5>() + , test::lvalue_bitset<6>() + , test::rvalue_const_bitset<6>() + , test::lvalue_const_bitset<7>() + , test::rvalue_const_bitset<7>() + ) + ); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/function_type_tpl_param.cpp b/src/boost/libs/parameter/test/function_type_tpl_param.cpp new file mode 100644 index 000000000..a741d87d7 --- /dev/null +++ b/src/boost/libs/parameter/test/function_type_tpl_param.cpp @@ -0,0 +1,134 @@ +// Copyright Frank Mori Hess 2009. +// Copyright Cromwell D. Enage 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/template_keyword.hpp> +#include <boost/parameter/parameters.hpp> +#include <boost/parameter/required.hpp> +#include <boost/parameter/value_type.hpp> +#include <boost/parameter/config.hpp> + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) && \ + BOOST_WORKAROUND(BOOST_MSVC, < 1920) +#include <type_traits> +#else +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_same.hpp> +#endif + +namespace test { + namespace keywords { + + BOOST_PARAMETER_TEMPLATE_KEYWORD(function_type) + } // namespace keywords + + template <typename K, typename A> +#if BOOST_WORKAROUND(BOOST_MSVC, < 1920) +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + using X = boost::parameter::value_type< +#else + struct X + : boost::parameter::value_type< +#endif + typename boost::parameter::parameters< + boost::parameter::required<K> + >::BOOST_NESTED_TEMPLATE bind<A>::type + , K +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + >; +#else + > + { + }; +#endif +#else // MSVC-14.2 + struct X + { + typedef typename boost::parameter::value_type< + typename boost::parameter::parameters< + boost::parameter::required<K> + >::BOOST_NESTED_TEMPLATE bind<A>::type + , K + >::type type; + }; +#endif + + template <typename T> +#if BOOST_WORKAROUND(BOOST_MSVC, < 1920) +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + using Y = std::is_same< +#else + struct Y + : boost::mpl::if_< + boost::is_same< +#endif + T + , typename X< + test::keywords::tag::function_type + , test::keywords::function_type<T> + >::type +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + >; +#else + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + { + }; +#endif +#else // MSVC-14.2 + struct Y + { + typedef typename boost::mpl::if_< + boost::is_same< + T + , typename X< + test::keywords::tag::function_type + , test::keywords::function_type<T> + >::type + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type type; + }; +#endif + + struct Z + { + int operator()() const + { + return 0; + } + }; +} // namespace test + +#include <boost/mpl/aux_/test.hpp> + +#if !defined(BOOST_PARAMETER_CAN_USE_MP11) || \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1920) +#include <boost/mpl/assert.hpp> +#endif + +MPL_TEST_CASE() +{ +#if BOOST_WORKAROUND(BOOST_MSVC, < 1920) +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert(test::Y<void()>::value, "void()"); + static_assert(test::Y<test::Z>::value, "test::Z"); + static_assert(test::Y<double(double)>::value, "double(double)"); +#else + BOOST_MPL_ASSERT((test::Y<void()>)); + BOOST_MPL_ASSERT((test::Y<test::Z>)); + BOOST_MPL_ASSERT((test::Y<double(double)>)); +#endif +#else // MSVC-14.2 + BOOST_MPL_ASSERT((test::Y<void()>::type)); + BOOST_MPL_ASSERT((test::Y<test::Z>::type)); + BOOST_MPL_ASSERT((test::Y<double(double)>::type)); +#endif +} + diff --git a/src/boost/libs/parameter/test/literate/README b/src/boost/libs/parameter/test/literate/README new file mode 100644 index 000000000..da7f5d54c --- /dev/null +++ b/src/boost/libs/parameter/test/literate/README @@ -0,0 +1,6 @@ +These tests were extracted from the Boost.Parameter documentation +with: + +python ../../../../tools/litre/tool.py \ + ../../../../libs/parameter/doc/index.rst \ + --dump_dir=. diff --git a/src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp b/src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp new file mode 100644 index 000000000..d80f2f9f0 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp @@ -0,0 +1,61 @@ + +#include <boost/parameter.hpp> +#include <iostream> + +BOOST_PARAMETER_NAME(index) + +template <typename ArgumentPack> +int print_index(ArgumentPack const& args) +{ + std::cout << "index = " << args[_index] << std::endl; + return 0; +} + +BOOST_PARAMETER_NAME(name) + +template <typename ArgumentPack> +int print_name_and_index(ArgumentPack const& args) +{ + std::cout << "name = " << args[_name] << "; "; + return print_index(args); +} + +#include <boost/core/lightweight_test.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_convertible.hpp> + +int main() +{ + int x = print_index(_index = 3); // prints "index = 3" + int y = print_name_and_index((_index = 3, _name = "jones")); + boost::parameter::parameters< + boost::parameter::required< + tag::name + , boost::mpl::if_< + boost::is_convertible<boost::mpl::_,char const*> + , boost::mpl::true_ + , boost::mpl::false_ + > + > + , boost::parameter::optional< + tag::index + , boost::mpl::if_< + boost::is_convertible<boost::mpl::_,int> + , boost::mpl::true_ + , boost::mpl::false_ + > + > + > spec; + char const sam[] = "sam"; + int twelve = 12; + int z0 = print_name_and_index(spec(sam, twelve)); + int z1 = print_name_and_index(spec(_index=12, _name="sam")); + BOOST_TEST(!x); + BOOST_TEST(!y); + BOOST_TEST(!z0); + BOOST_TEST(!z1); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/class-template-skeleton0.cpp b/src/boost/libs/parameter/test/literate/class-template-skeleton0.cpp new file mode 100644 index 000000000..bc8095e97 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/class-template-skeleton0.cpp @@ -0,0 +1,16 @@ + +#include <boost/parameter.hpp> + +namespace boost { namespace python { + + template < + typename A0 + , typename A1 = boost::parameter::void_ + , typename A2 = boost::parameter::void_ + , typename A3 = boost::parameter::void_ + > + struct class_ + { + }; +}} + diff --git a/src/boost/libs/parameter/test/literate/deduced-parameters0.cpp b/src/boost/libs/parameter/test/literate/deduced-parameters0.cpp new file mode 100644 index 000000000..f2e1d4caf --- /dev/null +++ b/src/boost/libs/parameter/test/literate/deduced-parameters0.cpp @@ -0,0 +1,101 @@ + +#include <boost/parameter.hpp> + +BOOST_PARAMETER_NAME(name) +BOOST_PARAMETER_NAME(func) +BOOST_PARAMETER_NAME(docstring) +BOOST_PARAMETER_NAME(keywords) +BOOST_PARAMETER_NAME(policies) + +struct default_call_policies +{ +}; + +struct no_keywords +{ +}; + +struct keywords +{ +}; + +#include <boost/mpl/bool.hpp> + +template <typename T> +struct is_keyword_expression + : boost::mpl::false_ +{ +}; + +template <> +struct is_keyword_expression<keywords> + : boost::mpl::true_ +{ +}; + +default_call_policies some_policies; + +void f() +{ +} + +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/type_traits/is_convertible.hpp> + +char const*& blank_char_ptr() +{ + static char const* larr = ""; + return larr; +} + +BOOST_PARAMETER_FUNCTION( + (bool), def, tag, + (required (name,(char const*)) (func,*) ) // nondeduced + (deduced + (optional + (docstring, (char const*), blank_char_ptr()) + (keywords + // see 5 + , *(is_keyword_expression<boost::mpl::_>) + , no_keywords() + ) + (policies + , *( + boost::mpl::eval_if< + boost::is_convertible<boost::mpl::_,char const*> + , boost::mpl::false_ + , boost::mpl::if_< + // see 5 + is_keyword_expression<boost::mpl::_> + , boost::mpl::false_ + , boost::mpl::true_ + > + > + ) + , default_call_policies() + ) + ) + ) +) +{ + return true; +} + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + char const* f_name = "f"; + def(f_name, &f, some_policies, "Documentation for f"); + def(f_name, &f, "Documentation for f", some_policies); + def( + f_name + , &f + , _policies = some_policies + , "Documentation for f" + ); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/deduced-template-parameters0.cpp b/src/boost/libs/parameter/test/literate/deduced-template-parameters0.cpp new file mode 100644 index 000000000..2fb1cd82b --- /dev/null +++ b/src/boost/libs/parameter/test/literate/deduced-template-parameters0.cpp @@ -0,0 +1,214 @@ + +#include <boost/parameter.hpp> + +namespace boost { namespace python { + + BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type) + BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list) + BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type) + BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable) +}} + +namespace boost { namespace python { + namespace detail { + + struct bases_base + { + }; + } + + template <typename A0 = void, typename A1 = void, typename A2 = void> + struct bases : detail::bases_base + { + }; +}} + +#include <boost/mpl/bool.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/noncopyable.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_base_of.hpp> +#include <boost/type_traits/is_class.hpp> +#include <boost/config.hpp> + +#if !defined(BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION) || \ + !(1 == BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION) +#include <boost/type_traits/is_scalar.hpp> +#endif + +namespace boost { namespace python { + + typedef boost::parameter::parameters< + boost::parameter::required< + tag::class_type +#if defined(BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION) && \ + (1 == BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION) + , boost::mpl::if_< + boost::is_class<boost::mpl::_> + , boost::mpl::true_ + , boost::mpl::false_ + > +#else + , boost::mpl::if_< + boost::is_scalar<boost::mpl::_> + , boost::mpl::false_ + , boost::mpl::true_ + > +#endif + > + , boost::parameter::optional< + boost::parameter::deduced<tag::base_list> + , boost::mpl::if_< + boost::is_base_of<detail::bases_base,boost::mpl::_> + , boost::mpl::true_ + , boost::mpl::false_ + > + > + , boost::parameter::optional< + boost::parameter::deduced<tag::held_type> + , boost::mpl::eval_if< + boost::is_base_of<detail::bases_base,boost::mpl::_> + , boost::mpl::false_ + , boost::mpl::if_< + boost::is_same<boost::noncopyable,boost::mpl::_> + , boost::mpl::false_ + , boost::mpl::true_ + > + > + > + , boost::parameter::optional< + boost::parameter::deduced<tag::copyable> + , boost::mpl::if_< + boost::is_same<boost::noncopyable,boost::mpl::_> + , boost::mpl::true_ + , boost::mpl::false_ + > + > + > class_signature; + + template < + typename A0 + , typename A1 = boost::parameter::void_ + , typename A2 = boost::parameter::void_ + , typename A3 = boost::parameter::void_ + > + struct class_ + { + // Create ArgumentPack + typedef typename boost::python::class_signature::BOOST_NESTED_TEMPLATE + bind<A0,A1,A2,A3>::type args; + + // Extract first logical parameter. + typedef typename boost::parameter::value_type< + args,boost::python::tag::class_type + >::type class_type; + + typedef typename boost::parameter::value_type< + args,boost::python::tag::base_list,boost::python::bases<> + >::type base_list; + + typedef typename boost::parameter::value_type< + args,boost::python::tag::held_type,class_type + >::type held_type; + + typedef typename boost::parameter::value_type< + args,boost::python::tag::copyable,void + >::type copyable; + }; +}} + +struct B +{ +}; + +struct D +{ +}; + +typedef boost::python::class_<B,boost::noncopyable> c1; + +#include <memory> + +#if defined(BOOST_NO_CXX11_SMART_PTR) +typedef boost::python::class_<D,std::auto_ptr<D>,boost::python::bases<B> > c2; +#else +typedef boost::python::class_< + D,std::unique_ptr<D>,boost::python::bases<B> +> c2; +#endif + +#include <boost/mpl/assert.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c1::class_type,B> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c1::base_list,boost::python::bases<> > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c1::held_type,B> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c1::copyable,boost::noncopyable> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c2::class_type,D> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c2::base_list,boost::python::bases<B> > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#if defined(BOOST_NO_CXX11_SMART_PTR) + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c2::held_type,std::auto_ptr<D> > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#else + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c2::held_type,std::unique_ptr<D> > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif // BOOST_NO_CXX11_SMART_PTR + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c2::copyable,void> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +} + diff --git a/src/boost/libs/parameter/test/literate/default-expression-evaluation0.cpp b/src/boost/libs/parameter/test/literate/default-expression-evaluation0.cpp new file mode 100644 index 000000000..87c99d32e --- /dev/null +++ b/src/boost/libs/parameter/test/literate/default-expression-evaluation0.cpp @@ -0,0 +1,48 @@ + +#include <boost/parameter.hpp> +#include <iostream> + +BOOST_PARAMETER_NAME(graph) +BOOST_PARAMETER_NAME(visitor) +BOOST_PARAMETER_NAME(root_vertex) +BOOST_PARAMETER_NAME(index_map) +BOOST_PARAMETER_NAME(color_map) + +#include <boost/graph/depth_first_search.hpp> // for dfs_visitor + +BOOST_PARAMETER_FUNCTION((bool), depth_first_search, tag, + (required + (graph, *) + (visitor, *) + (root_vertex, *) + (index_map, *) + (color_map, *) + ) +) +{ + std::cout << "graph=" << graph; + std::cout << std::endl; + std::cout << "visitor=" << visitor; + std::cout << std::endl; + std::cout << "root_vertex=" << root_vertex; + std::cout << std::endl; + std::cout << "index_map=" << index_map; + std::cout << std::endl; + std::cout << "color_map=" << color_map; + std::cout << std::endl; + return true; +} + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + char const* g = "1"; + depth_first_search(1, 2, 3, 4, 5); + depth_first_search( + g, '2', _color_map = '5' + , _index_map = "4", _root_vertex = "3" + ); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/defining-the-keywords0.cpp b/src/boost/libs/parameter/test/literate/defining-the-keywords0.cpp new file mode 100644 index 000000000..e6525750e --- /dev/null +++ b/src/boost/libs/parameter/test/literate/defining-the-keywords0.cpp @@ -0,0 +1,11 @@ + +#include <boost/parameter/name.hpp> + +namespace graphs { + + BOOST_PARAMETER_NAME(graph) // Note: no semicolon + BOOST_PARAMETER_NAME(visitor) + BOOST_PARAMETER_NAME(root_vertex) + BOOST_PARAMETER_NAME(index_map) + BOOST_PARAMETER_NAME(color_map) +} diff --git a/src/boost/libs/parameter/test/literate/defining-the-keywords1.cpp b/src/boost/libs/parameter/test/literate/defining-the-keywords1.cpp new file mode 100644 index 000000000..8107dce19 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/defining-the-keywords1.cpp @@ -0,0 +1,21 @@ + +#include <boost/parameter/keyword.hpp> + +namespace graphs { + namespace tag { + + // keyword tag type + struct graph + { + typedef boost::parameter::forward_reference qualifier; + }; + } + + namespace // unnamed + { + // A reference to the keyword object + boost::parameter::keyword<tag::graph> const& _graph + = boost::parameter::keyword<tag::graph>::instance; + } +} + diff --git a/src/boost/libs/parameter/test/literate/exercising-the-code-so-far0.cpp b/src/boost/libs/parameter/test/literate/exercising-the-code-so-far0.cpp new file mode 100644 index 000000000..3098f09be --- /dev/null +++ b/src/boost/libs/parameter/test/literate/exercising-the-code-so-far0.cpp @@ -0,0 +1,193 @@ + +#include <boost/parameter.hpp> + +namespace boost { namespace python { + + BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type) + BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list) + BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type) + BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable) + + template <typename B = int> + struct bases + { + }; +}} + +#include <boost/mpl/bool.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/is_sequence.hpp> +#include <boost/type_traits/is_class.hpp> +#include <boost/config.hpp> + +#if !defined(BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION) || \ + !(1 == BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION) +#include <boost/type_traits/is_scalar.hpp> +#endif + +namespace boost { namespace python { + + typedef boost::parameter::parameters< + boost::parameter::required< + tag::class_type +#if defined(BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION) && \ + (1 == BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION) + , boost::mpl::if_< + boost::is_class<boost::mpl::_> + , boost::mpl::true_ + , boost::mpl::false_ + > +#else + , boost::mpl::if_< + boost::is_scalar<boost::mpl::_> + , boost::mpl::false_ + , boost::mpl::true_ + > +#endif + > + , boost::parameter::optional< + tag::base_list + , boost::mpl::is_sequence<boost::mpl::_> + > + , boost::parameter::optional<tag::held_type> + , boost::parameter::optional<tag::copyable> + > class_signature; +}} // namespace boost::python + +namespace boost { namespace python { + + template < + typename A0 + , typename A1 = boost::parameter::void_ + , typename A2 = boost::parameter::void_ + , typename A3 = boost::parameter::void_ + > + struct class_ + { + // Create ArgumentPack + typedef typename class_signature::BOOST_NESTED_TEMPLATE bind< + A0, A1, A2, A3 + >::type args; + + // Extract first logical parameter. + typedef typename boost::parameter::value_type< + args, tag::class_type + >::type class_type; + + typedef typename boost::parameter::value_type< + args, tag::base_list, boost::python::bases<> + >::type base_list; + + typedef typename boost::parameter::value_type< + args, tag::held_type, class_type + >::type held_type; + + typedef typename boost::parameter::value_type< + args, tag::copyable, void + >::type copyable; + }; +}} // namespace boost::python + +struct B +{ +}; + +struct D +{ +}; + +#include <boost/noncopyable.hpp> +#include <memory> + +typedef boost::python::class_< + boost::python::class_type<B> + , boost::python::copyable<boost::noncopyable> +> c1; + +typedef boost::python::class_< + D + , boost::python::held_type< +#if defined(BOOST_NO_CXX11_SMART_PTR) + std::auto_ptr<D> +#else + std::unique_ptr<D> +#endif + > + , boost::python::base_list<boost::python::bases<B> > +> c2; + +#include <boost/type_traits/is_same.hpp> +#include <boost/mpl/aux_/test.hpp> +#include <boost/mpl/assert.hpp> + +MPL_TEST_CASE() +{ + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c1::class_type,B> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c1::base_list,boost::python::bases<> > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c1::held_type,B> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c1::copyable,boost::noncopyable> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c2::class_type,D> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c2::base_list,boost::python::bases<B> > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#if defined(BOOST_NO_CXX11_SMART_PTR) + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c2::held_type,std::auto_ptr<D> > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#else + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c2::held_type,std::unique_ptr<D> > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif // BOOST_NO_CXX11_SMART_PTR + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same<c2::copyable,void> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +} + diff --git a/src/boost/libs/parameter/test/literate/extracting-parameter-types0.cpp b/src/boost/libs/parameter/test/literate/extracting-parameter-types0.cpp new file mode 100644 index 000000000..22e458242 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/extracting-parameter-types0.cpp @@ -0,0 +1,55 @@ + +#include <boost/parameter.hpp> + +BOOST_PARAMETER_NAME(name) +BOOST_PARAMETER_NAME(index) + +template <typename T> +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) +void noop(T&&) +#else +void noop(T&) +#endif +{ +} + +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) +#include <utility> +#endif + +template <typename Name, typename Index> +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) +int deduce_arg_types_impl(Name&& name, Index&& index) +{ + noop(std::forward<Name>(name)); + noop(std::forward<Index>(index)); + return index; +} +#else +int deduce_arg_types_impl(Name& name, Index& index) +{ + Name& n2 = name; // we know the types + Index& i2 = index; + noop(n2); + noop(i2); + return index; +} +#endif + +template <typename ArgumentPack> +int deduce_arg_types(ArgumentPack const& args) +{ + return deduce_arg_types_impl(args[_name], args[_index|42]); +} + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + int a1 = deduce_arg_types((_name = "foo")); + int a2 = deduce_arg_types((_name = "foo", _index = 3)); + BOOST_TEST_EQ(a1, 42); + BOOST_TEST_EQ(a2, 3); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/extracting-parameter-types1.cpp b/src/boost/libs/parameter/test/literate/extracting-parameter-types1.cpp new file mode 100644 index 000000000..64694f51a --- /dev/null +++ b/src/boost/libs/parameter/test/literate/extracting-parameter-types1.cpp @@ -0,0 +1,21 @@ + +#include <boost/parameter.hpp> + +BOOST_PARAMETER_NAME(index) + +template <typename ArgumentPack> +typename boost::parameter::value_type<ArgumentPack,tag::index,int>::type + twice_index(ArgumentPack const& args) +{ + return 2 * args[_index|42]; +} + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + int six = twice_index(_index = 3); + BOOST_TEST_EQ(six, 6); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/fine-grained-name-control0.cpp b/src/boost/libs/parameter/test/literate/fine-grained-name-control0.cpp new file mode 100644 index 000000000..688658adc --- /dev/null +++ b/src/boost/libs/parameter/test/literate/fine-grained-name-control0.cpp @@ -0,0 +1,21 @@ + +#include <boost/parameter.hpp> + +BOOST_PARAMETER_NAME((pass_foo, keywords) foo) + +BOOST_PARAMETER_FUNCTION( + (int), f, keywords, (required (foo, *)) +) +{ + return foo + 1; +} + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + int x = f(pass_foo = 41); + BOOST_TEST_EQ(x, 42); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/handling-out-parameters0.cpp b/src/boost/libs/parameter/test/literate/handling-out-parameters0.cpp new file mode 100644 index 000000000..fb6bc9396 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/handling-out-parameters0.cpp @@ -0,0 +1,33 @@ + +#include <boost/parameter.hpp> + +namespace boost { + + int vertex_index = 0; + + template <typename T = int> + struct dfs_visitor + { + }; +} + +BOOST_PARAMETER_NAME(graph) +BOOST_PARAMETER_NAME(visitor) +BOOST_PARAMETER_NAME(root_vertex) +BOOST_PARAMETER_NAME(index_map) +BOOST_PARAMETER_NAME(in_out(color_map)) + +BOOST_PARAMETER_FUNCTION((void), f, tag, + (required (graph, *)) + (optional + (visitor, *, boost::dfs_visitor<>()) + (root_vertex, *, *vertices(graph).first) + (index_map, *, get(boost::vertex_index,graph)) + (color_map, *, + default_color_map(num_vertices(graph), index_map) + ) + ) +) +{ +} + diff --git a/src/boost/libs/parameter/test/literate/headers-and-namespaces0.cpp b/src/boost/libs/parameter/test/literate/headers-and-namespaces0.cpp new file mode 100644 index 000000000..a3b138d2e --- /dev/null +++ b/src/boost/libs/parameter/test/literate/headers-and-namespaces0.cpp @@ -0,0 +1,3 @@ +#include <boost/parameter/keyword.hpp> +using boost::parameter::keyword; + diff --git a/src/boost/libs/parameter/test/literate/lazy-default-computation0.cpp b/src/boost/libs/parameter/test/literate/lazy-default-computation0.cpp new file mode 100644 index 000000000..ad8a3e83e --- /dev/null +++ b/src/boost/libs/parameter/test/literate/lazy-default-computation0.cpp @@ -0,0 +1,28 @@ + +#include <boost/parameter.hpp> +#include <string> + +BOOST_PARAMETER_NAME(s1) +BOOST_PARAMETER_NAME(s2) +BOOST_PARAMETER_NAME(s3) + +template <typename ArgumentPack> +std::string f(ArgumentPack const& args) +{ + std::string const& s1 = args[_s1]; + std::string const& s2 = args[_s2]; + typename boost::parameter::binding< + ArgumentPack,tag::s3,std::string + >::type s3 = args[_s3|(s1+s2)]; // always constructs s1+s2 + return s3; +} + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + std::string x = f((_s1="hello,", _s2=" world", _s3="hi world")); + BOOST_TEST_EQ(x, std::string("hi world")); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/lazy-default-computation1.cpp b/src/boost/libs/parameter/test/literate/lazy-default-computation1.cpp new file mode 100644 index 000000000..c6ecc1981 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/lazy-default-computation1.cpp @@ -0,0 +1,37 @@ + +#include <boost/bind.hpp> +#include <boost/ref.hpp> +#include <boost/parameter.hpp> +#include <string> +#include <functional> + +BOOST_PARAMETER_NAME(s1) +BOOST_PARAMETER_NAME(s2) +BOOST_PARAMETER_NAME(s3) + +template <typename ArgumentPack> +std::string f(ArgumentPack const& args) +{ + std::string const& s1 = args[_s1]; + std::string const& s2 = args[_s2]; + typename boost::parameter::binding< + ArgumentPack, tag::s3, std::string + >::type s3 = args[ + _s3 || boost::bind( + std::plus<std::string>() + , boost::ref(s1) + , boost::ref(s2) + ) + ]; + return s3; +} + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + std::string x = f((_s1="hello,", _s2=" world", _s3="hi world")); + BOOST_TEST_EQ(x, std::string("hi world")); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/namespaces0.cpp b/src/boost/libs/parameter/test/literate/namespaces0.cpp new file mode 100644 index 000000000..a0bd827ca --- /dev/null +++ b/src/boost/libs/parameter/test/literate/namespaces0.cpp @@ -0,0 +1,27 @@ + +#include <boost/parameter.hpp> +#include <iostream> + +namespace lib { + + BOOST_PARAMETER_NAME(name) + BOOST_PARAMETER_NAME(index) + + BOOST_PARAMETER_FUNCTION( + (int), f, tag, (optional (name,*,"bob")(index,(int),1)) + ) + { + std::cout << name << ":" << index << std::endl; + return index; + } +} + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + int x = lib::f(lib::_name = "jill", lib::_index = 1); + BOOST_TEST_EQ(x, 1); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/namespaces1.cpp b/src/boost/libs/parameter/test/literate/namespaces1.cpp new file mode 100644 index 000000000..4d5ff786c --- /dev/null +++ b/src/boost/libs/parameter/test/literate/namespaces1.cpp @@ -0,0 +1,30 @@ + +#include <boost/parameter.hpp> +#include <iostream> + +namespace lib { + + BOOST_PARAMETER_NAME(name) + BOOST_PARAMETER_NAME(index) + + BOOST_PARAMETER_FUNCTION( + (int), f, tag, (optional (name,*,"bob")(index,(int),1)) + ) + { + std::cout << name << ":" << index << std::endl; + return index; + } +} + +#include <boost/core/lightweight_test.hpp> + +using lib::_name; +using lib::_index; + +int main() +{ + int x = lib::f(_name = "jill", _index = 1); + BOOST_TEST_EQ(x, 1); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/namespaces2.cpp b/src/boost/libs/parameter/test/literate/namespaces2.cpp new file mode 100644 index 000000000..c4a5d4f55 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/namespaces2.cpp @@ -0,0 +1,29 @@ + +#include <boost/parameter.hpp> +#include <iostream> + +namespace lib { + + BOOST_PARAMETER_NAME(name) + BOOST_PARAMETER_NAME(index) + + BOOST_PARAMETER_FUNCTION( + (int), f, tag, (optional (name,*,"bob")(index,(int),1)) + ) + { + std::cout << name << ":" << index << std::endl; + return index; + } +} + +#include <boost/core/lightweight_test.hpp> + +using namespace lib; + +int main() +{ + int x = f(_name = "jill", _index = 3); + BOOST_TEST_EQ(x, 3); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/namespaces3.cpp b/src/boost/libs/parameter/test/literate/namespaces3.cpp new file mode 100644 index 000000000..6f5260f72 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/namespaces3.cpp @@ -0,0 +1,31 @@ + +#include <boost/parameter.hpp> +#include <iostream> + +namespace lib { + namespace keywords { + + BOOST_PARAMETER_NAME(name) + BOOST_PARAMETER_NAME(index) + } + + BOOST_PARAMETER_FUNCTION( + (int), f, keywords::tag, (optional (name,*,"bob")(index,(int),1)) + ) + { + std::cout << name << ":" << index << std::endl; + return index; + } +} + +#include <boost/core/lightweight_test.hpp> + +using namespace lib::keywords; + +int main() +{ + int x = lib::f(_name = "bob", _index = 2); + BOOST_TEST_EQ(x, 2); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/optional-parameters0.cpp b/src/boost/libs/parameter/test/literate/optional-parameters0.cpp new file mode 100644 index 000000000..fb6bc9396 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/optional-parameters0.cpp @@ -0,0 +1,33 @@ + +#include <boost/parameter.hpp> + +namespace boost { + + int vertex_index = 0; + + template <typename T = int> + struct dfs_visitor + { + }; +} + +BOOST_PARAMETER_NAME(graph) +BOOST_PARAMETER_NAME(visitor) +BOOST_PARAMETER_NAME(root_vertex) +BOOST_PARAMETER_NAME(index_map) +BOOST_PARAMETER_NAME(in_out(color_map)) + +BOOST_PARAMETER_FUNCTION((void), f, tag, + (required (graph, *)) + (optional + (visitor, *, boost::dfs_visitor<>()) + (root_vertex, *, *vertices(graph).first) + (index_map, *, get(boost::vertex_index,graph)) + (color_map, *, + default_color_map(num_vertices(graph), index_map) + ) + ) +) +{ +} + diff --git a/src/boost/libs/parameter/test/literate/parameter-enabled-constructors0.cpp b/src/boost/libs/parameter/test/literate/parameter-enabled-constructors0.cpp new file mode 100644 index 000000000..96663a053 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/parameter-enabled-constructors0.cpp @@ -0,0 +1,36 @@ + +#include <boost/parameter.hpp> +#include <iostream> + +BOOST_PARAMETER_NAME(name) +BOOST_PARAMETER_NAME(index) + +struct myclass_impl +{ + template <typename ArgumentPack> + myclass_impl(ArgumentPack const& args) + { + std::cout << "name = " << args[_name]; + std::cout << "; index = " << args[_index | 42]; + std::cout << std::endl; + } +}; + +struct myclass : myclass_impl +{ + BOOST_PARAMETER_CONSTRUCTOR( + myclass, (myclass_impl), tag + , (required (name,*)) (optional (index,*)) + ) // no semicolon +}; + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + myclass x("bob", 3); // positional + myclass y(_index = 12, _name = "sally"); // named + myclass z("june"); // positional/defaulted + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/parameter-enabled-function-call-operators0.cpp b/src/boost/libs/parameter/test/literate/parameter-enabled-function-call-operators0.cpp new file mode 100644 index 000000000..f623ef85d --- /dev/null +++ b/src/boost/libs/parameter/test/literate/parameter-enabled-function-call-operators0.cpp @@ -0,0 +1,29 @@ + +#include <boost/parameter.hpp> +#include <iostream> + +using namespace boost::parameter; + +BOOST_PARAMETER_NAME(arg1) +BOOST_PARAMETER_NAME(arg2) + +struct callable2 +{ + BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR( + (void), tag, (required (arg1,(int))(arg2,(int))) + ) + { + std::cout << arg1 << ", " << arg2 << std::endl; + } +}; + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + callable2 c2; + callable2 const& c2_const = c2; + c2_const(1, 2); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/parameter-enabled-member-functions0.cpp b/src/boost/libs/parameter/test/literate/parameter-enabled-member-functions0.cpp new file mode 100644 index 000000000..04eecbf1b --- /dev/null +++ b/src/boost/libs/parameter/test/literate/parameter-enabled-member-functions0.cpp @@ -0,0 +1,29 @@ + +#include <boost/parameter.hpp> +#include <iostream> + +using namespace boost::parameter; + +BOOST_PARAMETER_NAME(arg1) +BOOST_PARAMETER_NAME(arg2) + +struct callable2 +{ + BOOST_PARAMETER_CONST_MEMBER_FUNCTION( + (void), call, tag, (required (arg1,(int))(arg2,(int))) + ) + { + std::cout << arg1 << ", " << arg2 << std::endl; + } +}; + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + callable2 c2; + callable2 const& c2_const = c2; + c2_const.call(1, 2); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/parameter-enabled-member-functions1.cpp b/src/boost/libs/parameter/test/literate/parameter-enabled-member-functions1.cpp new file mode 100644 index 000000000..3aaae2357 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/parameter-enabled-member-functions1.cpp @@ -0,0 +1,21 @@ + +#include <boost/parameter.hpp> + +BOOST_PARAMETER_NAME(arg1) +BOOST_PARAMETER_NAME(arg2) + +using namespace boost::parameter; + +struct callable2 +{ + BOOST_PARAMETER_CONST_MEMBER_FUNCTION( + (void), call, tag, (required (arg1,(int))(arg2,(int))) + ) + { + call_impl(arg1, arg2); + } + + private: + void call_impl(int, int); // implemented elsewhere. +}; + diff --git a/src/boost/libs/parameter/test/literate/predicate-requirements0.cpp b/src/boost/libs/parameter/test/literate/predicate-requirements0.cpp new file mode 100644 index 000000000..d39ae964a --- /dev/null +++ b/src/boost/libs/parameter/test/literate/predicate-requirements0.cpp @@ -0,0 +1,189 @@ + +#include <boost/parameter.hpp> + +BOOST_PARAMETER_NAME((_graph, graphs) graph) +BOOST_PARAMETER_NAME((_visitor, graphs) visitor) +BOOST_PARAMETER_NAME((_root_vertex, graphs) in(root_vertex)) +BOOST_PARAMETER_NAME((_index_map, graphs) in(index_map)) +BOOST_PARAMETER_NAME((_color_map, graphs) in_out(color_map)) + +#include <boost/graph/graph_traits.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_convertible.hpp> +#include <boost/type_traits/is_integral.hpp> +#include <boost/type_traits/is_same.hpp> + +struct vertex_descriptor_predicate +{ + template <typename T, typename Args> + struct apply + : boost::mpl::if_< + boost::is_convertible< + T + , typename boost::graph_traits< + typename boost::parameter::value_type< + Args + , graphs::graph + >::type + >::vertex_descriptor + > + , boost::mpl::true_ + , boost::mpl::false_ + > + { + }; +}; + +#include <boost/mpl/eval_if.hpp> + +struct graph_predicate +{ + template <typename T, typename Args> + struct apply + : boost::mpl::eval_if< + boost::is_convertible< + typename boost::graph_traits<T>::traversal_category + , boost::incidence_graph_tag + > + , boost::mpl::if_< + boost::is_convertible< + typename boost::graph_traits<T>::traversal_category + , boost::vertex_list_graph_tag + > + , boost::mpl::true_ + , boost::mpl::false_ + > + , boost::mpl::false_ + > + { + }; +}; + +#include <boost/property_map/property_map.hpp> +#include <boost/type_traits/is_same.hpp> + +struct color_map_predicate +{ + template <typename T, typename Args> + struct apply + : boost::mpl::if_< + boost::is_same< + typename boost::property_traits<T>::key_type + , typename boost::graph_traits< + typename boost::parameter::value_type< + Args + , graphs::graph + >::type + >::vertex_descriptor + > + , boost::mpl::true_ + , boost::mpl::false_ + > + { + }; +}; + +#include <boost/type_traits/is_integral.hpp> + +struct index_map_predicate +{ + template <typename T, typename Args> + struct apply + : boost::mpl::eval_if< + boost::is_integral< + typename boost::property_traits<T>::value_type + > + , boost::mpl::if_< + boost::is_same< + typename boost::property_traits<T>::key_type + , typename boost::graph_traits< + typename boost::parameter::value_type< + Args + , graphs::graph + >::type + >::vertex_descriptor + > + , boost::mpl::true_ + , boost::mpl::false_ + > + , boost::mpl::false_ + > + { + }; +}; + +#include <boost/graph/properties.hpp> +#include <vector> + +template <typename Size, typename IndexMap> +boost::iterator_property_map< + std::vector<boost::default_color_type>::iterator + , IndexMap + , boost::default_color_type + , boost::default_color_type& +>& + default_color_map(Size num_vertices, IndexMap const& index_map) +{ + static std::vector<boost::default_color_type> colors(num_vertices); + static boost::iterator_property_map< + std::vector<boost::default_color_type>::iterator + , IndexMap + , boost::default_color_type + , boost::default_color_type& + > m(colors.begin(), index_map); + return m; +} + +#include <boost/graph/depth_first_search.hpp> + +BOOST_PARAMETER_FUNCTION((void), depth_first_search, graphs, + (required + (graph, *(graph_predicate)) + ) + (optional + (visitor + , * // not easily checkable + , boost::dfs_visitor<>() + ) + (root_vertex + , *(vertex_descriptor_predicate) + , *vertices(graph).first + ) + (index_map + , *(index_map_predicate) + , get(boost::vertex_index, graph) + ) + (color_map + , *(color_map_predicate) + , default_color_map(num_vertices(graph), index_map) + ) + ) +) +{ +} + +#include <boost/core/lightweight_test.hpp> +#include <boost/graph/adjacency_list.hpp> +#include <utility> + +int main() +{ + typedef boost::adjacency_list< + boost::vecS + , boost::vecS + , boost::directedS + > G; + enum {u, v, w, x, y, z, N}; + typedef std::pair<std::size_t,std::size_t> E; + E edges[] = { + E(u, v), E(u, x), E(x, v), E(y, x), + E(v, y), E(w, y), E(w, z), E(z, z) + }; + G g(edges, edges + sizeof(edges) / sizeof(E), N); + + ::depth_first_search(g); + ::depth_first_search(g, _root_vertex = static_cast<std::size_t>(x)); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/required-parameters0.cpp b/src/boost/libs/parameter/test/literate/required-parameters0.cpp new file mode 100644 index 000000000..9bf59ce3a --- /dev/null +++ b/src/boost/libs/parameter/test/literate/required-parameters0.cpp @@ -0,0 +1,11 @@ + +#include <boost/parameter.hpp> + +BOOST_PARAMETER_NAME(graph) + +BOOST_PARAMETER_FUNCTION( + (void), f, tag, (required (graph, *) ) +) +{ +} + diff --git a/src/boost/libs/parameter/test/literate/static-member-functions0.cpp b/src/boost/libs/parameter/test/literate/static-member-functions0.cpp new file mode 100644 index 000000000..ce568285f --- /dev/null +++ b/src/boost/libs/parameter/test/literate/static-member-functions0.cpp @@ -0,0 +1,27 @@ + +#include <boost/parameter.hpp> +#include <iostream> + +using namespace boost::parameter; + +BOOST_PARAMETER_NAME(arg1) + +struct somebody +{ + BOOST_PARAMETER_MEMBER_FUNCTION( + (void), static f, tag, (optional (arg1,(int),0)) + ) + { + std::cout << arg1 << std::endl; + } +}; + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + somebody::f(); + somebody::f(4); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/template-keywords0.cpp b/src/boost/libs/parameter/test/literate/template-keywords0.cpp new file mode 100644 index 000000000..9a10ce81e --- /dev/null +++ b/src/boost/libs/parameter/test/literate/template-keywords0.cpp @@ -0,0 +1,11 @@ + +#include <boost/parameter.hpp> + +namespace boost { namespace python { + + BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type) + BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list) + BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type) + BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable) +}} + diff --git a/src/boost/libs/parameter/test/literate/template-keywords1.cpp b/src/boost/libs/parameter/test/literate/template-keywords1.cpp new file mode 100644 index 000000000..a1adfa3e4 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/template-keywords1.cpp @@ -0,0 +1,17 @@ + +#include <boost/parameter.hpp> + +namespace boost { namespace python { + + namespace tag { + + struct class_type; // keyword tag type + } + + template <typename T> + struct class_type + : boost::parameter::template_keyword<boost::python::tag::class_type,T> + { + }; +}} + diff --git a/src/boost/libs/parameter/test/literate/top-level0.cpp b/src/boost/libs/parameter/test/literate/top-level0.cpp new file mode 100644 index 000000000..8a8e39f6f --- /dev/null +++ b/src/boost/libs/parameter/test/literate/top-level0.cpp @@ -0,0 +1,57 @@ + +#include <boost/parameter.hpp> + +namespace test { + + BOOST_PARAMETER_NAME(title) + BOOST_PARAMETER_NAME(width) + BOOST_PARAMETER_NAME(titlebar) + + BOOST_PARAMETER_FUNCTION((int), new_window, tag, + (required (title,*)(width,*)(titlebar,*)) + ) + { + return 0; + } + + BOOST_PARAMETER_TEMPLATE_KEYWORD(deleter) + BOOST_PARAMETER_TEMPLATE_KEYWORD(copy_policy) + + template <typename T> + struct Deallocate + { + }; + + struct DeepCopy + { + }; + + struct Foo + { + }; + + template <typename T, typename A0, typename A1> + struct smart_ptr + { + smart_ptr(test::Foo*) + { + } + }; +} + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + char const* alert_s = "alert"; + int x = test::new_window(alert_s, test::_width=10, test::_titlebar=false); + test::Foo* foo = new test::Foo(); + test::smart_ptr< + test::Foo + , test::deleter<test::Deallocate<test::Foo> > + , test::copy_policy<test::DeepCopy> + > p(foo); + delete foo; + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/literate/writing-the-function0.cpp b/src/boost/libs/parameter/test/literate/writing-the-function0.cpp new file mode 100644 index 000000000..6a05ea260 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/writing-the-function0.cpp @@ -0,0 +1,45 @@ + +#include <boost/parameter/name.hpp> + +BOOST_PARAMETER_NAME(graph) +BOOST_PARAMETER_NAME(visitor) +BOOST_PARAMETER_NAME(root_vertex) +BOOST_PARAMETER_NAME(index_map) +BOOST_PARAMETER_NAME(in_out(color_map)) + +namespace boost { + + template <typename T = int> + struct dfs_visitor + { + }; + + int vertex_index = 0; +} + +#include <boost/parameter/preprocessor.hpp> + +namespace graphs { + + BOOST_PARAMETER_FUNCTION( + (void), // 1. parenthesized return type + depth_first_search, // 2. name of the function template + + tag, // 3. namespace of tag types + + (required (graph, *) ) // 4. one required parameter, and + + (optional // four optional parameters, with defaults + (visitor, *, boost::dfs_visitor<>()) + (root_vertex, *, *vertices(graph).first) + (index_map, *, get(boost::vertex_index,graph)) + (in_out(color_map), *, + default_color_map(num_vertices(graph), index_map) + ) + ) + ) + { + // ... body of function goes here... + // use graph, visitor, index_map, and color_map + } +} diff --git a/src/boost/libs/parameter/test/macros.cpp b/src/boost/libs/parameter/test/macros.cpp new file mode 100644 index 000000000..97026bbee --- /dev/null +++ b/src/boost/libs/parameter/test/macros.cpp @@ -0,0 +1,68 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter.hpp> +#include <boost/parameter/macros.hpp> +#include <boost/bind.hpp> +#include "basics.hpp" + +namespace test { + + BOOST_PARAMETER_FUN(int, f, 2, 4, f_parameters) + { + p[test::_tester]( + p[test::_name] + , p[test::_value || boost::bind(&test::value_default)] + , p[test::_index | 999] + ); + + return 1; + } + + BOOST_PARAMETER_NAME(foo) + BOOST_PARAMETER_NAME(bar) + + struct baz_parameters + : boost::parameter::parameters< + boost::parameter::optional<test::tag::foo> + , boost::parameter::optional<test::tag::bar> + > + { + }; + + BOOST_PARAMETER_FUN(int, baz, 0, 2, baz_parameters) + { + return 1; + } +} // namespace test + +#include <boost/ref.hpp> +#include <boost/core/lightweight_test.hpp> +#include <string> + +int main() +{ + test::f( + test::values( + std::string("foo") + , std::string("bar") + , std::string("baz") + ) + , std::string("foo") + , std::string("bar") + , std::string("baz") + ); + BOOST_TEST_EQ(1, test::baz()); + + int x = 56; + test::f( + test::values(std::string("foo"), 666.222, 56) + , test::_index = boost::ref(x) + , test::_name = std::string("foo") + ); + + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/macros_eval_category.cpp b/src/boost/libs/parameter/test/macros_eval_category.cpp new file mode 100644 index 000000000..7550ecdb1 --- /dev/null +++ b/src/boost/libs/parameter/test/macros_eval_category.cpp @@ -0,0 +1,185 @@ +// Copyright Cromwell D. Enage 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> + +#if (BOOST_PARAMETER_MAX_ARITY < 10) +#error Define BOOST_PARAMETER_MAX_ARITY as 10 or greater. +#endif + +#include <boost/parameter.hpp> + +namespace test { + + BOOST_PARAMETER_NAME(in(lrc0)) + BOOST_PARAMETER_NAME(out(lr0)) + BOOST_PARAMETER_NAME(in(rrc0)) +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_PARAMETER_NAME(consume(rr0)) +#else + BOOST_PARAMETER_NAME(rr0) +#endif + BOOST_PARAMETER_NAME(in(lrc1)) + BOOST_PARAMETER_NAME(out(lr1)) + BOOST_PARAMETER_NAME(in(rrc1)) + BOOST_PARAMETER_NAME(in(lrc2)) + BOOST_PARAMETER_NAME(out(lr2)) + BOOST_PARAMETER_NAME(rr2) + + struct g_parameters + : boost::parameter::parameters< + boost::parameter::required<test::tag::lrc0> + , boost::parameter::required<test::tag::lr0> + , boost::parameter::required<test::tag::rrc0> + , boost::parameter::required<test::tag::rr0> + , boost::parameter::required<test::tag::lrc1> + , boost::parameter::required<test::tag::lr1> + , boost::parameter::required<test::tag::rrc1> + , boost::parameter::optional<test::tag::lrc2> + , boost::parameter::optional<test::tag::lr2> + , boost::parameter::optional<test::tag::rr2> + > + { + }; +} // namespace test + +#include <boost/parameter/macros.hpp> +#include <boost/core/lightweight_test.hpp> +#include "evaluate_category.hpp" + +namespace test { + + struct C + { + BOOST_PARAMETER_MEMFUN(static int, evaluate, 7, 10, g_parameters) + { + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , U::evaluate_category<0>(p[test::_lrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , U::evaluate_category<0>(p[test::_lr0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , U::evaluate_category<1>(p[test::_lrc1]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , U::evaluate_category<1>(p[test::_lr1]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , U::evaluate_category<2>( + p[test::_lrc2 | test::lvalue_const_bitset<2>()] + ) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , U::evaluate_category<2>( + p[test::_lr2 || test::lvalue_bitset_function<2>()] + ) + ); +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , U::evaluate_category<0>(p[test::_rrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference + , U::evaluate_category<0>(p[test::_rr0]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , U::evaluate_category<1>(p[test::_rrc1]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference + , U::evaluate_category<2>( + p[test::_rr2 || test::rvalue_bitset_function<2>()] + ) + ); +#else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , U::evaluate_category<0>(p[test::_rrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , U::evaluate_category<0>(p[test::_rr0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , U::evaluate_category<1>(p[test::_rrc1]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , U::evaluate_category<2>( + p[test::_rr2 || test::rvalue_bitset_function<2>()] + ) + ); +#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING + + return 0; + } + }; +} // namespace test + +#if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) +#include <boost/core/ref.hpp> +#endif + +int main() +{ +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) || \ + (10 < BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY) + test::C::evaluate( + test::lvalue_const_bitset<0>() + , test::lvalue_bitset<0>() + , test::rvalue_const_bitset<0>() + , test::rvalue_bitset<0>() + , test::lvalue_const_bitset<1>() + , test::lvalue_bitset<1>() + , test::rvalue_const_bitset<1>() + ); + test::C::evaluate( + test::lvalue_const_bitset<0>() + , test::lvalue_bitset<0>() + , test::rvalue_const_bitset<0>() + , test::rvalue_bitset<0>() + , test::lvalue_const_bitset<1>() + , test::lvalue_bitset<1>() + , test::rvalue_const_bitset<1>() + , test::lvalue_const_bitset<2>() + , test::lvalue_bitset<2>() + , test::rvalue_bitset<2>() + ); +#else // no perfect forwarding support and no exponential overloads + test::C::evaluate( + test::lvalue_const_bitset<0>() + , boost::ref(test::lvalue_bitset<0>()) + , test::rvalue_const_bitset<0>() + , test::rvalue_bitset<0>() + , test::lvalue_const_bitset<1>() + , boost::ref(test::lvalue_bitset<1>()) + , test::rvalue_const_bitset<1>() + ); + test::C::evaluate( + test::lvalue_const_bitset<0>() + , boost::ref(test::lvalue_bitset<0>()) + , test::rvalue_const_bitset<0>() + , test::rvalue_bitset<0>() + , test::lvalue_const_bitset<1>() + , boost::ref(test::lvalue_bitset<1>()) + , test::rvalue_const_bitset<1>() + , test::lvalue_const_bitset<2>() + , boost::ref(test::lvalue_bitset<2>()) + , test::rvalue_bitset<2>() + ); +#endif // perfect forwarding support, or exponential overloads + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/maybe.cpp b/src/boost/libs/parameter/test/maybe.cpp new file mode 100644 index 000000000..bb00a9b7e --- /dev/null +++ b/src/boost/libs/parameter/test/maybe.cpp @@ -0,0 +1,43 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/name.hpp> + +namespace test { + + BOOST_PARAMETER_NAME(kw) + BOOST_PARAMETER_NAME(unused) + + template <typename Args> + int f(Args const& args) + { + return args[test::_kw | 1.f]; + } +} // namespace test + +#include <boost/parameter/aux_/maybe.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ(0, test::f((test::_kw = 0, test::_unused = 0))); + BOOST_TEST_EQ(1, test::f(test::_unused = 0)); + BOOST_TEST_EQ( + 1 + , test::f(( + test::_kw = boost::parameter::aux::maybe<int>() + , test::_unused = 0 + )) + ); + BOOST_TEST_EQ( + 2 + , test::f(( + test::_kw = boost::parameter::aux::maybe<int>(2) + , test::_unused = 0 + )) + ); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/mpl.cpp b/src/boost/libs/parameter/test/mpl.cpp new file mode 100644 index 000000000..d03ce4d61 --- /dev/null +++ b/src/boost/libs/parameter/test/mpl.cpp @@ -0,0 +1,185 @@ +// Copyright David Abrahams 2006. +// Copyright Cromwell D. Enage 2019. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/for_each.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/contains.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/type_traits/add_pointer.hpp> +#include "basics.hpp" + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/mp11/list.hpp> +#include <boost/mp11/map.hpp> +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/mpl.hpp> +#endif + +namespace test { + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + template <typename Map> + struct assert_in_map + { + template <typename T> + void operator()(T&&) + { + static_assert( + boost::mp11::mp_map_contains<Map,T>::value + , "T must be in Map" + ); + } + }; + + template <typename Set> + struct assert_in_set_0 + { + template <typename T> + void operator()(T&&) + { + static_assert( + boost::mp11::mp_contains<Set,T>::value + , "T must be in Set" + ); + } + }; +#endif + + template <typename Set> + struct assert_in_set_1 + { + template <typename T> + void operator()(T*) + { + BOOST_MPL_ASSERT((boost::mpl::contains<Set,T>)); + } + }; + + template <typename Expected, typename Args> + void f_impl(Args const& p BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected)) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + boost::mp11::mp_size<Expected>::value == boost::mp11::mp_size< + Args + >::value + , "mp_size<Expected>::value == mp_size<Args>::value" + ); + + boost::mp11::mp_for_each<boost::mp11::mp_map_keys<Args> >( + test::assert_in_set_0<Expected>() + ); + boost::mp11::mp_for_each<Expected>(test::assert_in_map<Args>()); +#endif + + BOOST_MPL_ASSERT_RELATION( + boost::mpl::size<Expected>::value + , == + , boost::mpl::size<Args>::value + ); + + boost::mpl::for_each<Args,boost::add_pointer<boost::mpl::_1> >( + test::assert_in_set_1<Expected>() + ); + boost::mpl::for_each<Expected,boost::add_pointer<boost::mpl::_1> >( + test::assert_in_set_1<Args>() + ); + } + + template < + typename Expected + , typename Tester + , typename Name + , typename Value + , typename Index + > + void f( + Tester const& t + , Name const& name_ + , Value const& value_ + , Index const& index_ + BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected) + ) + { + test::f_impl<Expected>( + test::f_parameters()(t, name_, value_, index_) + ); + } + + template < + typename Expected + , typename Tester + , typename Name + , typename Value + > + void f( + Tester const& t + , Name const& name_ + , Value const& value_ + BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected) + ) + { + test::f_impl<Expected>(test::f_parameters()(t, name_, value_)); + } + + template <typename Expected, typename Tester, typename Name> + void f( + Tester const& t + , Name const& name_ + BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected) + ) + { + test::f_impl<Expected>(test::f_parameters()(t, name_)); + } + + void run() + { + typedef test::tag::tester tester_; + typedef test::tag::name name_; + typedef test::tag::value value_; + typedef test::tag::index index_; + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + test::f< + boost::mp11::mp_list<tester_,name_,value_,index_> + >(1, 2, 3, 4); + test::f< + boost::mp11::mp_list<tester_,name_,index_> + >(1, 2, test::_index = 3); + test::f< + boost::mp11::mp_list<tester_,name_,index_> + >(1, test::_index = 2, test::_name = 3); + test::f< + boost::mp11::mp_list<name_,value_> + >(test::_name = 3, test::_value = 4); + test::f_impl<boost::mp11::mp_list<value_> >(test::_value = 4); +#endif + + test::f<boost::mpl::list4<tester_,name_,value_,index_> >(1, 2, 3, 4); + test::f< + boost::mpl::list3<tester_,name_,index_> + >(1, 2, test::_index = 3); + test::f< + boost::mpl::list3<tester_,name_,index_> + >(1, test::_index = 2, test::_name = 3); + test::f< + boost::mpl::list2<name_,value_> + >(test::_name = 3, test::_value = 4); + test::f_impl<boost::mpl::list1<value_> >(test::_value = 4); + } +} + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + test::run(); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/normalized_argument_types.cpp b/src/boost/libs/parameter/test/normalized_argument_types.cpp new file mode 100644 index 000000000..7685da9cd --- /dev/null +++ b/src/boost/libs/parameter/test/normalized_argument_types.cpp @@ -0,0 +1,179 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> + +#if (BOOST_PARAMETER_MAX_ARITY < 2) +#error Define BOOST_PARAMETER_MAX_ARITY as 2 or greater. +#endif +#if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ + (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 3) +#error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \ +as 3 or greater. +#endif + +namespace test { + + struct count_instances + { + count_instances() + { + ++count_instances::count; + } + + count_instances(count_instances const&) + { + ++count_instances::count; + } + + template <typename T> + count_instances(T const&) + { + ++count_instances::count; + } + + ~count_instances() + { + --count_instances::count; + } + + static std::size_t count; + + void noop() const + { + } + }; + + std::size_t count_instances::count = 0; +} // namespace test + +#include <boost/parameter/name.hpp> + +namespace test { + + BOOST_PARAMETER_NAME(x) + BOOST_PARAMETER_NAME(y) +} // namespace test + +#include <boost/parameter/preprocessor.hpp> + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <type_traits> +#else +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/type_traits/is_convertible.hpp> +#endif + +namespace test { + + BOOST_PARAMETER_FUNCTION((int), f, tag, + (required + (x, (long)) + ) + (optional + (y, (long), 2L) + ) + ) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_convertible<x_type,long>::value + , "is_convertible<x_type,long>" + ); + static_assert( + std::is_convertible<y_type,long>::value + , "is_convertible<y_type,long>" + ); +#else + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_convertible<x_type,long> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_convertible<y_type,long> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif // BOOST_PARAMETER_CAN_USE_MP11 + return 0; + } +} // namespace test + +#include <boost/core/lightweight_test.hpp> + +namespace test { + + BOOST_PARAMETER_FUNCTION((int), g, tag, + (required + (x, (test::count_instances)) + ) + ) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_convertible<x_type,test::count_instances>::value + , "is_convertible<x_type,test::count_instances>" + ); +#else + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_convertible<x_type,test::count_instances> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif + x.noop(); +#if !BOOST_WORKAROUND(BOOST_GCC, < 40000) + BOOST_TEST_LT(0, test::count_instances::count); +#endif + return 0; + } + + BOOST_PARAMETER_FUNCTION((int), h, tag, + (required + (x, (test::count_instances const&)) + ) + ) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_convertible<x_type,test::count_instances const>::value + , "is_convertible<x_type,test::count_instances const>" + ); +#else + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_convertible<x_type,test::count_instances const> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif + x.noop(); +#if !BOOST_WORKAROUND(BOOST_GCC, < 40000) + BOOST_TEST_EQ(1, test::count_instances::count); +#endif + return 0; + } +} // namespace test + +int main() +{ + test::f(1, 2); + test::f(1., 2.f); + test::f(1U); + test::g(0); + test::h(0); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/ntp.cpp b/src/boost/libs/parameter/test/ntp.cpp new file mode 100644 index 000000000..c48628f08 --- /dev/null +++ b/src/boost/libs/parameter/test/ntp.cpp @@ -0,0 +1,337 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> + +#if (BOOST_PARAMETER_MAX_ARITY < 4) +#error Define BOOST_PARAMETER_MAX_ARITY as 4 or greater. +#endif + +namespace test { + + struct X + { + }; + + struct Y : X + { + }; +} // namespace test + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <type_traits> +#else +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_base_of.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/type_traits/remove_reference.hpp> +#endif + +namespace test { + + struct Z + { + template <typename T, typename Args> +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + using fn = std::is_base_of< + X + , typename std::remove_const< + typename std::remove_reference<T>::type + >::type + >; +#else + struct apply + : boost::mpl::if_< + boost::is_base_of< + X + , typename boost::remove_const< + typename boost::remove_reference<T>::type + >::type + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + { + }; +#endif // BOOST_PARAMETER_CAN_USE_MP11 + }; +} // namespace test + +#include <boost/parameter/template_keyword.hpp> + +namespace test { + + template <typename T = int> + struct a0_is : boost::parameter::template_keyword<test::a0_is<>,T> + { + }; + + template <typename T = int> + struct a1_is : boost::parameter::template_keyword<test::a1_is<>,T> + { + }; + + template <typename T = int> + struct a2_is : boost::parameter::template_keyword<test::a2_is<>,T> + { + }; + + template <typename T = int> + struct a3_is : boost::parameter::template_keyword<test::a3_is<>,T> + { + }; +} // namespace test + +#include <boost/parameter/parameters.hpp> +#include <boost/parameter/optional.hpp> +#include <boost/parameter/deduced.hpp> +#include <boost/parameter/binding.hpp> + +namespace test { + + template < + typename A0 = boost::parameter::void_ + , typename A1 = boost::parameter::void_ + , typename A2 = boost::parameter::void_ + , typename A3 = boost::parameter::void_ + > + struct with_ntp + { + typedef typename boost::parameter::parameters< + test::a0_is<> + , test::a1_is<> + , test::a2_is<> + , boost::parameter::optional< + boost::parameter::deduced<test::a3_is<> > + , Z + > + >::BOOST_NESTED_TEMPLATE bind< + A0 + , A1 + , A2 + , A3 +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + , boost::parameter::void_ +#endif + >::type args; + typedef typename boost::parameter::binding< + args + , test::a0_is<> + , void* + >::type a0; + typedef typename boost::parameter::binding< + args + , test::a1_is<> + , void* + >::type a1; + typedef typename boost::parameter::binding< + args + , test::a2_is<> + , void* + >::type a2; + typedef typename boost::parameter::binding< + args + , test::a3_is<> + , void* + >::type a3; + typedef void(*type)(a0, a1, a2, a3); + }; +} // namespace test + +#include <boost/mpl/aux_/test.hpp> + +#if !defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/mpl/assert.hpp> +#include <boost/type_traits/is_same.hpp> +#endif + +MPL_TEST_CASE() +{ +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_same< + test::with_ntp<>::type + , void(*)(void*, void*, void*, void*) + >::value + , "type must be void(*)(void*, void*, void*, void*)" + ); + static_assert( + std::is_same< + test::with_ntp<test::a2_is<int> >::type + , void(*)(void*, void*, int, void*) + >::value + , "type must be void(*)(void*, void*, int, void*)" + ); + static_assert( + std::is_same< + test::with_ntp<test::a1_is<int> >::type + , void(*)(void*, int, void*, void*) + >::value + , "type must be void(*)(void*, int, void*, void*)" + ); + static_assert( + std::is_same< + test::with_ntp<test::a2_is<int const>,test::a1_is<float> >::type + , void(*)(void*, float, int const, void*) + >::value + , "type must be void(*)(void*, float, int const, void*)" + ); + static_assert( + std::is_same< + test::with_ntp<int const>::type + , void(*)(int const, void*, void*, void*) + >::value + , "type must be void(*)(int const, void*, void*, void*)" + ); + static_assert( + std::is_same< + test::with_ntp<int,float>::type + , void(*)(int, float, void*, void*) + >::value + , "type must be void(*)(int, float, void*, void*)" + ); + static_assert( + std::is_same< + test::with_ntp<int,float,char>::type + , void(*)(int, float, char, void*) + >::value + , "type must be void(*)(int, float, char, void*)" + ); + static_assert( + std::is_same< + test::with_ntp<test::a0_is<int>,test::Y>::type + , void(*)(int, void*, void*, test::Y) + >::value + , "type must be must be void(*)(int, void*, void*, test::Y)" + ); + static_assert( + std::is_same< + test::with_ntp<int&,test::a2_is<char>,test::Y>::type + , void(*)(int&, void*, char, test::Y) + >::value + , "type must be void(*)(int&, void*, char, test::Y)" + ); +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + test::with_ntp<>::type + , void(*)(void*, void*, void*, void*) + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + test::with_ntp<test::a2_is<int> >::type + , void(*)(void*, void*, int, void*) + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + test::with_ntp<test::a1_is<int> >::type + , void(*)(void*, int, void*, void*) + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + test::with_ntp< + test::a2_is<int const> + , test::a1_is<float> + >::type + , void(*)(void*, float, int const, void*) + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + test::with_ntp<int const>::type + , void(*)(int const, void*, void*, void*) + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + test::with_ntp<int,float>::type + , void(*)(int, float, void*, void*) + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + test::with_ntp<int,float,char>::type + , void(*)(int, float, char, void*) + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + test::with_ntp<test::a0_is<int>,test::Y>::type + , void(*)(int, void*, void*, test::Y) + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + test::with_ntp<int&,test::a2_is<char>,test::Y>::type + , void(*)(int&, void*, char, test::Y) + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif // BOOST_PARAMETER_CAN_USE_MP11 + + typedef int test_array[1]; + typedef void(*test_function)(); + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_same< + test::with_ntp<test_array,test_function>::type + , void(*)(test_array&, test_function, void*, void*) + >::value + , "type must be void(*)(test_array&, test_function, void*, void*)" + ); +#else + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + test::with_ntp<test_array,test_function>::type + , void(*)(test_array&, test_function, void*, void*) + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif +} + diff --git a/src/boost/libs/parameter/test/optional_deduced_sfinae.cpp b/src/boost/libs/parameter/test/optional_deduced_sfinae.cpp new file mode 100644 index 000000000..a821cc9cf --- /dev/null +++ b/src/boost/libs/parameter/test/optional_deduced_sfinae.cpp @@ -0,0 +1,108 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> + +#if (BOOST_PARAMETER_MAX_ARITY < 2) +#error Define BOOST_PARAMETER_MAX_ARITY as 2 or greater. +#endif +#if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ + (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 2) +#error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \ +as 2 or greater. +#endif + +#include <boost/parameter/preprocessor.hpp> +#include <boost/parameter/name.hpp> +#include <boost/parameter/aux_/preprocessor/nullptr.hpp> +#include <boost/tuple/tuple.hpp> +#include <boost/core/enable_if.hpp> +#include <string> + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/mp11/utility.hpp> +#include <type_traits> +#else +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_convertible.hpp> +#endif + +namespace test { + + BOOST_PARAMETER_NAME(x) + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + template <typename T, typename Args> + using predicate = std::is_convertible<T,char const*>; + + BOOST_PARAMETER_FUNCTION((int), sfinae, test::tag, + (deduced + (optional + (x + , *(boost::mp11::mp_quote<test::predicate>) + , static_cast<char const*>(BOOST_PARAMETER_AUX_PP_NULLPTR) + ) + ) + ) + ) +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + struct predicate + { + template <typename T, typename Args> + struct apply + : boost::mpl::if_< + boost::is_convertible<T,char const*> + , boost::mpl::true_ + , boost::mpl::false_ + > + { + }; + }; + + BOOST_PARAMETER_FUNCTION((int), sfinae, test::tag, + (deduced + (optional + (x + , *(test::predicate) + , static_cast<char const*>(BOOST_PARAMETER_AUX_PP_NULLPTR) + ) + ) + ) + ) +#endif // BOOST_PARAMETER_CAN_USE_MP11 + { + return 1; + } + + template <typename A0> + typename boost::enable_if< +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + std::is_same<int,A0> +#else + typename boost::mpl::if_< + boost::is_same<int,A0> + , boost::mpl::true_ + , boost::mpl::false_ + >::type +#endif + , int + >::type + sfinae(A0 const& a0) + { + return 0; + } +} // namespace test + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ(1, test::sfinae()); + BOOST_TEST_EQ(1, test::sfinae("foo")); + BOOST_TEST_EQ(0, test::sfinae(1)); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/parameterized_inheritance.cpp b/src/boost/libs/parameter/test/parameterized_inheritance.cpp new file mode 100644 index 000000000..eead03a1a --- /dev/null +++ b/src/boost/libs/parameter/test/parameterized_inheritance.cpp @@ -0,0 +1,264 @@ +// Copyright Cromwell D. Enage 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> + +#if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ + (BOOST_PARAMETER_COMPOSE_MAX_ARITY < 3) +#error Define BOOST_PARAMETER_COMPOSE_MAX_ARITY as 3 or greater. +#endif + +#include <boost/parameter/name.hpp> + +namespace test { + + BOOST_PARAMETER_NAME(a0) + BOOST_PARAMETER_NAME(a1) + BOOST_PARAMETER_NAME(a2) +} + +#if !defined(BOOST_NO_SFINAE) +#include <boost/parameter/is_argument_pack.hpp> +#include <boost/type_traits/is_convertible.hpp> +#include <boost/core/enable_if.hpp> +#endif + +namespace test { + +#if !defined(BOOST_NO_SFINAE) + struct _enabler + { + }; +#endif + + template <typename T> + class backend0 + { + T _a0; + + public: + template <typename ArgPack> + explicit backend0( + ArgPack const& args +#if !defined(BOOST_NO_SFINAE) + , typename boost::enable_if< + boost::parameter::is_argument_pack<ArgPack> + , test::_enabler + >::type = test::_enabler() +#endif + ) : _a0(args[test::_a0]) + { + } + +#if !defined(BOOST_NO_SFINAE) + template <typename U> + backend0( + backend0<U> const& copy + , typename boost::enable_if< + boost::is_convertible<U,T> + , test::_enabler + >::type = test::_enabler() + ) : _a0(copy.get_a0()) + { + } +#endif + + template <typename Iterator> + backend0(Iterator itr, Iterator itr_end) : _a0(itr, itr_end) + { + } + + T const& get_a0() const + { + return this->_a0; + } + + protected: + template <typename ArgPack> + void initialize_impl(ArgPack const& args) + { + this->_a0 = args[test::_a0]; + } + }; + + template <typename B, typename T> + class backend1 : public B + { + T _a1; + + public: + template <typename ArgPack> + explicit backend1( + ArgPack const& args +#if !defined(BOOST_NO_SFINAE) + , typename boost::enable_if< + boost::parameter::is_argument_pack<ArgPack> + , test::_enabler + >::type = test::_enabler() +#endif + ) : B(args), _a1(args[test::_a1]) + { + } + +#if !defined(BOOST_NO_SFINAE) + template <typename Derived> + backend1( + Derived const& copy + , typename boost::disable_if< + boost::parameter::is_argument_pack<Derived> + , test::_enabler + >::type = test::_enabler() + ) : B(copy), _a1(copy.get_a1()) + { + } +#endif + + T const& get_a1() const + { + return this->_a1; + } + + protected: + template <typename ArgPack> + void initialize_impl(ArgPack const& args) + { + B::initialize_impl(args); + this->_a1 = args[test::_a1]; + } + }; + + template <typename B, typename T> + class backend2 : public B + { + T _a2; + + public: + template <typename ArgPack> + explicit backend2( + ArgPack const& args +#if !defined(BOOST_NO_SFINAE) + , typename boost::enable_if< + boost::parameter::is_argument_pack<ArgPack> + , test::_enabler + >::type = test::_enabler() +#endif + ) : B(args), _a2(args[test::_a2]) + { + } + +#if !defined(BOOST_NO_SFINAE) + template <typename Derived> + backend2( + Derived const& copy + , typename boost::disable_if< + boost::parameter::is_argument_pack<Derived> + , test::_enabler + >::type = test::_enabler() + ) : B(copy), _a2(copy.get_a2()) + { + } +#endif + + T const& get_a2() const + { + return this->_a2; + } + + protected: + template <typename ArgPack> + void initialize_impl(ArgPack const& args) + { + B::initialize_impl(args); + this->_a2 = args[test::_a2]; + } + }; +} + +#include <boost/parameter/preprocessor_no_spec.hpp> + +#if !defined(BOOST_NO_SFINAE) +#include <boost/parameter/are_tagged_arguments.hpp> +#endif + +namespace test { + + template <typename B> + struct frontend : public B + { + BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR(frontend, (B)) + +#if !defined(BOOST_NO_SFINAE) + template <typename Iterator> + frontend( + Iterator itr + , Iterator itr_end + , typename boost::disable_if< + boost::parameter::are_tagged_arguments<Iterator> + , test::_enabler + >::type = test::_enabler() + ) : B(itr, itr_end) + { + } + + template <typename O> + frontend(frontend<O> const& copy) : B(copy) + { + } +#endif + + BOOST_PARAMETER_NO_SPEC_MEMBER_FUNCTION((void), initialize) + { + this->initialize_impl(args); + } + + BOOST_PARAMETER_NO_SPEC_FUNCTION_CALL_OPERATOR((void)) + { + this->initialize_impl(args); + } + }; +} // namespace test + +#include <boost/core/lightweight_test.hpp> + +#if !defined(BOOST_NO_SFINAE) +#include <string> +#endif + +int main() +{ + char const* p = "foo"; + char const* q = "bar"; + test::frontend< + test::backend2<test::backend1<test::backend0<char const*>, char>, int> + > composed_obj0(test::_a2 = 4, test::_a1 = ' ', test::_a0 = p); +#if defined(BOOST_NO_SFINAE) + test::frontend< + test::backend1<test::backend2<test::backend0<char const*>, int>, char> + > composed_obj1(test::_a0 = p, test::_a1 = ' ', test::_a2 = 4); +#else + test::frontend< + test::backend1<test::backend2<test::backend0<char const*>, int>, char> + > composed_obj1(composed_obj0); +#endif + BOOST_TEST_EQ(composed_obj0.get_a0(), composed_obj1.get_a0()); + BOOST_TEST_EQ(composed_obj0.get_a1(), composed_obj1.get_a1()); + BOOST_TEST_EQ(composed_obj0.get_a2(), composed_obj1.get_a2()); + composed_obj0.initialize(test::_a0 = q, test::_a1 = '!', test::_a2 = 8); + composed_obj1.initialize(test::_a2 = 8, test::_a1 = '!', test::_a0 = q); + BOOST_TEST_EQ(composed_obj0.get_a0(), composed_obj1.get_a0()); + BOOST_TEST_EQ(composed_obj0.get_a1(), composed_obj1.get_a1()); + BOOST_TEST_EQ(composed_obj0.get_a2(), composed_obj1.get_a2()); + composed_obj0(test::_a2 = 8, test::_a1 = '!', test::_a0 = q); + composed_obj1(test::_a0 = q, test::_a1 = '!', test::_a2 = 8); + BOOST_TEST_EQ(composed_obj0.get_a0(), composed_obj1.get_a0()); + BOOST_TEST_EQ(composed_obj0.get_a1(), composed_obj1.get_a1()); + BOOST_TEST_EQ(composed_obj0.get_a2(), composed_obj1.get_a2()); +#if !defined(BOOST_NO_SFINAE) + test::frontend<test::backend0<std::string> > string_wrap(p, p + 3); + BOOST_TEST_EQ(string_wrap.get_a0(), std::string(p)); +#endif + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/preprocessor.cpp b/src/boost/libs/parameter/test/preprocessor.cpp new file mode 100644 index 000000000..91e324dae --- /dev/null +++ b/src/boost/libs/parameter/test/preprocessor.cpp @@ -0,0 +1,689 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/preprocessor.hpp> +#include <boost/parameter/binding.hpp> +#include <boost/parameter/config.hpp> +#include "basics.hpp" + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <type_traits> +#else +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_same.hpp> +#endif + +namespace test { + + BOOST_PARAMETER_BASIC_FUNCTION((int), f, test::tag, + (required + (tester, *) + (name, *) + ) + (optional + (value, *) + (index, (int)) + ) + ) + { + typedef typename boost::parameter::binding< + Args,test::tag::index,int& + >::type index_type; + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_same<index_type,int&>::value + , "index_type == int&" + ); +#else + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same<index_type,int&> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif + + args[test::_tester]( + args[test::_name] + , args[test::_value | 1.f] + , args[test::_index | 2] + ); + + return 1; + } +} // namespace test + +#include <boost/parameter/value_type.hpp> + +#if !defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/type_traits/remove_const.hpp> +#endif + +namespace test { + + BOOST_PARAMETER_BASIC_FUNCTION((int), g, test::tag, + (required + (tester, *) + (name, *) + ) + (optional + (value, *) + (index, (int)) + ) + ) + { + typedef typename boost::parameter::value_type< + Args,test::tag::index,int + >::type index_type; + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_same< + typename std::remove_const<index_type>::type + , int + >::value + , "remove_const<index_type>::type == int" + ); +#else + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::remove_const<index_type>::type + , int + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif + + args[test::_tester]( + args[test::_name] + , args[test::_value | 1.f] + , args[test::_index | 2] + ); + + return 1; + } +} // namespace test + +#if !defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/type_traits/remove_reference.hpp> +#endif + +namespace test { + + BOOST_PARAMETER_FUNCTION((int), h, test::tag, + (required + (tester, *) + (name, *) + ) + (optional + (value, *, 1.f) + (index, (int), 2) + ) + ) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_same< + typename std::remove_const< + typename std::remove_reference<index_type>::type + >::type + , int + >::value + , "remove_cref<index_type>::type == int" + ); +#elif !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ + !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::remove_const< + typename boost::remove_reference<index_type>::type + >::type + , int + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif // BOOST_PARAMETER_CAN_USE_MP11 || Borland/MSVC workarounds not needed + + tester(name, value, index); + + return 1; + } + + BOOST_PARAMETER_FUNCTION((int), h2, test::tag, + (required + (tester, *) + (name, *) + ) + (optional + (value, *, 1.f) + (index, (int), static_cast<int>(value * 2)) + ) + ) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_same< + typename std::remove_const< + typename std::remove_reference<index_type>::type + >::type + , int + >::value + , "remove_cref<index_type>::type == int" + ); +#elif !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ + !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::remove_const< + typename boost::remove_reference<index_type>::type + >::type + , int + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif // BOOST_PARAMETER_CAN_USE_MP11 || Borland/MSVC workarounds not needed + + tester(name, value, index); + + return 1; + } +} // namespace test + +#include <string> + +#if !defined(BOOST_NO_SFINAE) +#include <boost/parameter/aux_/preprocessor/nullptr.hpp> +#include <boost/core/enable_if.hpp> +#if !defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/type_traits/is_base_of.hpp> +#include <boost/type_traits/is_convertible.hpp> +#endif +#endif + +namespace test { + + struct base_0 + { + float f; + int i; + + template <typename Args> + explicit base_0( + Args const& args +#if !defined(BOOST_NO_SFINAE) + , typename boost::disable_if< + typename boost::mpl::if_< + boost::is_base_of<base_0,Args> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + >::type* = BOOST_PARAMETER_AUX_PP_NULLPTR +#endif // BOOST_NO_SFINAE + ) : f(args[test::_value | 1.f]), i(args[test::_index | 2]) + { + } + }; + + struct class_0 : test::base_0 + { + BOOST_PARAMETER_CONSTRUCTOR(class_0, (test::base_0), test::tag, + (optional + (value, *) + (index, *) + ) + ) + + BOOST_PARAMETER_BASIC_FUNCTION_CALL_OPERATOR((int), test::tag, + (optional + (value, *) + (index, *) + ) + ) + { + this->f = args[test::_value | 2.f]; + this->i = args[test::_index | 1]; + return 1; + } + }; + + struct base_1 + { + template <typename Args> + explicit base_1( + Args const& args +#if !defined(BOOST_NO_SFINAE) + , typename boost::disable_if< +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + std::is_base_of<base_1,Args> +#else + typename boost::mpl::if_< + boost::is_base_of<base_1,Args> + , boost::mpl::true_ + , boost::mpl::false_ + >::type +#endif + >::type* = BOOST_PARAMETER_AUX_PP_NULLPTR +#endif // BOOST_NO_SFINAE + ) + { + args[test::_tester]( + args[test::_name] + , args[test::_value | 1.f] + , args[test::_index | 2] + ); + } + }; + + struct class_1 : test::base_1 + { + BOOST_PARAMETER_CONSTRUCTOR(class_1, (test::base_1), test::tag, + (required + (tester, *) + (name, *) + ) + (optional + (value, *) + (index, *) + ) + ) + + BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((int), f, test::tag, + (required + (tester, *) + (name, *) + ) + (optional + (value, *) + (index, *) + ) + ) + { + args[test::_tester]( + args[test::_name] + , args[test::_value | 1.f] + , args[test::_index | 2] + ); + + return 1; + } + + BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION((int), f, test::tag, + (required + (tester, *) + (name, *) + ) + (optional + (value, *) + (index, *) + ) + ) + { + args[test::_tester]( + args[test::_name] + , args[test::_value | 1.f] + , args[test::_index | 2] + ); + + return 1; + } + + BOOST_PARAMETER_MEMBER_FUNCTION((int), f2, test::tag, + (required + (tester, *) + (name, *) + ) + (optional + (value, *, 1.f) + (index, *, 2) + ) + ) + { + tester(name, value, index); + return 1; + } + + BOOST_PARAMETER_CONST_MEMBER_FUNCTION((int), f2, test::tag, + (required + (tester, *) + (name, *) + ) + (optional + (value, *, 1.f) + (index, *, 2) + ) + ) + { + tester(name, value, index); + return 1; + } + + BOOST_PARAMETER_MEMBER_FUNCTION((int), static f_static, test::tag, + (required + (tester, *) + (name, *) + ) + (optional + (value, *, 1.f) + (index, *, 2) + ) + ) + { + tester(name, value, index); + return 1; + } + + BOOST_PARAMETER_FUNCTION_CALL_OPERATOR((int), test::tag, + (required + (tester, *) + (name, *) + ) + (optional + (value, *, 1.f) + (index, *, 2) + ) + ) + { + tester(name, value, index); + return 1; + } + + BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR((int), test::tag, + (required + (tester, *) + (name, *) + ) + (optional + (value, *, 1.f) + (index, *, 2) + ) + ) + { + tester(name, value, index); + return 1; + } + }; + + BOOST_PARAMETER_FUNCTION((int), sfinae, test::tag, + (required + (name, (std::string)) + ) + ) + { + return 1; + } + +#if !defined(BOOST_NO_SFINAE) + // On compilers that actually support SFINAE, add another overload + // that is an equally good match and can only be in the overload set + // when the others are not. This tests that the SFINAE is actually + // working. On all other compilers we're just checking that everything + // about SFINAE-enabled code will work, except of course the SFINAE. + template <typename A0> + typename boost::enable_if< +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + std::is_same<int,A0> +#else + typename boost::mpl::if_< + boost::is_same<int,A0> + , boost::mpl::true_ + , boost::mpl::false_ + >::type +#endif + , int + >::type + sfinae(A0 const& a0) + { + return 0; + } +#endif // BOOST_NO_SFINAE + + struct predicate + { + template <typename T, typename Args> +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + using fn = std::is_convertible<T,std::string>; +#else + struct apply + : boost::mpl::if_< + boost::is_convertible<T,std::string> + , boost::mpl::true_ + , boost::mpl::false_ + > + { + }; +#endif + + BOOST_PARAMETER_BASIC_CONST_FUNCTION_CALL_OPERATOR((bool), test::tag, + (required + (value, *) + (index, *) + ) + ) + { + return args[test::_value] < args[test::_index]; + } + }; + + BOOST_PARAMETER_FUNCTION((int), sfinae1, test::tag, + (required + (name, *(test::predicate)) + ) + ) + { + return 1; + } + +#if !defined(BOOST_NO_SFINAE) + // On compilers that actually support SFINAE, add another overload + // that is an equally good match and can only be in the overload set + // when the others are not. This tests that the SFINAE is actually + // working. On all other compilers we're just checking that everything + // about SFINAE-enabled code will work, except of course the SFINAE. + template <typename A0> + typename boost::enable_if< +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + std::is_same<int,A0> +#else + typename boost::mpl::if_< + boost::is_same<int,A0> + , boost::mpl::true_ + , boost::mpl::false_ + >::type +#endif + , int + >::type + sfinae1(A0 const& a0) + { + return 0; + } +#endif // BOOST_NO_SFINAE + + struct udt + { + udt(int foo_, int bar_) : foo(foo_), bar(bar_) + { + } + + int foo; + int bar; + }; + + BOOST_PARAMETER_FUNCTION((int), lazy_defaults, test::tag, + (required + (name, *) + ) + (optional + (value, *, name.foo) + (index, *, name.bar) + ) + ) + { + return 0; + } +} // namespace test + +#if BOOST_WORKAROUND(BOOST_MSVC, == 1300) +#include <boost/parameter/aux_/as_lvalue.hpp> +#endif + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + test::f( + test::values(std::string("foo"), 1.f, 2) + , std::string("foo") + ); + test::f( + test::_tester = test::values(std::string("foo"), 1.f, 2) + , test::_name = std::string("foo") + ); + + int index_lvalue = 2; + + test::f( + test::_tester = test::values(std::string("foo"), 1.f, 2) + , test::_name = std::string("foo") + , test::_value = 1.f + , test::_index = index_lvalue + ); + + test::f( + test::values(std::string("foo"), 1.f, 2) + , std::string("foo") + , 1.f + , index_lvalue + ); + + test::g( + test::values(std::string("foo"), 1.f, 2) + , std::string("foo") + , 1.f +#if BOOST_WORKAROUND(BOOST_MSVC, == 1300) + , boost::parameter::aux::as_lvalue(2) +#else + , 2 +#endif + ); + + test::h( + test::values(std::string("foo"), 1.f, 2) + , std::string("foo") + , 1.f +#if BOOST_WORKAROUND(BOOST_MSVC, == 1300) + , boost::parameter::aux::as_lvalue(2) +#else + , 2 +#endif + ); + + test::h2( + test::_tester = test::values(std::string("foo"), 1.f, 2) + , test::_name = std::string("foo") + , test::_value = 1.f + ); + + test::class_0 u; + + BOOST_TEST(2 == u.i); + BOOST_TEST(1.f == u.f); + + u(); + + BOOST_TEST(1 == u.i); + BOOST_TEST(2.f == u.f); + + test::class_1 x( + test::values(std::string("foo"), 1.f, 2) + , std::string("foo") + , test::_index = 2 + ); + + x.f(test::values(std::string("foo"), 1.f, 2), std::string("foo")); + x.f( + test::_tester = test::values(std::string("foo"), 1.f, 2) + , test::_name = std::string("foo") + ); + x.f2(test::values(std::string("foo"), 1.f, 2), std::string("foo")); + x.f2( + test::_tester = test::values(std::string("foo"), 1.f, 2) + , test::_name = std::string("foo") + ); + x(test::values(std::string("foo"), 1.f, 2), std::string("foo")); + x( + test::_tester = test::values(std::string("foo"), 1.f, 2) + , test::_name = std::string("foo") + ); + + test::class_1 const& x_const = x; + + x_const.f(test::values(std::string("foo"), 1.f, 2), std::string("foo")); + x_const.f( + test::_tester = test::values(std::string("foo"), 1.f, 2) + , test::_name = std::string("foo") + ); + x_const.f2(test::values(std::string("foo"), 1.f, 2), std::string("foo")); + x_const.f2( + test::_tester = test::values(std::string("foo"), 1.f, 2) + , test::_name = std::string("foo") + ); + test::class_1::f_static( + test::values(std::string("foo"), 1.f, 2) + , std::string("foo") + ); + test::class_1::f_static( + test::_tester = test::values(std::string("foo"), 1.f, 2) + , test::_name = std::string("foo") + ); + x_const(test::values(std::string("foo"), 1.f, 2), std::string("foo")); + x_const( + test::_tester = test::values(std::string("foo"), 1.f, 2) + , test::_name = std::string("foo") + ); + + test::predicate p; + test::predicate const& p_const = p; + + BOOST_TEST(p_const(3, 4)); + BOOST_TEST(!p_const(4, 3)); + BOOST_TEST(!p_const(test::_index = 3, test::_value = 4)); + +#if !defined(BOOST_NO_SFINAE) && \ + !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) + // GCC 3- tries to bind string literals + // to non-const references to char const*. + // BOOST_TEST(test::sfinae("foo") == 1); + char const* foo_str = "foo"; + BOOST_TEST(test::sfinae(foo_str) == 1); + BOOST_TEST(test::sfinae(1) == 0); + +#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) + // Sun actually eliminates the desired overload for some reason. + // Disabling this part of the test because SFINAE abilities are + // not the point of this test. + BOOST_TEST(test::sfinae1(foo_str) == 1); +#endif + + BOOST_TEST(test::sfinae1(1) == 0); +#endif + + test::lazy_defaults(test::_name = test::udt(0, 1)); + test::lazy_defaults(test::_name = 0, test::_value = 1, test::_index = 2); + + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/preprocessor_deduced.cpp b/src/boost/libs/parameter/test/preprocessor_deduced.cpp new file mode 100644 index 000000000..f3c89172d --- /dev/null +++ b/src/boost/libs/parameter/test/preprocessor_deduced.cpp @@ -0,0 +1,443 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> +#include <boost/parameter/preprocessor.hpp> +#include <boost/parameter/name.hpp> +#include <boost/tuple/tuple.hpp> +#include <map> +#include <string> +#include "basics.hpp" + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/parameter/value_type.hpp> +#include <boost/mp11/map.hpp> +#include <boost/core/enable_if.hpp> +#include <type_traits> +#else +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_convertible.hpp> +#if !defined(BOOST_NO_SFINAE) +#include <boost/parameter/value_type.hpp> +#include <boost/mpl/has_key.hpp> +#include <boost/core/enable_if.hpp> +#include <boost/type_traits/is_same.hpp> +#endif +#endif + +namespace test { + + BOOST_PARAMETER_NAME(expected) + BOOST_PARAMETER_NAME(x) + BOOST_PARAMETER_NAME(y) + BOOST_PARAMETER_NAME(z) + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + template <typename To> + struct predicate + { + template <typename From, typename Args> + using fn = std::is_convertible<From,To>; + }; + + BOOST_PARAMETER_FUNCTION((int), f, test::tag, + (required + (expected, *) + ) + (deduced + (required + (x, *(test::predicate<int>)) + (y, *(test::predicate<std::string>)) + ) + ) + ) +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + struct predicate_int + { + template <typename From, typename Args> + struct apply + : boost::mpl::if_< + boost::is_convertible<From,int> + , boost::mpl::true_ + , boost::mpl::false_ + > + { + }; + }; + + struct predicate_string + { + template <typename From, typename Args> + struct apply + : boost::mpl::if_< + boost::is_convertible<From,std::string> + , boost::mpl::true_ + , boost::mpl::false_ + > + { + }; + }; + + BOOST_PARAMETER_FUNCTION((int), f, test::tag, + (required + (expected, *) + ) + (deduced + (required + (x, *(test::predicate_int)) + (y, *(test::predicate_string)) + ) + ) + ) +#endif // BOOST_PARAMETER_CAN_USE_MP11 + { + BOOST_TEST(test::equal(x, boost::tuples::get<0>(expected))); + BOOST_TEST(test::equal(y, boost::tuples::get<1>(expected))); + return 1; + } + + struct X + { + X(int x_ = -1) : x(x_) + { + } + + bool operator==(X const& other) const + { + return this->x == other.x; + } + + int x; + }; + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + BOOST_PARAMETER_FUNCTION((int), g, test::tag, + (required + (expected, *) + ) + (deduced + (required + (x, *(test::predicate<int>)) + (y, *(test::predicate<std::string>)) + ) + (optional + (z, *(test::predicate<test::X>), test::X()) + ) + ) + ) +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + struct predicate_X + { + template <typename From, typename Args> + struct apply + : boost::mpl::if_< + boost::is_convertible<From,test::X> + , boost::mpl::true_ + , boost::mpl::false_ + > + { + }; + }; + + BOOST_PARAMETER_FUNCTION((int), g, tag, + (required + (expected, *) + ) + (deduced + (required + (x, *(test::predicate_int)) + (y, *(test::predicate_string)) + ) + (optional + (z, *(test::predicate_X), test::X()) + ) + ) + ) +#endif // BOOST_PARAMETER_CAN_USE_MP11 + { + BOOST_TEST(test::equal(x, boost::tuples::get<0>(expected))); + BOOST_TEST(test::equal(y, boost::tuples::get<1>(expected))); + BOOST_TEST(test::equal(z, boost::tuples::get<2>(expected))); + return 1; + } + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + BOOST_PARAMETER_FUNCTION((int), sfinae, test::tag, + (deduced + (required + (x, *(test::predicate<std::string>)) + ) + ) + ) +#else + BOOST_PARAMETER_FUNCTION((int), sfinae, test::tag, + (deduced + (required + (x, *(test::predicate_string)) + ) + ) + ) +#endif + { + return 1; + } + +#if !defined(BOOST_NO_SFINAE) + // On compilers that actually support SFINAE, add another overload + // that is an equally good match and can only be in the overload set + // when the others are not. This tests that the SFINAE is actually + // working. On all other compilers we're just checking that everything + // about SFINAE-enabled code will work, except of course the SFINAE. + template <typename A0> + typename boost::enable_if< +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + std::is_same<int,A0> +#else + typename boost::mpl::if_< + boost::is_same<int,A0> + , boost::mpl::true_ + , boost::mpl::false_ + >::type +#endif + , int + >::type + sfinae(A0 const& a0) + { + return 0; + } + +#if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) || \ + !BOOST_WORKAROUND(BOOST_MSVC, < 1800) + // Test support for two different Boost.Parameter-enabled + // function call operator overloads. + class char_read_base + { + int index; + char const* key; + + public: + template <typename Args> + explicit char_read_base(Args const& args) + : index(args[test::_y]), key(args[test::_z]) + { + } + + BOOST_PARAMETER_FUNCTION_CALL_OPERATOR((void), test::tag, + (deduced + (required + (y, (int)) + (z, (char const*)) + ) + ) + ) + { + this->index = y; + this->key = z; + } + + BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR((char), test::tag, + (deduced + (required + (y, (bool)) + (z, (std::map<char const*,std::string>)) + ) + ) + ) + { + return y ? ( + (z.find(this->key)->second)[this->index] + ) : this->key[this->index]; + } + }; + + struct char_reader : public char_read_base + { + BOOST_PARAMETER_CONSTRUCTOR(char_reader, (char_read_base), test::tag, + (deduced + (required + (y, (int)) + (z, (char const*)) + ) + ) + ) + }; +#endif // MSVC-11.0- + + // Test Boost.Parameter-enabled functions + // with parameter-dependent return types. +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE) +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + BOOST_PARAMETER_FUNCTION( + ( + boost::lazy_enable_if< + boost::mp11::mp_map_contains<Args,test::tag::y> + , boost::parameter::value_type<Args,test::tag::y> + > + ), return_y, test::tag, + (deduced + (required + (x, (std::map<char const*,std::string>)) + (y, (char const*)) + ) + (optional + (z, (int), 4) + ) + ) + ) +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + BOOST_PARAMETER_FUNCTION( + ( + boost::lazy_enable_if< + typename boost::mpl::has_key<Args,test::tag::y>::type + , boost::parameter::value_type<Args,test::tag::y> + > + ), return_y, test::tag, + (deduced + (required + (x, (std::map<char const*,std::string>)) + (y, (char const*)) + ) + (optional + (z, (int), 4) + ) + ) + ) +#endif // BOOST_PARAMETER_CAN_USE_MP11 + { + return y; + } +#endif // LIBS_PARAMETER_TEST_COMPILE_FAILURE +#endif // BOOST_NO_SFINAE + +#if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE) + BOOST_PARAMETER_FUNCTION( + (typename boost::parameter::value_type<Args,test::tag::y>::type), + return_y, test::tag, + (deduced + (required + (x, (std::map<char const*,std::string>)) + (y, (char const*)) + ) + (optional + (z, (int), 4) + ) + ) + ) + { + return y; + } +#endif // defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE) +} // namespace test + +#include <boost/core/lightweight_test.hpp> + +int main() +{ + test::f( + boost::make_tuple(0, std::string("foo")) + , test::_x = 0 + , test::_y = std::string("foo") + ); + test::f( + boost::make_tuple(0, std::string("foo")) + , 0 + , std::string("foo") + ); + test::f( + boost::make_tuple(0, std::string("foo")) + , std::string("foo") + , 0 + ); + test::f( + boost::make_tuple(0, std::string("foo")) + , test::_y = std::string("foo") + , 0 + ); + test::f( + boost::make_tuple(0, std::string("foo")) + , test::_x = 0 + , std::string("foo") + ); + test::f( + boost::make_tuple(0, std::string("foo")) + , 0 + , test::_y = std::string("foo") + ); + test::g( + boost::make_tuple(0, std::string("foo"), test::X()) + , test::_x = 0 + , test::_y = std::string("foo") + ); + test::g( + boost::make_tuple(0, std::string("foo"), test::X()) + , 0 + , std::string("foo") + ); + test::g( + boost::make_tuple(0, std::string("foo"), test::X()) + , std::string("foo") + , 0 + ); + test::g( + boost::make_tuple(0, std::string("foo"), test::X()) + , test::_y = std::string("foo") + , 0 + ); + test::g( + boost::make_tuple(0, std::string("foo"), test::X()) + , test::_x = 0 + , std::string("foo") + ); + test::g( + boost::make_tuple(0, std::string("foo"), test::X()) + , 0 + , test::_y = std::string("foo") + ); + test::g( + boost::make_tuple(0, std::string("foo"), test::X(1)) + , 0 + , test::_y = std::string("foo") + , test::X(1) + ); + test::g( + boost::make_tuple(0, std::string("foo"), test::X(1)) + , test::X(1) + , 0 + , test::_y = std::string("foo") + ); + + std::map<char const*,std::string> k2s; +#if !defined(BOOST_NO_SFINAE) + char const* keys[] = {"foo", "bar", "baz"}; + BOOST_TEST_EQ(1, test::sfinae(keys[0])); + BOOST_TEST_EQ(0, test::sfinae(0)); +#if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) || \ + !BOOST_WORKAROUND(BOOST_MSVC, < 1800) + k2s[keys[0]] = std::string("qux"); + k2s[keys[1]] = std::string("wmb"); + k2s[keys[2]] = std::string("zxc"); + test::char_reader r(keys[0], 0); + BOOST_TEST_EQ('q', (r(k2s, true))); + BOOST_TEST_EQ('f', (r(k2s, false))); + r(keys[1], 1); + BOOST_TEST_EQ('m', (r(k2s, true))); + BOOST_TEST_EQ('a', (r(k2s, false))); + r(keys[2], 2); + BOOST_TEST_EQ('c', (r(k2s, true))); + BOOST_TEST_EQ('z', (r(k2s, false))); +#endif // MSVC-11.0- +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE) + BOOST_TEST_EQ(keys[1], test::return_y(2, k2s, keys[1])); +#endif +#endif // BOOST_NO_SFINAE + +#if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE) + BOOST_TEST_EQ(keys[1], test::return_y(2, k2s, keys[1])); +#endif + + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/preprocessor_eval_cat_8.cpp b/src/boost/libs/parameter/test/preprocessor_eval_cat_8.cpp new file mode 100644 index 000000000..1ed3212bd --- /dev/null +++ b/src/boost/libs/parameter/test/preprocessor_eval_cat_8.cpp @@ -0,0 +1,314 @@ +// Copyright Cromwell D. Enage 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> + +#if ( \ + !defined(__MINGW32__) && \ + defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) \ + ) || defined(BOOST_MSVC) +#if (BOOST_PARAMETER_MAX_ARITY < 8) +#error Define BOOST_PARAMETER_MAX_ARITY as 8 or greater. +#endif +#else // mingw, or no perfect forwarding support and not msvc +#if (BOOST_PARAMETER_COMPOSE_MAX_ARITY < 8) +#error Define BOOST_PARAMETER_COMPOSE_MAX_ARITY as 8 or greater. +#endif +#endif // msvc, or perfect forwarding support and not mingw + +#include <boost/parameter/name.hpp> + +namespace test { + + BOOST_PARAMETER_NAME((_lrc0, kw) in(lrc0)) + BOOST_PARAMETER_NAME((_lr0, kw) in_out(lr0)) + BOOST_PARAMETER_NAME((_rrc0, kw) in(rrc0)) +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_PARAMETER_NAME((_rr0, kw) consume(rr0)) +#else + BOOST_PARAMETER_NAME((_rr0, kw) rr0) +#endif + BOOST_PARAMETER_NAME((_lrc1, kw) in(lrc1)) + BOOST_PARAMETER_NAME((_lr1, kw) out(lr1)) + BOOST_PARAMETER_NAME((_rrc1, kw) in(rrc1)) + BOOST_PARAMETER_NAME((_rr1, kw) rr1) +} // namespace test + +#include <boost/mpl/bool.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/if.hpp> +#include <boost/core/lightweight_test.hpp> +#include <boost/type_traits/is_convertible.hpp> +#include "evaluate_category.hpp" + +#if !defined(__MINGW32__) && defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) +#include <boost/parameter/preprocessor.hpp> +#include <utility> +#elif defined(BOOST_MSVC) +#include <boost/parameter/preprocessor.hpp> +#else +#include <boost/parameter/preprocessor_no_spec.hpp> +#endif + +namespace test { + + struct C + { +#if ( \ + !defined(__MINGW32__) && \ + defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) \ + ) || defined(BOOST_MSVC) + typedef boost::mpl::if_< + boost::is_convertible<boost::mpl::_,std::bitset<1> > + , boost::mpl::true_ + , boost::mpl::false_ + > bs0_pred; + typedef boost::mpl::if_< + boost::is_convertible<boost::mpl::_,std::bitset<2> > + , boost::mpl::true_ + , boost::mpl::false_ + > bs1_pred; + typedef boost::mpl::if_< + boost::is_convertible<boost::mpl::_,std::bitset<3> > + , boost::mpl::true_ + , boost::mpl::false_ + > bs2_pred; + typedef boost::mpl::if_< + boost::is_convertible<boost::mpl::_,std::bitset<4> > + , boost::mpl::true_ + , boost::mpl::false_ + > bs3_pred; + typedef boost::mpl::if_< + boost::is_convertible<boost::mpl::_,std::bitset<5> > + , boost::mpl::true_ + , boost::mpl::false_ + > bs4_pred; + typedef boost::mpl::if_< + boost::is_convertible<boost::mpl::_,std::bitset<6> > + , boost::mpl::true_ + , boost::mpl::false_ + > bs5_pred; + typedef boost::mpl::if_< + boost::is_convertible<boost::mpl::_,std::bitset<7> > + , boost::mpl::true_ + , boost::mpl::false_ + > bs6_pred; + typedef boost::mpl::if_< + boost::is_convertible<boost::mpl::_,std::bitset<8> > + , boost::mpl::true_ + , boost::mpl::false_ + > bs7_pred; + + BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR((bool), kw, + (deduced + (required + (lrc0, *(bs0_pred)) + (lr0, *(bs1_pred)) + (rrc0, *(bs2_pred)) + (rr0, *(bs3_pred)) + (lrc1, *(bs4_pred)) + ) + (optional + (lr1, *(bs5_pred), test::lvalue_bitset<5>()) + (rrc1, *(bs6_pred), test::rvalue_const_bitset<6>()) + (rr1, *(bs7_pred), test::rvalue_bitset<7>()) + ) + ) + ) +#else + BOOST_PARAMETER_NO_SPEC_CONST_FUNCTION_CALL_OPERATOR((bool)) +#endif // msvc, or perfect forwarding support and not mingw + { +#if ( \ + !defined(__MINGW32__) && \ + defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) \ + ) || defined(BOOST_MSVC) + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<0>(lrc0) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::U::evaluate_category<1>(lr0) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<4>(lrc1) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::U::evaluate_category<5>(lr1) + ); +#else // mingw, or no perfect forwarding support and not msvc + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<0>(args[test::_lrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::U::evaluate_category<1>(args[test::_lr0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<4>(args[test::_lrc1]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::U::evaluate_category<5>( + args[test::_lr1 | test::lvalue_bitset<5>()] + ) + ); +#endif // msvc, or perfect forwarding support and not mingw +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) +#if defined(__MINGW32__) + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<2>(args[test::_rrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference + , test::U::evaluate_category<3>(args[test::_rr0]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<6>( + args[test::_rrc1 | test::rvalue_const_bitset<6>()] + ) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference + , test::U::evaluate_category<7>( + args[test::_rr1 | test::rvalue_bitset<7>()] + ) + ); +#else // !defined(__MINGW32__) + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<2>(std::forward<rrc0_type>(rrc0)) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference + , test::U::evaluate_category<3>(std::forward<rr0_type>(rr0)) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<6>(std::forward<rrc1_type>(rrc1)) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference + , test::U::evaluate_category<7>(std::forward<rr1_type>(rr1)) + ); +#endif // __MINGW32__ +#else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) +#if defined(BOOST_MSVC) + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<2>(rrc0) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<3>(rr0) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<6>(rrc1) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<7>(rr1) + ); +#else // !defined(BOOST_MSVC) + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<2>(args[test::_rrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<3>(args[test::_rr0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<6>( + args[test::_rrc1 | test::rvalue_const_bitset<6>()] + ) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<7>( + args[test::_rr1 | test::rvalue_bitset<7>()] + ) + ); +#endif // BOOST_MSVC +#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING + + return true; + } + }; +} // namespace test + +int main() +{ + test::C cp0; + test::C cp1; + +#if ( \ + !defined(__MINGW32__) && \ + defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) \ + ) || defined(BOOST_MSVC) + cp0( + test::lvalue_const_bitset<4>() + , test::lvalue_const_bitset<0>() + , test::lvalue_bitset<1>() + , test::rvalue_const_bitset<2>() + , test::rvalue_bitset<3>() + ); + cp0( + test::lvalue_const_bitset<4>() + , test::lvalue_const_bitset<0>() + , test::rvalue_const_bitset<6>() + , test::lvalue_bitset<1>() + , test::rvalue_const_bitset<2>() + , test::rvalue_bitset<3>() + ); + cp1( + test::lvalue_bitset<1>() + , test::rvalue_const_bitset<2>() + , test::rvalue_bitset<3>() + , test::lvalue_const_bitset<4>() + , test::lvalue_bitset<5>() + , test::rvalue_const_bitset<6>() + , test::rvalue_bitset<7>() + , test::lvalue_const_bitset<0>() + ); +#else // mingw, or no perfect forwarding support and not msvc + cp0( + test::_lrc1 = test::lvalue_const_bitset<4>() + , test::_lrc0 = test::lvalue_const_bitset<0>() + , test::_lr0 = test::lvalue_bitset<1>() + , test::_rrc0 = test::rvalue_const_bitset<2>() + , test::_rr0 = test::rvalue_bitset<3>() + ); + cp0( + test::_lrc1 = test::lvalue_const_bitset<4>() + , test::_lrc0 = test::lvalue_const_bitset<0>() + , test::_rrc1 = test::rvalue_const_bitset<6>() + , test::_lr0 = test::lvalue_bitset<1>() + , test::_rrc0 = test::rvalue_const_bitset<2>() + , test::_rr0 = test::rvalue_bitset<3>() + ); + cp1( + test::_lr0 = test::lvalue_bitset<1>() + , test::_rrc0 = test::rvalue_const_bitset<2>() + , test::_rr0 = test::rvalue_bitset<3>() + , test::_lrc1 = test::lvalue_const_bitset<4>() + , test::_lr1 = test::lvalue_bitset<5>() + , test::_rrc1 = test::rvalue_const_bitset<6>() + , test::_rr1 = test::rvalue_bitset<7>() + , test::_lrc0 = test::lvalue_const_bitset<0>() + ); +#endif // msvc, or perfect forwarding support and not mingw + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/preprocessor_eval_cat_no_spec.cpp b/src/boost/libs/parameter/test/preprocessor_eval_cat_no_spec.cpp new file mode 100644 index 000000000..44c90b89c --- /dev/null +++ b/src/boost/libs/parameter/test/preprocessor_eval_cat_no_spec.cpp @@ -0,0 +1,525 @@ +// Copyright Cromwell D. Enage 2018. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> + +#if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ + (BOOST_PARAMETER_COMPOSE_MAX_ARITY < 8) +#error Define BOOST_PARAMETER_COMPOSE_MAX_ARITY as 8 or greater. +#endif + +#include <boost/parameter/name.hpp> + +namespace test { + + BOOST_PARAMETER_NAME((_lrc0, kw0) in(lrc0)) + BOOST_PARAMETER_NAME((_lr0, kw1) in_out(lr0)) + BOOST_PARAMETER_NAME((_rrc0, kw2) in(rrc0)) +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_PARAMETER_NAME((_rr0, kw3) consume(rr0)) +#else + BOOST_PARAMETER_NAME((_rr0, kw3) rr0) +#endif + BOOST_PARAMETER_NAME((_lrc1, kw4) in(lrc1)) + BOOST_PARAMETER_NAME((_lr1, kw5) out(lr1)) + BOOST_PARAMETER_NAME((_rrc1, kw6) in(rrc1)) + BOOST_PARAMETER_NAME((_rr1, kw7) rr1) +} // namespace test + +#include <boost/parameter/preprocessor_no_spec.hpp> +#include <boost/parameter/value_type.hpp> +#include <boost/core/lightweight_test.hpp> +#include <boost/type_traits/is_scalar.hpp> +#include <boost/type_traits/remove_const.hpp> +#include "evaluate_category.hpp" + +namespace test { + + BOOST_PARAMETER_NO_SPEC_FUNCTION((bool), evaluate) + { + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw0::lrc0 + >::type + >::type + >::evaluate_category(args[test::_lrc0]) + )); + BOOST_TEST(( + test::passed_by_lvalue_reference == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw1::lr0 + >::type + >::type + >::evaluate_category(args[test::_lr0]) + )); + +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + if ( + boost::is_scalar< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw2::rrc0 + >::type + >::type + >::value + ) + { + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw2::rrc0 + >::type + >::type + >::evaluate_category(args[test::_rrc0]) + )); + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw3::rr0 + >::type + >::type + >::evaluate_category(args[test::_rr0]) + )); + } + else // rrc0's value type isn't scalar + { + BOOST_TEST(( + test::passed_by_rvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw2::rrc0 + >::type + >::type + >::evaluate_category(args[test::_rrc0]) + )); + BOOST_TEST(( + test::passed_by_rvalue_reference == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw3::rr0 + >::type + >::type + >::evaluate_category(args[test::_rr0]) + )); + } +#else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw2::rrc0 + >::type + >::type + >::evaluate_category(args[test::_rrc0]) + )); + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw3::rr0 + >::type + >::type + >::evaluate_category(args[test::_rr0]) + )); +#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING + + return true; + } +} // namespace test + +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> + +#if !defined(BOOST_NO_SFINAE) +#include <boost/parameter/aux_/preprocessor/nullptr.hpp> +#include <boost/core/enable_if.hpp> +#include <boost/type_traits/is_base_of.hpp> +#endif + +namespace test { + + char const* baz = "baz"; + + struct B + { +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1800) + B() + { + } +#endif + + template <typename Args> + explicit B( + Args const& args +#if !defined(BOOST_NO_SFINAE) + , typename boost::disable_if< + typename boost::mpl::if_< + boost::is_base_of<B,Args> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + >::type* = BOOST_PARAMETER_AUX_PP_NULLPTR +#endif // BOOST_NO_SFINAE + ) + { + test::evaluate( + test::_lrc0 = args[test::_lrc0] + , test::_lr0 = args[test::_lr0] + , test::_rrc0 = args[test::_rrc0] + , test::_rr0 = args[test::_rr0] + ); + } + + BOOST_PARAMETER_NO_SPEC_MEMBER_FUNCTION((bool), static evaluate) + { + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw0::lrc0 + >::type + >::type + >::evaluate_category(args[test::_lrc0]) + )); + BOOST_TEST(( + test::passed_by_lvalue_reference == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw1::lr0 + , char const* + >::type + >::type + >::evaluate_category(args[test::_lr0 | test::baz]) + )); + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw2::rrc0 + , float + >::type + >::type + >::evaluate_category(args[test::_rrc0 | 0.0f]) + )); + +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST(( + test::passed_by_rvalue_reference == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw3::rr0 + , std::string + >::type + >::type + >::evaluate_category( + args[ + test::_rr0 | std::string(args[test::_lr0 | test::baz]) + ] + ) + )); +#else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw3::rr0 + , std::string + >::type + >::type + >::evaluate_category( + args[ + test::_rr0 | std::string(args[test::_lr0 | test::baz]) + ] + ) + )); +#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING + + return true; + } + }; + + struct C : B + { +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1800) + C() : B() + { + } +#endif + + BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR(C, (B)) + }; + + struct D + { + BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR(D, D::_evaluate) + + BOOST_PARAMETER_NO_SPEC_CONST_MEMBER_FUNCTION((bool), evaluate_m) + { + return D::_evaluate(args); + } + + BOOST_PARAMETER_NO_SPEC_CONST_FUNCTION_CALL_OPERATOR((bool)) + { + return D::_evaluate(args); + } + + private: + template <typename Args> + static bool _evaluate(Args const& args) + { + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<0>(args[test::_lrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::U::evaluate_category<1>(args[test::_lr0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<4>(args[test::_lrc1]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::U::evaluate_category<5>( + args[test::_lr1 | test::lvalue_bitset<5>()] + ) + ); +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<2>(args[test::_rrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference + , test::U::evaluate_category<3>(args[test::_rr0]) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::U::evaluate_category<6>( + args[test::_rrc1 | test::rvalue_const_bitset<6>()] + ) + ); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference + , test::U::evaluate_category<7>( + args[test::_rr1 | test::rvalue_bitset<7>()] + ) + ); +#else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<2>(args[test::_rrc0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<3>(args[test::_rr0]) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<6>( + args[test::_rrc1 | test::rvalue_const_bitset<6>()] + ) + ); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::U::evaluate_category<7>( + args[test::_rr1 | test::rvalue_bitset<7>()] + ) + ); +#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING + + return true; + } + }; +} // namespace test + +int main() +{ + test::evaluate( + test::_lr0 = test::lvalue_float() + , test::_rrc0 = test::rvalue_const_float() + , test::_rr0 = test::rvalue_float() + , test::_lrc0 = test::lvalue_const_float() + ); + test::evaluate( + test::_lr0 = test::lvalue_char_ptr() + , test::_rrc0 = test::rvalue_const_char_ptr() + , test::_rr0 = test::rvalue_char_ptr() + , test::_lrc0 = test::lvalue_const_char_ptr() + ); + test::evaluate( + test::_lr0 = test::lvalue_str() + , test::_rrc0 = test::rvalue_const_str() + , test::_rr0 = test::rvalue_str() + , test::_lrc0 = test::lvalue_const_str() + ); + + test::C cf1( + test::_lr0 = test::lvalue_float() + , test::_rrc0 = test::rvalue_const_float() + , test::_rr0 = test::rvalue_float() + , test::_lrc0 = test::lvalue_const_float() + ); + test::C cc1( + test::_lr0 = test::lvalue_char_ptr() + , test::_rrc0 = test::rvalue_const_char_ptr() + , test::_rr0 = test::rvalue_char_ptr() + , test::_lrc0 = test::lvalue_const_char_ptr() + ); + test::C cs1( + test::_lr0 = test::lvalue_str() + , test::_rrc0 = test::rvalue_const_str() + , test::_rr0 = test::rvalue_str() + , test::_lrc0 = test::lvalue_const_str() + ); + + char baz_arr[4] = "qux"; + typedef char char_arr[4]; + +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && ( \ + BOOST_WORKAROUND(BOOST_GCC, < 40000) || \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1800) \ + ) + // MSVC-12+ treats static_cast<char_arr&&>(baz_arr) as an lvalue. + // GCC 3- tries to bind string literals + // to non-const references to char const*. +#else + test::evaluate( + test::_lr0 = baz_arr +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + , test::_rrc0 = static_cast<char_arr const&&>("def") + , test::_rr0 = static_cast<char_arr&&>(baz_arr) +#else + , test::_rrc0 = "grl" + , test::_rr0 = "grp" +#endif + , test::_lrc0 = "wld" + ); +#endif // MSVC-12+ + test::B::evaluate(test::_lrc0 = test::lvalue_const_str()[0]); + test::C::evaluate( + test::_rrc0 = test::rvalue_const_float() + , test::_lrc0 = test::lvalue_const_str()[0] + ); + +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1800) + // MSVC-12+ treats static_cast<char_arr&&>(baz_arr) as an lvalue. + test::C cp0; + test::C cp1; +#else + test::C cp0( + test::_lrc0 = "frd" + , test::_lr0 = baz_arr +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + , test::_rrc0 = static_cast<char_arr const&&>("dfs") + , test::_rr0 = static_cast<char_arr&&>(baz_arr) +#else + , test::_rrc0 = "plg" + , test::_rr0 = "thd" +#endif + ); + test::C cp1( + test::_lr0 = baz_arr +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + , test::_rrc0 = static_cast<char_arr const&&>("dgx") + , test::_rr0 = static_cast<char_arr&&>(baz_arr) +#else + , test::_rrc0 = "hnk" + , test::_rr0 = "xzz" +#endif + , test::_lrc0 = "zts" + ); +#endif // MSVC-12+ + + cp0.evaluate( + test::_lrc0 = test::lvalue_const_str()[0] + , test::_lr0 = test::lvalue_char_ptr() + , test::_rr0 = test::rvalue_str() + , test::_rrc0 = test::rvalue_const_float() + ); + cp1.evaluate( + test::_lrc0 = test::lvalue_const_str()[0] + , test::_rr0 = test::rvalue_str() + , test::_rrc0 = test::rvalue_const_float() + , test::_lr0 = test::lvalue_char_ptr() + ); + + test::D dp0( + test::_lrc1 = test::lvalue_const_bitset<4>() + , test::_lrc0 = test::lvalue_const_bitset<0>() + , test::_lr0 = test::lvalue_bitset<1>() + , test::_rrc0 = test::rvalue_const_bitset<2>() + , test::_rr0 = test::rvalue_bitset<3>() + ); + test::D dp1( + test::_lrc1 = test::lvalue_const_bitset<4>() + , test::_lrc0 = test::lvalue_const_bitset<0>() + , test::_rrc1 = test::rvalue_const_bitset<6>() + , test::_lr0 = test::lvalue_bitset<1>() + , test::_rrc0 = test::rvalue_const_bitset<2>() + , test::_rr0 = test::rvalue_bitset<3>() + ); + + dp0.evaluate_m( + test::_lrc1 = test::lvalue_const_bitset<4>() + , test::_lrc0 = test::lvalue_const_bitset<0>() + , test::_rrc1 = test::rvalue_const_bitset<6>() + , test::_lr0 = test::lvalue_bitset<1>() + , test::_rrc0 = test::rvalue_const_bitset<2>() + , test::_rr0 = test::rvalue_bitset<3>() + ); + dp1.evaluate_m( + test::_lr0 = test::lvalue_bitset<1>() + , test::_rrc0 = test::rvalue_const_bitset<2>() + , test::_rr0 = test::rvalue_bitset<3>() + , test::_lrc1 = test::lvalue_const_bitset<4>() + , test::_lr1 = test::lvalue_bitset<5>() + , test::_rrc1 = test::rvalue_const_bitset<6>() + , test::_rr1 = test::rvalue_bitset<7>() + , test::_lrc0 = test::lvalue_const_bitset<0>() + ); + dp0( + test::_lrc1 = test::lvalue_const_bitset<4>() + , test::_lrc0 = test::lvalue_const_bitset<0>() + , test::_lr0 = test::lvalue_bitset<1>() + , test::_rrc0 = test::rvalue_const_bitset<2>() + , test::_rr0 = test::rvalue_bitset<3>() + ); + dp1( + test::_lr0 = test::lvalue_bitset<1>() + , test::_rrc0 = test::rvalue_const_bitset<2>() + , test::_rr0 = test::rvalue_bitset<3>() + , test::_lrc1 = test::lvalue_const_bitset<4>() + , test::_lr1 = test::lvalue_bitset<5>() + , test::_rrc1 = test::rvalue_const_bitset<6>() + , test::_rr1 = test::rvalue_bitset<7>() + , test::_lrc0 = test::lvalue_const_bitset<0>() + ); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/preprocessor_eval_category.cpp b/src/boost/libs/parameter/test/preprocessor_eval_category.cpp new file mode 100644 index 000000000..6dafd46f2 --- /dev/null +++ b/src/boost/libs/parameter/test/preprocessor_eval_category.cpp @@ -0,0 +1,571 @@ +// Copyright Cromwell D. Enage 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> + +#if (BOOST_PARAMETER_MAX_ARITY < 4) +#error Define BOOST_PARAMETER_MAX_ARITY as 4 or greater. +#endif +#if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ + (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 5) +#error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \ +as 5 or greater. +#endif + +#include <boost/parameter/name.hpp> + +namespace test { + + BOOST_PARAMETER_NAME((_lrc0, kw) in(lrc0)) + BOOST_PARAMETER_NAME((_lr0, kw) in_out(lr0)) + BOOST_PARAMETER_NAME((_rrc0, kw) in(rrc0)) +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_PARAMETER_NAME((_rr0, kw) consume(rr0)) +#else + BOOST_PARAMETER_NAME((_rr0, kw) rr0) +#endif +} // namespace test + +#include <boost/parameter/preprocessor.hpp> +#include <boost/parameter/value_type.hpp> +#include <boost/core/lightweight_test.hpp> +#include <boost/type_traits/is_scalar.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include "evaluate_category.hpp" + +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) +#include <utility> +#endif + +namespace test { + + BOOST_PARAMETER_FUNCTION((bool), evaluate, kw, + (required + (lrc0, *) + (lr0, *) + (rrc0, *) + (rr0, *) + ) + ) + { + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw::lrc0 + >::type + >::type + >::evaluate_category(args[test::_lrc0]) + )); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::A< + typename boost::remove_const< + typename boost::remove_reference<lrc0_type>::type + >::type + >::evaluate_category(lrc0) + ); + BOOST_TEST(( + test::passed_by_lvalue_reference == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw::lr0 + >::type + >::type + >::evaluate_category(args[test::_lr0]) + )); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::A< + typename boost::remove_const< + typename boost::remove_reference<lr0_type>::type + >::type + >::evaluate_category(lr0) + ); + +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + if ( + boost::is_scalar< + typename boost::remove_const< + typename boost::remove_reference<rrc0_type>::type + >::type + >::value + ) + { + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw::rrc0 + >::type + >::type + >::evaluate_category(args[test::_rrc0]) + )); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::A< + typename boost::remove_const< + typename boost::remove_reference<rrc0_type>::type + >::type + >::evaluate_category(std::forward<rrc0_type>(rrc0)) + ); + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw::rr0 + >::type + >::type + >::evaluate_category(args[test::_rr0]) + )); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::A< + typename boost::remove_const< + typename boost::remove_reference<rr0_type>::type + >::type + >::evaluate_category(std::forward<rr0_type>(rr0)) + ); + } + else // rrc0's value type isn't scalar + { + BOOST_TEST(( + test::passed_by_rvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw::rrc0 + >::type + >::type + >::evaluate_category(args[test::_rrc0]) + )); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference_to_const + , test::A< + typename boost::remove_const< + typename boost::remove_reference<rrc0_type>::type + >::type + >::evaluate_category(std::forward<rrc0_type>(rrc0)) + ); + BOOST_TEST(( + test::passed_by_rvalue_reference == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw::rr0 + >::type + >::type + >::evaluate_category(args[test::_rr0]) + )); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference + , test::A< + typename boost::remove_const< + typename boost::remove_reference<rr0_type>::type + >::type + >::evaluate_category(std::forward<rr0_type>(rr0)) + ); + } +#else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw::rrc0 + >::type + >::type + >::evaluate_category(args[test::_rrc0]) + )); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::A< + typename boost::remove_const< + typename boost::remove_reference<rrc0_type>::type + >::type + >::evaluate_category(rrc0) + ); + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw::rr0 + >::type + >::type + >::evaluate_category(args[test::_rr0]) + )); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::A< + typename boost::remove_const< + typename boost::remove_reference<rr0_type>::type + >::type + >::evaluate_category(rr0) + ); +#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING + + return true; + } +} // namespace test + +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> + +#if !defined(BOOST_NO_SFINAE) +#include <boost/parameter/aux_/preprocessor/nullptr.hpp> +#include <boost/core/enable_if.hpp> +#include <boost/type_traits/is_base_of.hpp> +#endif + +namespace test { + + char const* baz = "baz"; + + struct B + { +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1800) + B() + { + } +#endif + + template <typename Args> + explicit B( + Args const& args +#if !defined(BOOST_NO_SFINAE) + , typename boost::disable_if< + typename boost::mpl::if_< + boost::is_base_of<B,Args> + , boost::mpl::true_ + , boost::mpl::false_ + >::type + >::type* = BOOST_PARAMETER_AUX_PP_NULLPTR +#endif // BOOST_NO_SFINAE + ) + { + test::evaluate( + args[test::_lrc0] + , args[test::_lr0] + , args[test::_rrc0] + , args[test::_rr0] + ); + } + +#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) + typedef test::string_predicate<test::kw::lr0> rr0_pred; + + BOOST_PARAMETER_MEMBER_FUNCTION((bool), static evaluate, kw, + (required + (lrc0, (char)) + ) + (deduced + (optional + (rrc0, (float), 0.0f) + (lr0, (char const*), test::baz) + (rr0, *(rr0_pred), std::string(lr0)) + ) + ) + ) +#else // !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) + BOOST_PARAMETER_MEMBER_FUNCTION((bool), static evaluate, kw, + (required + (lrc0, (char)) + ) + (deduced + (optional + (rrc0, (float), 0.0f) + (lr0, (char const*), test::baz) + (rr0 + , *(test::string_predicate<test::kw::lr0>) + , std::string(lr0) + ) + ) + ) + ) +#endif // SunPro CC workarounds needed. + { + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw::lrc0 + >::type + >::type + >::evaluate_category(args[test::_lrc0]) + )); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::A< + typename boost::remove_const< + typename boost::remove_reference<lrc0_type>::type + >::type + >::evaluate_category(lrc0) + ); + BOOST_TEST(( + test::passed_by_lvalue_reference == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw::lr0 + >::type + >::type + >::evaluate_category(args[test::_lr0]) + )); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference + , test::A< + typename boost::remove_const< + typename boost::remove_reference<lr0_type>::type + >::type + >::evaluate_category(lr0) + ); + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw::rrc0 + >::type + >::type + >::evaluate_category(args[test::_rrc0]) + )); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::A< + typename boost::remove_const< + typename boost::remove_reference<rrc0_type>::type + >::type + >::evaluate_category(rrc0) + ); + +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST(( + test::passed_by_rvalue_reference == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw::rr0 + >::type + >::type + >::evaluate_category(args[test::_rr0]) + )); + BOOST_TEST_EQ( + test::passed_by_rvalue_reference + , test::A< + typename boost::remove_const< + typename boost::remove_reference<rr0_type>::type + >::type + >::evaluate_category(std::forward<rr0_type>(rr0)) + ); +#else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + BOOST_TEST(( + test::passed_by_lvalue_reference_to_const == test::A< + typename boost::remove_const< + typename boost::parameter::value_type< + Args + , test::kw::rr0 + >::type + >::type + >::evaluate_category(args[test::_rr0]) + )); + BOOST_TEST_EQ( + test::passed_by_lvalue_reference_to_const + , test::A< + typename boost::remove_const< + typename boost::remove_reference<rr0_type>::type + >::type + >::evaluate_category(rr0) + ); +#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING + + return true; + } + }; + + struct C : B + { +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1800) + C() : B() + { + } +#endif + + BOOST_PARAMETER_CONSTRUCTOR(C, (B), kw, + (required + (lrc0, *) + (lr0, *) + (rrc0, *) + (rr0, *) + ) + ) + }; +} // namespace test + +int main() +{ + test::evaluate( + test::lvalue_const_float() + , test::lvalue_float() + , test::rvalue_const_float() + , test::rvalue_float() + ); + test::evaluate( + test::lvalue_const_char_ptr() + , test::lvalue_char_ptr() + , test::rvalue_const_char_ptr() + , test::rvalue_char_ptr() + ); + test::evaluate( + test::lvalue_const_str() + , test::lvalue_str() + , test::rvalue_const_str() + , test::rvalue_str() + ); + test::evaluate( + test::_lr0 = test::lvalue_float() + , test::_rrc0 = test::rvalue_const_float() + , test::_rr0 = test::rvalue_float() + , test::_lrc0 = test::lvalue_const_float() + ); + test::evaluate( + test::_lr0 = test::lvalue_char_ptr() + , test::_rrc0 = test::rvalue_const_char_ptr() + , test::_rr0 = test::rvalue_char_ptr() + , test::_lrc0 = test::lvalue_const_char_ptr() + ); + test::evaluate( + test::_lr0 = test::lvalue_str() + , test::_rrc0 = test::rvalue_const_str() + , test::_rr0 = test::rvalue_str() + , test::_lrc0 = test::lvalue_const_str() + ); + + test::C cf0( + test::lvalue_const_float() + , test::lvalue_float() + , test::rvalue_const_float() + , test::rvalue_float() + ); + test::C cc0( + test::lvalue_const_char_ptr() + , test::lvalue_char_ptr() + , test::rvalue_const_char_ptr() + , test::rvalue_char_ptr() + ); + test::C cs0( + test::lvalue_const_str() + , test::lvalue_str() + , test::rvalue_const_str() + , test::rvalue_str() + ); + test::C cf1( + test::_lr0 = test::lvalue_float() + , test::_rrc0 = test::rvalue_const_float() + , test::_rr0 = test::rvalue_float() + , test::_lrc0 = test::lvalue_const_float() + ); + test::C cc1( + test::_lr0 = test::lvalue_char_ptr() + , test::_rrc0 = test::rvalue_const_char_ptr() + , test::_rr0 = test::rvalue_char_ptr() + , test::_lrc0 = test::lvalue_const_char_ptr() + ); + test::C cs1( + test::_lr0 = test::lvalue_str() + , test::_rrc0 = test::rvalue_const_str() + , test::_rr0 = test::rvalue_str() + , test::_lrc0 = test::lvalue_const_str() + ); + + char baz_arr[4] = "qux"; + typedef char char_arr[4]; + +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1800) + // MSVC-12+ treats static_cast<char_arr&&>(baz_arr) as an lvalue. +#else + test::evaluate( + "q2x" + , baz_arr +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + , static_cast<char_arr const&&>("mos") + , static_cast<char_arr&&>(baz_arr) +#else + , "crg" + , "uir" +#endif + ); + test::evaluate( + test::_lr0 = baz_arr +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + , test::_rrc0 = static_cast<char_arr const&&>("def") + , test::_rr0 = static_cast<char_arr&&>(baz_arr) +#else + , test::_rrc0 = "grl" + , test::_rr0 = "grp" +#endif + , test::_lrc0 = "wld" + ); +#endif // MSVC-12+ + test::B::evaluate(test::lvalue_const_str()[0]); + test::C::evaluate( + test::lvalue_const_str()[0] + , test::rvalue_const_float() + ); + +#if !defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE_VENDOR_SPECIFIC) && \ + BOOST_WORKAROUND(BOOST_MSVC, >= 1800) + // MSVC-12+ treats static_cast<char_arr&&>(baz_arr) as an lvalue. + test::C cp0; + test::C cp1; +#else + test::C cp0( + "frd" + , baz_arr +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + , static_cast<char_arr const&&>("dfs") + , static_cast<char_arr&&>(baz_arr) +#else + , "plg" + , "thd" +#endif + ); + test::C cp1( + test::_lr0 = baz_arr +#if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) + , test::_rrc0 = static_cast<char_arr const&&>("dgx") + , test::_rr0 = static_cast<char_arr&&>(baz_arr) +#else + , test::_rrc0 = "hnk" + , test::_rr0 = "xzz" +#endif + , test::_lrc0 = "zts" + ); +#endif // MSVC-12+ + + cp0.evaluate( + test::lvalue_const_str()[0] + , test::lvalue_char_ptr() + , test::rvalue_str() + , test::rvalue_const_float() + ); + cp1.evaluate( + test::lvalue_const_str()[0] + , test::rvalue_str() + , test::rvalue_const_float() + , test::lvalue_char_ptr() + ); + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/python_test.cpp b/src/boost/libs/parameter/test/python_test.cpp new file mode 100644 index 000000000..12c0c3153 --- /dev/null +++ b/src/boost/libs/parameter/test/python_test.cpp @@ -0,0 +1,172 @@ +// Copyright Daniel Wallin 2006. Use, modification and distribution is +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include <math.h> +#include <boost/python.hpp> +#include <boost/parameter/preprocessor.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/parameter/python.hpp> +#include <boost/utility/enable_if.hpp> + +namespace test { + +BOOST_PARAMETER_KEYWORD(tags, x) +BOOST_PARAMETER_KEYWORD(tags, y) +BOOST_PARAMETER_KEYWORD(tags, z) + +struct Xbase +{ + // We need the disable_if part for VC7.1/8.0. + template <class Args> + Xbase( + Args const& args + , typename boost::disable_if< + boost::is_base_and_derived<Xbase, Args> + >::type* = 0 + ) + : value(std::string(args[x | "foo"]) + args[y | "bar"]) + {} + + std::string value; +}; + +struct X : Xbase +{ + BOOST_PARAMETER_CONSTRUCTOR(X, (Xbase), tags, + (optional + (x, *) + (y, *) + ) + ) + + BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((int), f, tags, + (required + (x, *) + (y, *) + ) + (optional + (z, *) + ) + ) + { + return args[x] + args[y] + args[z | 0]; + } + + BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((std::string), g, tags, + (optional + (x, *) + (y, *) + ) + ) + { + return std::string(args[x | "foo"]) + args[y | "bar"]; + } + + BOOST_PARAMETER_MEMBER_FUNCTION((X&), h, tags, + (optional (x, *, "") (y, *, "")) + ) + { + return *this; + } + + template <class A0> + X& operator()(A0 const& a0) + { + return *this; + } +}; + +} // namespace test + +struct f_fwd +{ + template <class R, class T, class A0, class A1, class A2> + R operator()(boost::type<R>, T& self, A0 const& a0, A1 const& a1, A2 const& a2) + { + return self.f(a0,a1,a2); + } +}; + +struct g_fwd +{ + template <class R, class T, class A0, class A1> + R operator()(boost::type<R>, T& self, A0 const& a0, A1 const& a1) + { + return self.g(a0,a1); + } +}; + +struct h_fwd +{ + template <class R, class T> + R operator()(boost::type<R>, T& self) + { + return self.h(); + } + + template <class R, class T, class A0> + R operator()(boost::type<R>, T& self, A0 const& a0) + { + return self.h(a0); + } + + template <class R, class T, class A0, class A1> + R operator()(boost::type<R>, T& self, A0 const& a0, A1 const& a1) + { + return self.h(a0,a1); + } +}; + +BOOST_PYTHON_MODULE(python_test_ext) +{ + namespace mpl = boost::mpl; + using namespace test; + using namespace boost::python; + + class_<X>("X") + .def( + boost::parameter::python::init< + mpl::vector< + tags::x*(std::string), tags::y*(std::string) + > + >() + ) + .def( + "f" + , boost::parameter::python::function< + f_fwd + , mpl::vector< + int, tags::x(int), tags::y(int), tags::z*(int) + > + >() + ) + .def( + "g" + , boost::parameter::python::function< + g_fwd + , mpl::vector< + std::string, tags::x*(std::string), tags::y*(std::string) + > + >() + ) + .def( + "h" + , boost::parameter::python::function< + h_fwd + , mpl::vector< + X&, tags::x**(std::string), tags::y**(std::string) + > + >() + , return_arg<>() + ) + .def( + boost::parameter::python::call< + mpl::vector< + X&, tags::x(int) + > + >() [ return_arg<>() ] + ) + .def_readonly("value", &X::value); +} + diff --git a/src/boost/libs/parameter/test/python_test.py b/src/boost/libs/parameter/test/python_test.py new file mode 100644 index 000000000..ce3b81c2f --- /dev/null +++ b/src/boost/libs/parameter/test/python_test.py @@ -0,0 +1,41 @@ +# Copyright Daniel Wallin 2006. Distributed under the +# Boost Software License, Version 1.0. (See accompanying file +# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +''' +>>> from python_test_ext import X +>>> x = X(y = 'baz') +>>> x.value +'foobaz' +>>> x.f(1,2) +3 +>>> x.f(1,2,3) +6 +>>> x.f(1,2, z = 3) +6 +>>> x.f(z = 3, y = 2, x = 1) +6 +>>> x.g() +'foobar' +>>> x.g(y = "baz") +'foobaz' +>>> x.g(x = "baz") +'bazbar' +>>> x.g(y = "foo", x = "bar") +'barfoo' +>>> y = x.h(x = "bar", y = "foo") +>>> assert x == y +>>> y = x(0) +>>> assert x == y +''' + +def run(args = None): + if args is not None: + import sys + sys.argv = args + import doctest, python_test + return doctest.testmod(python_test) + +if __name__ == '__main__': + import sys + sys.exit(run()[0]) diff --git a/src/boost/libs/parameter/test/sfinae.cpp b/src/boost/libs/parameter/test/sfinae.cpp new file mode 100644 index 000000000..17c50443f --- /dev/null +++ b/src/boost/libs/parameter/test/sfinae.cpp @@ -0,0 +1,174 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/config.hpp> + +#if (BOOST_PARAMETER_MAX_ARITY < 2) +#error Define BOOST_PARAMETER_MAX_ARITY as 2 or greater. +#endif +#if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) +#if (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 3) +#error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \ +as 3 or greater. +#endif +#endif + +#include <boost/parameter/name.hpp> + +namespace test { + + BOOST_PARAMETER_NAME((name, keywords) in(name)) + BOOST_PARAMETER_NAME((value, keywords) in(value)) +} // namespace test + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <type_traits> +#else +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_convertible.hpp> +#endif + +namespace test { + + template <typename To> + struct f_predicate + { + template <typename From, typename Args> +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + using fn = std::is_convertible<From,To>; +#else + struct apply + : boost::mpl::if_< + boost::is_convertible<From,To> + , boost::mpl::true_ + , boost::mpl::false_ + > + { + }; +#endif + }; +} // namespace test + +#include <boost/parameter/parameters.hpp> +#include <boost/parameter/optional.hpp> +#include <string> + +namespace test { + + struct f_parameters + : boost::parameter::parameters< + boost::parameter::optional< + test::keywords::name + , test::f_predicate<std::string> + > + , boost::parameter::optional< + test::keywords::value + , test::f_predicate<float> + > + > + { + }; +} // namespace test + +#include <boost/core/lightweight_test.hpp> + +namespace test { + + // The use of assert_equal_string is just a nasty workaround for a + // vc++ 6 ICE. + void assert_equal_string(std::string x, std::string y) + { + BOOST_TEST(x == y); + } + + template <typename P> + void f_impl(P const& p) + { + float v = p[test::value | 3.f]; + BOOST_TEST_EQ(v, 3.f); + test::assert_equal_string(p[test::name | "bar"], "foo"); + } + + void f() + { + test::f_impl(f_parameters()()); + } +} // namespace test + +#include <boost/parameter/match.hpp> + +namespace test { + + template <typename A0> + void + f( + A0 const& a0 + , BOOST_PARAMETER_MATCH(f_parameters, (A0), args) + ) + { + test::f_impl(args(a0)); + } + + template <typename A0, typename A1> + void + f( + A0 const& a0 + , A1 const& a1 + , BOOST_PARAMETER_MATCH(f_parameters, (A0)(A1), args) + ) + { + test::f_impl(args(a0, a1)); + } +} // namespace test + +#if !defined(BOOST_NO_SFINAE) && \ + !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) +#include <boost/core/enable_if.hpp> + +#if !defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/type_traits/is_same.hpp> +#endif + +namespace test { + + // On compilers that actually support SFINAE, add another overload that is + // an equally good match and can only be in the overload set when the + // others are not. This tests that the SFINAE is actually working. On + // all other compilers we're just checking that everything about + // SFINAE-enabled code will work, except of course the SFINAE. + template <typename A0, typename A1> + typename boost::enable_if< +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + std::is_same<int,A0> +#else + typename boost::mpl::if_< + boost::is_same<int,A0> + , boost::mpl::true_ + , boost::mpl::false_ + >::type +#endif + , int + >::type + f(A0 const& a0, A1 const& a1) + { + return 0; + } +} // namespace test + +#endif // SFINAE enabled, no Borland workarounds needed. + +int main() +{ + test::f("foo"); + test::f("foo", 3.f); + test::f(test::value = 3.f, test::name = "foo"); +#if !defined(BOOST_NO_SFINAE) && \ + !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) + BOOST_TEST_EQ(0, test::f(3, 4)); +#endif + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/singular.cpp b/src/boost/libs/parameter/test/singular.cpp new file mode 100644 index 000000000..a8c20e918 --- /dev/null +++ b/src/boost/libs/parameter/test/singular.cpp @@ -0,0 +1,158 @@ +// Copyright Daniel Wallin 2005. +// Copyright Cromwell D. Enage 2019. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +namespace test { + + struct default_src + { + typedef int result_type; + + int operator()() const + { + return 0; + } + }; +} // namespace test + +#include <boost/parameter/name.hpp> + +namespace test { + + BOOST_PARAMETER_NAME(x) + BOOST_PARAMETER_NAME(y) + BOOST_PARAMETER_NAME(z) +} // namespace test + +#include <boost/parameter/is_argument_pack.hpp> +#include <boost/parameter/config.hpp> +#include <boost/mpl/has_key.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/core/lightweight_test.hpp> + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <boost/mp11/map.hpp> +#include <type_traits> +#endif + +namespace test { + + template <typename ArgumentPack, typename K, typename T> + void check0(ArgumentPack const& p, K const& kw, T const& value) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + !boost::mp11::mp_map_contains<ArgumentPack,test::tag::z>::value + , "test::tag::z must not be in ArgumentPack" + ); + static_assert( + std::is_same< + boost::mp11::mp_map_find<ArgumentPack,test::tag::z> + , void + >::value + , "test::tag::z must not be found in ArgumentPack" + ); +#endif // BOOST_PARAMETER_CAN_USE_MP11 + BOOST_MPL_ASSERT((boost::parameter::is_argument_pack<ArgumentPack>)); + BOOST_MPL_ASSERT_NOT(( + boost::mpl::has_key<ArgumentPack,test::tag::z> + )); + BOOST_TEST_EQ(p[kw], value); + } +} // namespace test + +#include <boost/mpl/void.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/key_type.hpp> +#include <boost/mpl/order.hpp> +#include <boost/mpl/count.hpp> +#include <boost/mpl/equal_to.hpp> +#include <boost/type_traits/is_same.hpp> + +namespace test { + + template <typename ArgumentPack, typename K, typename T> + void check1(ArgumentPack const& p, K const& kw, T const& value) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + boost::mp11::mp_map_contains<ArgumentPack,typename K::tag>::value + , "typename K::tag must be in ArgumentPack" + ); + static_assert( + !boost::mp11::mp_map_contains<ArgumentPack,test::tag::z>::value + , "test::tag::z must not be in ArgumentPack" + ); + static_assert( + !std::is_same< + boost::mp11::mp_map_find<ArgumentPack,typename K::tag> + , void + >::value + , "typename K::tag must be found in ArgumentPack" + ); + static_assert( + std::is_same< + boost::mp11::mp_map_find<ArgumentPack,test::tag::z> + , void + >::value + , "test::tag::z must not be found in ArgumentPack" + ); +#endif // BOOST_PARAMETER_CAN_USE_MP11 + BOOST_MPL_ASSERT((boost::parameter::is_argument_pack<ArgumentPack>)); + BOOST_MPL_ASSERT((boost::mpl::has_key<ArgumentPack,typename K::tag>)); + BOOST_MPL_ASSERT_NOT(( + boost::mpl::has_key<ArgumentPack,test::tag::z> + )); + BOOST_MPL_ASSERT(( + boost::mpl::equal_to< + typename boost::mpl::count<ArgumentPack,typename K::tag>::type + , boost::mpl::int_<1> + > + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::key_type<ArgumentPack,typename K::tag>::type + , typename K::tag + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + typename boost::mpl::if_< + boost::is_same< + typename boost::mpl + ::order<ArgumentPack,typename K::tag>::type + , boost::mpl::void_ + > + , boost::mpl::false_ + , boost::mpl::true_ + >::type + )); + BOOST_TEST_EQ(p[kw], value); + } +} // namespace test + +int main() +{ + test::check1(test::_x = 20, test::_x, 20); + test::check1(test::_y = 20, test::_y, 20); + + test::check0(test::_x = 20, test::_x | 0, 20); + test::check0(test::_y = 20, test::_y | 0, 20); + + test::check0(test::_x = 20, test::_x || test::default_src(), 20); + test::check0(test::_y = 20, test::_y || test::default_src(), 20); + + test::check0(test::_y = 20, test::_x | 0, 0); + test::check0(test::_y = 20, test::_x || test::default_src(), 0); + + return boost::report_errors(); +} + diff --git a/src/boost/libs/parameter/test/timings.txt b/src/boost/libs/parameter/test/timings.txt new file mode 100644 index 000000000..aecb84ec8 --- /dev/null +++ b/src/boost/libs/parameter/test/timings.txt @@ -0,0 +1,128 @@ +# Copyright David Abrahams 2005. Distributed under the Boost +# Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +----------------- Test #1 ---------------- +Testers: + Matthias Troyer, Michael Gauckler, David Abrahams + +Date: + 2005-09-09 + +Compiler: + Cygwin g++-4.0.0 + +Command lines: + g++ -c -o efficiency.o -ftemplate-depth-100 -funroll-loops \ + -O3 -finline-functions -Wno-inline -DNDEBUG efficiency.cpp + + g++ -o efficiency.exe efficiency.o -Wl,--strip-all + + efficiency && efficiency && efficiency + +Machine: + Dell Inspiron 9300 + Intel(R) Pentium(R) M processor 2.00GHz + Running on 230 volts AC power + +Timings: + Run #1 results discarded per standard practice + + Run #2 + plain time: 0.75 + named parameter time: 0.734 + + Run #3 + plain time: 0.781 + named parameter time: 0.766 + +----------------- Test #2 ---------------- + +Testers: + Chris Frey + +Date: + 2005-09-17 + +Compiler: + Linux kernel 2.4.27 + gcc version 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8) + +Command lines: + g++ -c -o efficiency.o -ftemplate-depth-100 -funroll-loops \ + -O3 -finline-functions -Wno-inline -DNDEBUG efficiency.cpp + + g++ -o efficiency.exe efficiency.o -Wl,--strip-all + +Machine: + IBM Thinkpad 770Z, running on AC power + Intel Pentium II 366Mhz + +Timings: + Run #1 results discarded per standard practice + + Run #2 + plain time: 6.42 + named parameter time: 7.34 + + Run #3 + plain time: 6.42 + named parameter time: 7.34 + +----------------- Test #2 ---------------- + +Testers: + Stuar Dootson + +Date: + 2005-09-18 + +Machine: + Athlon 64 3500+ laptop, running on AC power + Windows XP SP2 + + +Compiler: Visual C++ 7.1 + + command line: + cl -O2 efficiency.cpp -EHsc -I\lib\boost\include\boost-1_33 + + Results: + plain time: <ignored> + named parameter time: <ignored> + plain time: 1.453 + named parameter time: 1.437 + plain time: 1.453 + named parameter time: 1.453 + +Compiler: Visual C++ 8.0 + + command-line: + cl -O2 efficiency.cpp -EHsc -I\lib\boost\include\boost-1_33 + + Results: + plain time: <ignored> + named parameter time: <ignored> + plain time: 1.438 + named parameter time: 1.453 + plain time: 1.438 + named parameter time: 1.437 + +Compiler: Mingw gcc 3.4.2 + + command-line: + g++ -c -o efficiency.o -ftemplate-depth-100 -funroll-loops -O3 + -finline-functions -Wno-inline -DNDEBUG efficiency.cpp + -I\lib\boost\include\boost-1_33 + g++ -o efficiency.exe efficiency.o -Wl,--strip-all + + Results: + plain time: <ignored> + named parameter time: <ignored> + plain time: 1.14 + named parameter time: 1.422 + plain time: 1.125 + named parameter time: 1.406 + +----------------------------------------- + diff --git a/src/boost/libs/parameter/test/tutorial.cpp b/src/boost/libs/parameter/test/tutorial.cpp new file mode 100644 index 000000000..4c4d17554 --- /dev/null +++ b/src/boost/libs/parameter/test/tutorial.cpp @@ -0,0 +1,41 @@ +// Copyright David Abrahams 2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/name.hpp> + +namespace graphs { + + BOOST_PARAMETER_NAME(graph) // Note: no semicolon + BOOST_PARAMETER_NAME(visitor) + BOOST_PARAMETER_NAME(root_vertex) + BOOST_PARAMETER_NAME(index_map) + BOOST_PARAMETER_NAME(color_map) +} // namespace graphs + +#include <boost/core/lightweight_test.hpp> + +namespace graphs { namespace core { + + template <typename ArgumentPack> + void depth_first_search(ArgumentPack const& args) + { + BOOST_TEST_EQ(false, args[_color_map]); + BOOST_TEST_EQ('G', args[_graph]); + BOOST_TEST_CSTR_EQ("hello, world", args[_index_map]); + BOOST_TEST_EQ(3.5, args[_root_vertex]); + BOOST_TEST_EQ(2, args[_visitor]); + } +}} // namespace graphs::core + +int main() +{ + using namespace graphs; + + core::depth_first_search(( + _graph = 'G', _visitor = 2, _root_vertex = 3.5 + , _index_map = "hello, world", _color_map = false + )); + return boost::report_errors(); +} diff --git a/src/boost/libs/parameter/test/unwrap_cv_reference.cpp b/src/boost/libs/parameter/test/unwrap_cv_reference.cpp new file mode 100644 index 000000000..55af09ddc --- /dev/null +++ b/src/boost/libs/parameter/test/unwrap_cv_reference.cpp @@ -0,0 +1,378 @@ +// Copyright David Abrahams 2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/parameter/aux_/unwrap_cv_reference.hpp> +#include <boost/parameter/config.hpp> +#include <boost/mpl/aux_/test.hpp> + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include <type_traits> +#else +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/type_traits/is_same.hpp> +#endif + +MPL_TEST_CASE() +{ +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference<int>::type + , int + >::value + , "unwrap_cv_reference<int>::type == int" + ); + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference<int const>::type + , int const + >::value + , "unwrap_cv_reference<int const>::type == int const" + ); + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference<int volatile>::type + , int volatile + >::value + , "unwrap_cv_reference<int volatile>::type == int volatile" + ); + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference< + int const volatile + >::type + , int const volatile + >::value + , "unwrap_cv_reference<int cv>::type == int cv" + ); +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference<int>::type + , int + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference<int const>::type + , int const + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference<int volatile>::type + , int volatile + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference< + int const volatile + >::type + , int const volatile + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif // BOOST_PARAMETER_CAN_USE_MP11 +} + +namespace test { + + struct foo + { + }; +} // namespace test + +MPL_TEST_CASE() +{ +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference<test::foo>::type + , test::foo + >::value + , "unwrap_cv_reference<test::foo>::type == test::foo" + ); + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference<test::foo const>::type + , test::foo const + >::value + , "unwrap_cv_reference<test::foo const>::type == test::foo const" + ); + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference< + test::foo volatile + >::type + , test::foo volatile + >::value + , "unwrap_cv_reference<test::foo volatile>::type == test::foo volatile" + ); + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference< + test::foo const volatile + >::type + , test::foo const volatile + >::value + , "unwrap_cv_reference<test::foo cv>::type == test::foo cv" + ); +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference<test::foo>::type + , test::foo + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference< + test::foo const + >::type + , test::foo const + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference< + test::foo volatile + >::type + , test::foo volatile + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference< + test::foo const volatile + >::type + , test::foo const volatile + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif // BOOST_PARAMETER_CAN_USE_MP11 +} + +#include <boost/ref.hpp> + +MPL_TEST_CASE() +{ +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference< + boost::reference_wrapper<test::foo> + >::type + , test::foo + >::value + , "unwrap_cv_reference<ref(test::foo)>::type == test::foo" + ); + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference< + boost::reference_wrapper<test::foo> const + >::type + , test::foo + >::value + , "unwrap_cv_reference<ref(test::foo) const>::type == test::foo" + ); + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference< + boost::reference_wrapper<test::foo> volatile + >::type + , test::foo + >::value + , "unwrap_cv_reference<ref(test::foo) volatile>::type == test::foo" + ); + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference< + boost::reference_wrapper<test::foo> const volatile + >::type + , test::foo + >::value + , "unwrap_cv_reference<ref(test::foo) cv>::type == test::foo" + ); +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference< + boost::reference_wrapper<test::foo> + >::type + , test::foo + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference< + boost::reference_wrapper<test::foo> const + >::type + , test::foo + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference< + boost::reference_wrapper<test::foo> volatile + >::type + , test::foo + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference< + boost::reference_wrapper<test::foo> const volatile + >::type + , test::foo + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif // BOOST_PARAMETER_CAN_USE_MP11 +} + +#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) +#include <functional> + +MPL_TEST_CASE() +{ +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference< + std::reference_wrapper<test::foo> + >::type + , test::foo + >::value + , "unwrap_cv_reference<std::ref(test::foo)>::type == test::foo" + ); + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference< + std::reference_wrapper<test::foo> const + >::type + , test::foo + >::value + , "unwrap_cv_reference<std::ref(test::foo) const>::type == test::foo" + ); + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference< + std::reference_wrapper<test::foo> volatile + >::type + , test::foo + >::value + , "unwrap_cv_reference<std::ref(test::foo) volatile>::type == test::foo" + ); + static_assert( + std::is_same< + boost::parameter::aux::unwrap_cv_reference< + std::reference_wrapper<test::foo> const volatile + >::type + , test::foo + >::value + , "unwrap_cv_reference<std::ref(test::foo) cv>::type == test::foo" + ); +#else // !defined(BOOST_PARAMETER_CAN_USE_MP11) + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference< + std::reference_wrapper<test::foo> + >::type + , test::foo + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference< + std::reference_wrapper<test::foo> const + >::type + , test::foo + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference< + std::reference_wrapper<test::foo> volatile + >::type + , test::foo + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); + BOOST_MPL_ASSERT(( + boost::mpl::if_< + boost::is_same< + boost::parameter::aux::unwrap_cv_reference< + std::reference_wrapper<test::foo> const volatile + >::type + , test::foo + > + , boost::mpl::true_ + , boost::mpl::false_ + >::type + )); +#endif // BOOST_PARAMETER_CAN_USE_MP11 +} + +#endif // BOOST_NO_CXX11_HDR_FUNCTIONAL + |