diff options
Diffstat (limited to 'src/boost/libs/mp11')
196 files changed, 12120 insertions, 0 deletions
diff --git a/src/boost/libs/mp11/CMakeLists.txt b/src/boost/libs/mp11/CMakeLists.txt new file mode 100644 index 000000000..45bcd6b25 --- /dev/null +++ b/src/boost/libs/mp11/CMakeLists.txt @@ -0,0 +1,66 @@ +# Copyright 2018, 2019 Peter Dimov +# 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(boost_mp11 VERSION 1.79.0 LANGUAGES CXX) + +add_library(boost_mp11 INTERFACE) +add_library(Boost::mp11 ALIAS boost_mp11) + +target_include_directories(boost_mp11 INTERFACE include) +target_compile_features(boost_mp11 INTERFACE cxx_alias_templates cxx_variadic_templates cxx_decltype) + +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + + # Fetch support files + + message(STATUS "Fetching BoostFetch.cmake") + + file(DOWNLOAD + "https://raw.githubusercontent.com/boostorg/cmake/develop/include/BoostFetch.cmake" + "${CMAKE_BINARY_DIR}/fetch_and_include/BoostFetch.cmake" + ) + + include("${CMAKE_BINARY_DIR}/fetch_and_include/BoostFetch.cmake") + + boost_fetch(boostorg/cmake TAG develop NO_ADD_SUBDIR) + + FetchContent_GetProperties(boostorg_cmake) + + list(APPEND CMAKE_MODULE_PATH ${boostorg_cmake_SOURCE_DIR}/include) + + # Testing (off by default) + + option(BUILD_TESTING "Build the tests." OFF) + include(CTest) + + if(BUILD_TESTING) + + set(BUILD_TESTING OFF) # hide cache variable + + boost_fetch(boostorg/assert TAG develop EXCLUDE_FROM_ALL) + boost_fetch(boostorg/config TAG develop EXCLUDE_FROM_ALL) + boost_fetch(boostorg/core TAG develop EXCLUDE_FROM_ALL) + boost_fetch(boostorg/static_assert TAG develop EXCLUDE_FROM_ALL) + boost_fetch(boostorg/throw_exception TAG develop EXCLUDE_FROM_ALL) + + unset(BUILD_TESTING) + + endif() + + # Do not use the default BoostInstall versioned layout on Windows when standalone + set(BOOST_INSTALL_LAYOUT "system" CACHE STRING "Installation layout (versioned, tagged, or system)") + + include(BoostInstall) + + boost_install(TARGETS boost_mp11 HEADER_DIRECTORY include/) + +endif() + +if(BUILD_TESTING) + + add_subdirectory(test) + +endif() diff --git a/src/boost/libs/mp11/README.md b/src/boost/libs/mp11/README.md new file mode 100644 index 000000000..e24b92011 --- /dev/null +++ b/src/boost/libs/mp11/README.md @@ -0,0 +1,23 @@ +# Mp11, a C++11 metaprogramming library + +Mp11 is a C++11 metaprogramming library based on template aliases and variadic templates. +It implements the approach outlined in the article +["Simple C++11 metaprogramming"](https://www.boost.org/libs/mp11/doc/html/simple_cxx11_metaprogramming.html) +and [its sequel](https://www.boost.org/libs/mp11/doc/html/simple_cxx11_metaprogramming_2.html). + +Mp11 is part of [Boost](http://boost.org/libs/mp11), starting with release 1.66.0. It +however has no Boost dependencies and can be used standalone, as a Git submodule, for +instance. For CMake users, `add_subdirectory` is supported, as is installation and +`find_package(boost_mp11)`. + +## Supported compilers + +* g++ 4.8 or later +* clang++ 3.9 or later +* Visual Studio 2013, 2015, 2017, 2019 + +Tested on [Github Actions](https://github.com/boostorg/mp11/actions) and [Appveyor](https://ci.appveyor.com/project/pdimov/mp11/). + +## License + +Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt). diff --git a/src/boost/libs/mp11/index.html b/src/boost/libs/mp11/index.html new file mode 100644 index 000000000..fc6d0ca2b --- /dev/null +++ b/src/boost/libs/mp11/index.html @@ -0,0 +1,15 @@ +<html> +<head> +<meta http-equiv="refresh" content="0; URL=doc/html/mp11.html"> +</head> +<body> +Automatic redirection failed, please go to +<a href="doc/html/mp11.html">doc/html/mp11.html</a>. +</body> +</html> +<!-- + © Copyright Beman Dawes, 2001 + 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 +--> diff --git a/src/boost/libs/mp11/meta/libraries.json b/src/boost/libs/mp11/meta/libraries.json new file mode 100644 index 000000000..fd9c73fbb --- /dev/null +++ b/src/boost/libs/mp11/meta/libraries.json @@ -0,0 +1,15 @@ +{ + "key": "mp11", + "name": "Mp11", + "authors": [ + "Peter Dimov" + ], + "maintainers": [ + "Peter Dimov <pdimov -at- gmail.com>" + ], + "description": "A C++11 metaprogramming library.", + "category": [ + "Metaprogramming" + ], + "cxxstd": "11" +} diff --git a/src/boost/libs/mp11/test/CMakeLists.txt b/src/boost/libs/mp11/test/CMakeLists.txt new file mode 100644 index 000000000..cab19b651 --- /dev/null +++ b/src/boost/libs/mp11/test/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright 2018 Peter Dimov +# 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(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST) + +if(HAVE_BOOST_TEST) + +boost_test_jamfile(FILE Jamfile LINK_LIBRARIES Boost::mp11 Boost::core) +boost_test(SOURCES check_cmake_version.cpp ARGUMENTS ${PROJECT_VERSION} LINK_LIBRARIES Boost::core Boost::config) + +endif() diff --git a/src/boost/libs/mp11/test/Jamfile b/src/boost/libs/mp11/test/Jamfile new file mode 100644 index 000000000..0e25055ac --- /dev/null +++ b/src/boost/libs/mp11/test/Jamfile @@ -0,0 +1,235 @@ +# Boost.Mp11 Library Test Jamfile +# +# Copyright 2015-2019 Peter Dimov +# +# 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 + +import testing ; +import ../../config/checks/config : requires ; + +project + : requirements + + [ requires cxx11_variadic_templates cxx11_template_aliases cxx11_decltype cxx11_hdr_tuple ] + + <warnings>extra + + <toolset>msvc:<warnings-as-errors>on + <toolset>gcc:<warnings-as-errors>on + <toolset>clang:<warnings-as-errors>on + ; + +# include-only +compile mp11.cpp ; + +# list +run mp_size.cpp ; +run mp_empty.cpp ; +run mp_front.cpp ; +run mp_pop_front.cpp ; +run mp_second.cpp ; +run mp_third.cpp ; +run mp_push_front.cpp ; +run mp_push_back.cpp ; +run mp_rename.cpp ; +run mp_append.cpp ; +run mp_append_2.cpp ; +run mp_append_sf.cpp ; +run mp_replace_front.cpp ; +run mp_replace_second.cpp ; +run mp_replace_third.cpp ; +run mp_apply_q.cpp ; +run mp_is_list.cpp ; +run mp_list_c.cpp ; +run mp_transform_front.cpp ; +run mp_transform_second.cpp ; +run mp_transform_third.cpp ; + +# algorithm +run mp_assign.cpp ; +run mp_clear.cpp ; +run mp_transform.cpp ; +run mp_transform_q.cpp ; +run mp_transform_sf.cpp ; +run mp_transform_if.cpp ; +run mp_transform_if_q.cpp ; +run mp_filter.cpp ; +run mp_fill.cpp ; +run mp_count.cpp ; +run mp_count_if.cpp ; +run mp_count_if_q.cpp ; +run mp_contains.cpp ; +run mp_starts_with.cpp ; +run mp_starts_with_sf.cpp ; +run mp_repeat.cpp ; +run mp_product.cpp ; +run mp_drop.cpp ; +run mp_iota.cpp ; +run mp_at.cpp ; +run mp_at_sf.cpp : : : <toolset>gcc-4.7:<warnings>all ; +run mp_take.cpp ; +run mp_replace.cpp ; +run mp_replace_if.cpp ; +run mp_replace_if_q.cpp ; +run mp_copy_if.cpp ; +run mp_copy_if_q.cpp ; +run mp_remove.cpp ; +run mp_remove_if.cpp ; +run mp_remove_if_q.cpp ; +run mp_partition.cpp ; +run mp_partition_q.cpp ; +run mp_sort.cpp ; +run mp_sort_q.cpp ; +run mp_find.cpp ; +run mp_find_if.cpp ; +run mp_find_if_q.cpp ; +run mp_reverse.cpp ; +run mp_fold.cpp ; +run mp_fold_q.cpp ; +run mp_reverse_fold.cpp ; +run mp_reverse_fold_q.cpp ; +run mp_unique.cpp ; +run mp_unique_if.cpp ; +run mp_unique_if_q.cpp ; +run mp_all_of.cpp ; +run mp_all_of_q.cpp ; +run mp_any_of.cpp ; +run mp_any_of_q.cpp ; +run mp_none_of.cpp ; +run mp_none_of_q.cpp ; +run mp_replace_at.cpp ; +run mp_replace_at_c.cpp ; +run mp_for_each.cpp ; +run mp_insert.cpp ; +run mp_erase.cpp ; +run mp_with_index.cpp ; +run mp_with_index_cx.cpp ; +run mp_from_sequence.cpp ; +run mp_min_element.cpp ; +run mp_min_element_q.cpp ; +run mp_max_element.cpp ; +run mp_max_element_q.cpp ; +run mp_nth_element.cpp ; +run mp_nth_element_q.cpp ; +run mp_back.cpp ; +run mp_pop_back.cpp ; +run mp_flatten.cpp ; +run mp_rotate_left.cpp ; +run mp_rotate_right.cpp ; +run mp_power_set.cpp ; +run mp_partial_sum.cpp ; +run mp_iterate.cpp ; +run mp_pairwise_fold.cpp ; +run mp_pairwise_fold_q.cpp ; +run mp_intersperse.cpp ; +run mp_split.cpp ; +run mp_join.cpp ; + +# integral +run integral.cpp ; + +# utility +run mp_identity.cpp ; +run mp_inherit.cpp ; +run mp_if.cpp ; +run mp_if_sf.cpp ; +run mp_eval_if.cpp ; +run mp_eval_if_sf.cpp ; +run mp_valid.cpp ; +run mp_defer.cpp ; +run mp_quote.cpp ; +run mp_invoke_q.cpp ; +run mp_invoke_q_sf.cpp ; +run mp_quote_trait.cpp ; +run mp_cond.cpp ; +run mp_cond_sf.cpp ; +run mp_not_fn.cpp ; +run mp_eval_if_not.cpp ; +run mp_eval_or.cpp ; +run mp_compose.cpp ; +run mp_valid_and_true.cpp ; + +# integer_sequence +run integer_sequence.cpp ; + +# tuple +run tuple_for_each.cpp ; +compile tuple_for_each_cx.cpp ; +run tuple_apply.cpp ; +compile tuple_apply_cx.cpp ; +run construct_from_tuple.cpp ; +compile construct_from_tuple_cx.cpp ; +run tuple_transform.cpp ; +run tuple_transform_2.cpp ; +compile tuple_transform_cx.cpp ; + +# set +run mp_set_contains.cpp ; +run mp_set_push_back.cpp ; +run mp_set_push_front.cpp ; +run mp_is_set.cpp ; +run mp_set_union.cpp ; +run mp_set_union_sf.cpp ; +run mp_set_difference.cpp ; +run mp_set_difference_sf.cpp ; +run mp_set_intersection.cpp ; +run mp_set_intersection_sf.cpp ; + +# function +run mp_all.cpp ; +run mp_all_2.cpp ; +run mp_and.cpp ; +run mp_any.cpp ; +run mp_any_2.cpp ; +run mp_or.cpp ; +run mp_same.cpp ; +run mp_plus.cpp ; +run mp_less.cpp ; +run mp_min.cpp ; +run mp_max.cpp ; +run mp_similar.cpp ; + +# map +run mp_map_find.cpp ; +run mp_map_find_2.cpp ; +run mp_map_find_3.cpp ; +run mp_map_contains.cpp ; +run mp_map_insert.cpp ; +run mp_map_replace.cpp ; +run mp_map_erase.cpp ; +run mp_map_update.cpp ; +run mp_map_update_q.cpp ; +run mp_map_keys.cpp ; +run mp_is_map.cpp ; + +# bind +run mp_bind.cpp ; +run mp_bind_q.cpp ; +run mp_bind_front.cpp ; +run mp_bind_back.cpp ; + +# mpl +run mpl.cpp : ; +run mpl_list.cpp : ; +run mpl_tuple.cpp : ; + +# version +run version.cpp ; +run mp11_version.cpp ; +run list_version.cpp ; +run algorithm_version.cpp ; +run integral_version.cpp ; +run utility_version.cpp ; +run function_version.cpp ; +run map_version.cpp ; +run set_version.cpp ; +run bind_version.cpp ; +run integer_sequence_version.cpp ; +run tuple_version.cpp ; +run mpl_version.cpp ; + +# quick (for CI) +alias quick : mp11 mp_size ; +explicit quick ; diff --git a/src/boost/libs/mp11/test/algorithm_version.cpp b/src/boost/libs/mp11/test/algorithm_version.cpp new file mode 100644 index 000000000..6960803fa --- /dev/null +++ b/src/boost/libs/mp11/test/algorithm_version.cpp @@ -0,0 +1,17 @@ + +// Copyright 2019 Peter Dimov +// +// 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/mp11/algorithm.hpp> +#include <boost/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_MP11_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/bind_version.cpp b/src/boost/libs/mp11/test/bind_version.cpp new file mode 100644 index 000000000..75f3d9573 --- /dev/null +++ b/src/boost/libs/mp11/test/bind_version.cpp @@ -0,0 +1,17 @@ + +// Copyright 2019 Peter Dimov +// +// 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/mp11/bind.hpp> +#include <boost/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_MP11_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/check_cmake_version.cpp b/src/boost/libs/mp11/test/check_cmake_version.cpp new file mode 100644 index 000000000..2fd464836 --- /dev/null +++ b/src/boost/libs/mp11/test/check_cmake_version.cpp @@ -0,0 +1,27 @@ +// Check whether the version in CMakeLists.txt is up to date +// +// Copyright 2018 Peter Dimov +// +// 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/core/lightweight_test.hpp> +#include <boost/version.hpp> +#include <cstdio> + +int main( int ac, char const* av[] ) +{ + BOOST_TEST_EQ( ac, 2 ); + + if( ac >= 2 ) + { + char version[ 64 ]; + std::sprintf( version, "%d.%d.%d", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100 ); + + BOOST_TEST_CSTR_EQ( av[1], version ); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/cmake_install_test/CMakeLists.txt b/src/boost/libs/mp11/test/cmake_install_test/CMakeLists.txt new file mode 100644 index 000000000..6dfc020df --- /dev/null +++ b/src/boost/libs/mp11/test/cmake_install_test/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright 2018 Peter Dimov +# 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(cmake_install_test LANGUAGES CXX) + +find_package(boost_mp11 REQUIRED) + +add_executable(main main.cpp) +target_link_libraries(main Boost::mp11) + +enable_testing() +add_test(NAME main COMMAND main) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>) diff --git a/src/boost/libs/mp11/test/cmake_install_test/main.cpp b/src/boost/libs/mp11/test/cmake_install_test/main.cpp new file mode 100644 index 000000000..7b8689ac6 --- /dev/null +++ b/src/boost/libs/mp11/test/cmake_install_test/main.cpp @@ -0,0 +1,12 @@ +// Copyright 2018 Peter Dimov +// 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/mp11.hpp> +using namespace boost::mp11; + +int main() +{ + using L1 = mp_list<int, float, int, float>; + return mp_size<mp_unique<L1>>::value == 2? 0: 1; +} diff --git a/src/boost/libs/mp11/test/cmake_subdir_test/CMakeLists.txt b/src/boost/libs/mp11/test/cmake_subdir_test/CMakeLists.txt new file mode 100644 index 000000000..6dd6975ae --- /dev/null +++ b/src/boost/libs/mp11/test/cmake_subdir_test/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright 2018 Peter Dimov +# 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(cmake_subdir_test LANGUAGES CXX) + +add_subdirectory(../.. boostorg/mp11) + +add_executable(main main.cpp) +target_link_libraries(main Boost::mp11) + +enable_testing() +add_test(NAME main COMMAND main) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>) diff --git a/src/boost/libs/mp11/test/cmake_subdir_test/main.cpp b/src/boost/libs/mp11/test/cmake_subdir_test/main.cpp new file mode 100644 index 000000000..7b8689ac6 --- /dev/null +++ b/src/boost/libs/mp11/test/cmake_subdir_test/main.cpp @@ -0,0 +1,12 @@ +// Copyright 2018 Peter Dimov +// 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/mp11.hpp> +using namespace boost::mp11; + +int main() +{ + using L1 = mp_list<int, float, int, float>; + return mp_size<mp_unique<L1>>::value == 2? 0: 1; +} diff --git a/src/boost/libs/mp11/test/construct_from_tuple.cpp b/src/boost/libs/mp11/test/construct_from_tuple.cpp new file mode 100644 index 000000000..b4b7f34da --- /dev/null +++ b/src/boost/libs/mp11/test/construct_from_tuple.cpp @@ -0,0 +1,222 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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 + + +#if defined(_MSC_VER) +#pragma warning( disable: 4244 ) // 'initializing': conversion from 'int' to 'char', possible loss of data +#endif + +#include <boost/mp11/tuple.hpp> +#include <boost/mp11/detail/config.hpp> +#include <boost/core/lightweight_test.hpp> +#include <tuple> +#include <memory> +#include <utility> +#include <array> + +struct T1 +{ + int x, y, z; + + T1( int x = 0, int y = 0, int z = 0 ): x(x), y(y), z(z) {} +}; + +struct T2 +{ + std::unique_ptr<int> x, y, z; + + T2( std::unique_ptr<int> x, std::unique_ptr<int> y, std::unique_ptr<int> z ): x(std::move(x)), y(std::move(y)), z(std::move(z)) {} + +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) + + T2( T2&& r ): x( std::move(r.x) ), y( std::move(r.y) ), z( std::move(r.z) ) {} + +#endif +}; + +int main() +{ + using boost::mp11::construct_from_tuple; + + { + std::tuple<int, short, char> tp{ 1, 2, 3 }; + + { + T1 t1 = construct_from_tuple<T1>( tp ); + + BOOST_TEST_EQ( t1.x, 1 ); + BOOST_TEST_EQ( t1.y, 2 ); + BOOST_TEST_EQ( t1.z, 3 ); + } + + { + T1 t1 = construct_from_tuple<T1>( std::move(tp) ); + + BOOST_TEST_EQ( t1.x, 1 ); + BOOST_TEST_EQ( t1.y, 2 ); + BOOST_TEST_EQ( t1.z, 3 ); + } + } + + { + std::tuple<int, short, char> const tp{ 1, 2, 3 }; + + { + T1 t1 = construct_from_tuple<T1>( tp ); + + BOOST_TEST_EQ( t1.x, 1 ); + BOOST_TEST_EQ( t1.y, 2 ); + BOOST_TEST_EQ( t1.z, 3 ); + } + + { + T1 t1 = construct_from_tuple<T1>( std::move(tp) ); + + BOOST_TEST_EQ( t1.x, 1 ); + BOOST_TEST_EQ( t1.y, 2 ); + BOOST_TEST_EQ( t1.z, 3 ); + } + } + +#if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 8 +#else + + { + std::tuple<std::unique_ptr<int>, std::unique_ptr<int>, std::unique_ptr<int>> tp{ std::unique_ptr<int>(new int(1)), std::unique_ptr<int>(new int(2)), std::unique_ptr<int>(new int(3)) }; + + T2 t2 = construct_from_tuple<T2>( std::move(tp) ); + + BOOST_TEST_EQ( *t2.x, 1 ); + BOOST_TEST_EQ( *t2.y, 2 ); + BOOST_TEST_EQ( *t2.z, 3 ); + } + +#endif + + { + std::pair<int, short> tp{ 1, 2 }; + + { + T1 t1 = construct_from_tuple<T1>( tp ); + + BOOST_TEST_EQ( t1.x, 1 ); + BOOST_TEST_EQ( t1.y, 2 ); + BOOST_TEST_EQ( t1.z, 0 ); + } + + { + T1 t1 = construct_from_tuple<T1>( std::move(tp) ); + + BOOST_TEST_EQ( t1.x, 1 ); + BOOST_TEST_EQ( t1.y, 2 ); + BOOST_TEST_EQ( t1.z, 0 ); + } + } + + { + std::pair<int, short> const tp{ 1, 2 }; + + { + T1 t1 = construct_from_tuple<T1>( tp ); + + BOOST_TEST_EQ( t1.x, 1 ); + BOOST_TEST_EQ( t1.y, 2 ); + BOOST_TEST_EQ( t1.z, 0 ); + } + + { + T1 t1 = construct_from_tuple<T1>( std::move(tp) ); + + BOOST_TEST_EQ( t1.x, 1 ); + BOOST_TEST_EQ( t1.y, 2 ); + BOOST_TEST_EQ( t1.z, 0 ); + } + } + + { + std::array<int, 3> tp{{ 1, 2, 3 }}; + + { + T1 t1 = construct_from_tuple<T1>( tp ); + + BOOST_TEST_EQ( t1.x, 1 ); + BOOST_TEST_EQ( t1.y, 2 ); + BOOST_TEST_EQ( t1.z, 3 ); + } + + { + T1 t1 = construct_from_tuple<T1>( std::move(tp) ); + + BOOST_TEST_EQ( t1.x, 1 ); + BOOST_TEST_EQ( t1.y, 2 ); + BOOST_TEST_EQ( t1.z, 3 ); + } + } + + { + std::array<int, 3> const tp{{ 1, 2, 3 }}; + + { + T1 t1 = construct_from_tuple<T1>( tp ); + + BOOST_TEST_EQ( t1.x, 1 ); + BOOST_TEST_EQ( t1.y, 2 ); + BOOST_TEST_EQ( t1.z, 3 ); + } + + { + T1 t1 = construct_from_tuple<T1>( std::move(tp) ); + + BOOST_TEST_EQ( t1.x, 1 ); + BOOST_TEST_EQ( t1.y, 2 ); + BOOST_TEST_EQ( t1.z, 3 ); + } + } + + { + std::tuple<> tp; + + { + T1 t1 = construct_from_tuple<T1>( tp ); + + BOOST_TEST_EQ( t1.x, 0 ); + BOOST_TEST_EQ( t1.y, 0 ); + BOOST_TEST_EQ( t1.z, 0 ); + } + + { + T1 t1 = construct_from_tuple<T1>( std::move(tp) ); + + BOOST_TEST_EQ( t1.x, 0 ); + BOOST_TEST_EQ( t1.y, 0 ); + BOOST_TEST_EQ( t1.z, 0 ); + } + } + + { + std::array<int, 0> tp; + + { + T1 t1 = construct_from_tuple<T1>( tp ); + + BOOST_TEST_EQ( t1.x, 0 ); + BOOST_TEST_EQ( t1.y, 0 ); + BOOST_TEST_EQ( t1.z, 0 ); + } + + { + T1 t1 = construct_from_tuple<T1>( std::move(tp) ); + + BOOST_TEST_EQ( t1.x, 0 ); + BOOST_TEST_EQ( t1.y, 0 ); + BOOST_TEST_EQ( t1.z, 0 ); + } + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/construct_from_tuple_cx.cpp b/src/boost/libs/mp11/test/construct_from_tuple_cx.cpp new file mode 100644 index 000000000..8962d3ed5 --- /dev/null +++ b/src/boost/libs/mp11/test/construct_from_tuple_cx.cpp @@ -0,0 +1,87 @@ + +// Copyright 2015 Peter Dimov. +// +// 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 + + +#if defined(_MSC_VER) +#pragma warning( disable: 4244 ) // 'initializing': conversion from 'int' to 'char', possible loss of data +#endif + +#include <boost/mp11/tuple.hpp> +#include <boost/mp11/detail/config.hpp> + +// Technically std::tuple isn't constexpr enabled in C++11, but it works with libstdc++ + +#if defined( BOOST_MP11_NO_CONSTEXPR ) || ( !defined(_MSC_VER) && !defined( __GLIBCXX__ ) && __cplusplus < 201400L ) + +int main() {} + +#else + +#include <tuple> +#include <array> +#include <utility> + +struct T1 +{ + int x, y, z; + + constexpr T1( int x = 0, int y = 0, int z = 0 ): x(x), y(y), z(z) {} +}; + +int main() +{ + using boost::mp11::construct_from_tuple; + + { + constexpr std::tuple<int, short, char> tp{ 1, 2, 3 }; + + constexpr auto r = construct_from_tuple<T1>( tp ); + + static_assert( r.x == 1, "r.x == 1" ); + static_assert( r.y == 2, "r.y == 2" ); + static_assert( r.z == 3, "r.z == 3" ); + } + + { + constexpr std::pair<short, char> tp{ 1, 2 }; + + constexpr auto r = construct_from_tuple<T1>( tp ); + + static_assert( r.x == 1, "r.x == 1" ); + static_assert( r.y == 2, "r.y == 2" ); + static_assert( r.z == 0, "r.z == 0" ); + } + + { + constexpr std::array<short, 3> tp{{ 1, 2, 3 }}; + + constexpr auto r = construct_from_tuple<T1>( tp ); + + static_assert( r.x == 1, "r.x == 1" ); + static_assert( r.y == 2, "r.y == 2" ); + static_assert( r.z == 3, "r.z == 3" ); + } + +#if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 9 +// "error: default initialization of an object of const type 'const std::tuple<>' without a user-provided default constructor" +#else + + { + constexpr std::tuple<> tp; + + constexpr auto r = construct_from_tuple<T1>( tp ); + + static_assert( r.x == 0, "r.x == 0" ); + static_assert( r.y == 0, "r.y == 0" ); + static_assert( r.z == 0, "r.z == 0" ); + } + +#endif +} + +#endif diff --git a/src/boost/libs/mp11/test/function_version.cpp b/src/boost/libs/mp11/test/function_version.cpp new file mode 100644 index 000000000..9464a827d --- /dev/null +++ b/src/boost/libs/mp11/test/function_version.cpp @@ -0,0 +1,17 @@ + +// Copyright 2019 Peter Dimov +// +// 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/mp11/function.hpp> +#include <boost/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_MP11_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/integer_sequence.cpp b/src/boost/libs/mp11/test/integer_sequence.cpp new file mode 100644 index 000000000..bc489ab67 --- /dev/null +++ b/src/boost/libs/mp11/test/integer_sequence.cpp @@ -0,0 +1,59 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/integer_sequence.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::integer_sequence; + using boost::mp11::make_integer_sequence; + using boost::mp11::index_sequence; + using boost::mp11::make_index_sequence; + using boost::mp11::index_sequence_for; + + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<int, 0>, integer_sequence<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<int, 1>, integer_sequence<int, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<int, 2>, integer_sequence<int, 0, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<int, 3>, integer_sequence<int, 0, 1, 2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<int, 4>, integer_sequence<int, 0, 1, 2, 3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<char, 0>, integer_sequence<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<char, 1>, integer_sequence<char, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<char, 2>, integer_sequence<char, 0, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<char, 3>, integer_sequence<char, 0, 1, 2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<char, 4>, integer_sequence<char, 0, 1, 2, 3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<std::size_t, 0>, integer_sequence<std::size_t>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<std::size_t, 1>, integer_sequence<std::size_t, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<std::size_t, 2>, integer_sequence<std::size_t, 0, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<std::size_t, 3>, integer_sequence<std::size_t, 0, 1, 2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_integer_sequence<std::size_t, 4>, integer_sequence<std::size_t, 0, 1, 2, 3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<make_index_sequence<0>, integer_sequence<std::size_t>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_index_sequence<1>, integer_sequence<std::size_t, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_index_sequence<2>, integer_sequence<std::size_t, 0, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_index_sequence<3>, integer_sequence<std::size_t, 0, 1, 2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_index_sequence<4>, integer_sequence<std::size_t, 0, 1, 2, 3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<make_index_sequence<0>, index_sequence<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_index_sequence<1>, index_sequence<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_index_sequence<2>, index_sequence<0, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_index_sequence<3>, index_sequence<0, 1, 2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<make_index_sequence<4>, index_sequence<0, 1, 2, 3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<index_sequence_for<>, index_sequence<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<index_sequence_for<void>, index_sequence<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<index_sequence_for<void, void>, index_sequence<0, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<index_sequence_for<void, void, void>, index_sequence<0, 1, 2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<index_sequence_for<void, void, void, void>, index_sequence<0, 1, 2, 3>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/integer_sequence_version.cpp b/src/boost/libs/mp11/test/integer_sequence_version.cpp new file mode 100644 index 000000000..2ba3ffe02 --- /dev/null +++ b/src/boost/libs/mp11/test/integer_sequence_version.cpp @@ -0,0 +1,17 @@ + +// Copyright 2019 Peter Dimov +// +// 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/mp11/integer_sequence.hpp> +#include <boost/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_MP11_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/integral.cpp b/src/boost/libs/mp11/test/integral.cpp new file mode 100644 index 000000000..ce0f96106 --- /dev/null +++ b/src/boost/libs/mp11/test/integral.cpp @@ -0,0 +1,70 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <cstddef> + +int main() +{ + using boost::mp11::mp_bool; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bool<false>, std::integral_constant<bool, false>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bool<true>, std::integral_constant<bool, true>>)); + + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_false, std::integral_constant<bool, false>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_true, std::integral_constant<bool, true>>)); + + using boost::mp11::mp_int; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_int<0>, std::integral_constant<int, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_int<814>, std::integral_constant<int, 814>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_int<-144>, std::integral_constant<int, -144>>)); + + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_size_t<0>, std::integral_constant<std::size_t, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_size_t<1972>, std::integral_constant<std::size_t, 1972>>)); + + using boost::mp11::mp_to_bool; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_false>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_true>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_int<0>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_int<1>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_int<107>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_int<-1>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_int<-91>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_size_t<0>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_size_t<1>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_to_bool<mp_size_t<442>>, mp_true>)); + + using boost::mp11::mp_not; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_false>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_true>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_int<0>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_int<1>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_int<107>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_int<-1>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_int<-91>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_size_t<0>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_size_t<1>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_not<mp_size_t<442>>, mp_false>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/integral_version.cpp b/src/boost/libs/mp11/test/integral_version.cpp new file mode 100644 index 000000000..2ba708069 --- /dev/null +++ b/src/boost/libs/mp11/test/integral_version.cpp @@ -0,0 +1,17 @@ + +// Copyright 2019 Peter Dimov +// +// 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/mp11/integral.hpp> +#include <boost/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_MP11_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/list_version.cpp b/src/boost/libs/mp11/test/list_version.cpp new file mode 100644 index 000000000..9cee66409 --- /dev/null +++ b/src/boost/libs/mp11/test/list_version.cpp @@ -0,0 +1,17 @@ + +// Copyright 2019 Peter Dimov +// +// 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/mp11/list.hpp> +#include <boost/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_MP11_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/map_version.cpp b/src/boost/libs/mp11/test/map_version.cpp new file mode 100644 index 000000000..92925f591 --- /dev/null +++ b/src/boost/libs/mp11/test/map_version.cpp @@ -0,0 +1,17 @@ + +// Copyright 2019 Peter Dimov +// +// 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/mp11/map.hpp> +#include <boost/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_MP11_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp11.cpp b/src/boost/libs/mp11/test/mp11.cpp new file mode 100644 index 000000000..6ab26cb7a --- /dev/null +++ b/src/boost/libs/mp11/test/mp11.cpp @@ -0,0 +1,14 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11.hpp> + +int main() +{ +} diff --git a/src/boost/libs/mp11/test/mp11_version.cpp b/src/boost/libs/mp11/test/mp11_version.cpp new file mode 100644 index 000000000..17332664f --- /dev/null +++ b/src/boost/libs/mp11/test/mp11_version.cpp @@ -0,0 +1,17 @@ + +// Copyright 2019 Peter Dimov +// +// 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/mp11.hpp> +#include <boost/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_MP11_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_all.cpp b/src/boost/libs/mp11/test/mp_all.cpp new file mode 100644 index 000000000..64f1e8f6a --- /dev/null +++ b/src/boost/libs/mp11/test/mp_all.cpp @@ -0,0 +1,70 @@ + +// Copyright 2015, 2016 Peter Dimov. +// +// 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/mp11/function.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/detail/config.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +using boost::mp11::mp_all; + +template<class V, class... T> using check1 = mp_all<std::is_same<V, void>, std::is_copy_constructible<T>..., std::is_copy_assignable<T>...>; +template<class V, class... T> using check2 = mp_all<std::is_same<V, void>, mp_all<std::is_copy_constructible<T>..., mp_all<std::is_copy_assignable<T>...>>>; + +int main() +{ + using boost::mp11::mp_true; + using boost::mp11::mp_false; + using boost::mp11::mp_int; + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_int<-7>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_int<0>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_size_t<7>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_size_t<0>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_false, mp_true>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true, mp_false>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_false, mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_int<-7>, mp_int<7>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_size_t<(size_t)-1>, mp_size_t<1>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true, mp_true, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true, mp_false, mp_true>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_false, mp_false, mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true, mp_true, mp_true, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_true, mp_false, mp_true, mp_true>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_false, mp_false, mp_false, mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_int<1>, mp_int<2>, mp_int<-11>, mp_int<14>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_int<1>, mp_int<0>, mp_int<-11>, mp_int<14>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_size_t<1>, mp_size_t<2>, mp_size_t<114>, mp_size_t<8>, mp_size_t<94>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all<mp_size_t<1>, mp_size_t<2>, mp_size_t<114>, mp_size_t<0>, mp_size_t<94>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<check1<void, int, float>, mp_true>)); + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 40900 ) + + BOOST_TEST_TRAIT_TRUE((std::is_same<check2<void, int, float>, mp_true>)); + +#endif + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_all_2.cpp b/src/boost/libs/mp11/test/mp_all_2.cpp new file mode 100644 index 000000000..b656c3dcc --- /dev/null +++ b/src/boost/libs/mp11/test/mp_all_2.cpp @@ -0,0 +1,42 @@ +// Copyright 2021 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/mp11/detail/config.hpp> + +#if BOOST_MP11_MSVC +# pragma warning( disable: 4503 ) // decorated name length exceeded +#endif + +#include <boost/mp11/function.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/algorithm.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_all; + + using boost::mp11::mp_list; + using boost::mp11::mp_apply; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + using boost::mp11::mp_repeat_c; + using boost::mp11::mp_push_back; + + int const N = 1089; + + using L1 = mp_repeat_c<mp_list<mp_true>, N>; + using R1 = mp_apply<mp_all, L1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_true>)); + + using L2 = mp_push_back<L1, mp_false>; + using R2 = mp_apply<mp_all, L2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, mp_false>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_all_of.cpp b/src/boost/libs/mp11/test/mp_all_of.cpp new file mode 100644 index 000000000..8818f90a2 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_all_of.cpp @@ -0,0 +1,80 @@ + +// Copyright 2015, 2016 Peter Dimov. +// +// 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/mp11/detail/config.hpp> + +#if BOOST_MP11_MSVC +# pragma warning( disable: 4503 ) // decorated name length exceeded +#endif + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_all_of; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L1, std::is_const>, mp_true>)); + + using L2 = mp_list<X1 const, X1 const, X1 const volatile, X1 const, X1 const volatile>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L2, std::is_volatile>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L2, std::is_const>, mp_true>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L1, std::is_const>, mp_true>)); + + using L2 = std::tuple<X1 const, X1 const, X1 const volatile, X1 const, X1 const volatile>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L2, std::is_volatile>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L2, std::is_const>, mp_true>)); + } + + { + using L2 = std::pair<X1 const, X1 const volatile>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L2, std::is_volatile>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of<L2, std::is_const>, mp_true>)); + } + + { + using boost::mp11::mp_repeat_c; + using boost::mp11::mp_to_bool; + using boost::mp11::mp_push_back; + + int const N = 1089; + + using L1 = mp_repeat_c<mp_list<mp_true>, N>; + using R1 = mp_all_of<L1, mp_to_bool>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_true>)); + + using L2 = mp_push_back<L1, mp_false>; + using R2 = mp_all_of<L2, mp_to_bool>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, mp_false>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_all_of_q.cpp b/src/boost/libs/mp11/test/mp_all_of_q.cpp new file mode 100644 index 000000000..8a877c552 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_all_of_q.cpp @@ -0,0 +1,59 @@ + +// Copyright 2015, 2016, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_all_of_q; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + using boost::mp11::mp_quote; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L1, mp_quote<std::is_const>>, mp_true>)); + + using L2 = mp_list<X1 const, X1 const, X1 const volatile, X1 const, X1 const volatile>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L2, mp_quote<std::is_volatile>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L2, mp_quote<std::is_const>>, mp_true>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L1, mp_quote<std::is_const>>, mp_true>)); + + using L2 = std::tuple<X1 const, X1 const, X1 const volatile, X1 const, X1 const volatile>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L2, mp_quote<std::is_volatile>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L2, mp_quote<std::is_const>>, mp_true>)); + } + + { + using L2 = std::pair<X1 const, X1 const volatile>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L2, mp_quote<std::is_volatile>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_all_of_q<L2, mp_quote<std::is_const>>, mp_true>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_and.cpp b/src/boost/libs/mp11/test/mp_and.cpp new file mode 100644 index 000000000..93da74a20 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_and.cpp @@ -0,0 +1,64 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/mp11/function.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_and; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + using boost::mp11::mp_int; + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<-7>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<0>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_size_t<7>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_size_t<0>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_false>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_false, void>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<-4>, mp_int<5>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<-4>, mp_int<0>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<0>, void>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_size_t<7>, mp_size_t<8>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_size_t<7>, mp_size_t<0>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_size_t<0>, void>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_true, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_true, mp_false>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_false, void>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_false, void, void>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_true, mp_true, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_true, mp_true, mp_false>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_true, mp_false, void>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_true, mp_false, void, void>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_false, void, void, void>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<1>, mp_int<2>, mp_int<-11>, mp_int<14>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_int<1>, mp_int<0>, void, void>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_size_t<1>, mp_size_t<2>, mp_size_t<114>, mp_size_t<8>, mp_size_t<94>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_and<mp_size_t<1>, mp_size_t<2>, mp_size_t<0>, void, void>, mp_false>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_any.cpp b/src/boost/libs/mp11/test/mp_any.cpp new file mode 100644 index 000000000..9376050ef --- /dev/null +++ b/src/boost/libs/mp11/test/mp_any.cpp @@ -0,0 +1,91 @@ + +// Copyright 2015, 2016, 2019 Peter Dimov. +// +// 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/mp11/function.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/set.hpp> +#include <boost/mp11/detail/config.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +using boost::mp11::mp_any; +using boost::mp11::mp_all; + +template<class... T> using check1 = mp_any<std::is_nothrow_copy_constructible<T>..., mp_any<std::is_nothrow_move_constructible<T>...>>; +template<class... T> using check2 = mp_any<mp_any<std::is_nothrow_copy_constructible<T>...>, std::is_nothrow_move_constructible<T>...>; +template<class... T> using check3 = mp_any<mp_all<std::is_nothrow_copy_constructible<T>...>, std::is_nothrow_default_constructible<T>...>; + +template<bool is_trivially_destructible, bool is_single_buffered, class... T> struct variant_base_impl {}; +#if BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 40800 ) +template<class... T> using variant_base = variant_base_impl<mp_all<std::has_trivial_destructor<T>...>::value, mp_any<mp_all<std::is_nothrow_move_constructible<T>...>, std::is_nothrow_default_constructible<T>...>::value, T...>; +#else +template<class... T> using variant_base = variant_base_impl<mp_all<std::is_trivially_destructible<T>...>::value, mp_any<mp_all<std::is_nothrow_move_constructible<T>...>, std::is_nothrow_default_constructible<T>...>::value, T...>; +#endif + +using boost::mp11::mp_set_contains; + +template<class T, class... S> using in_any_set = mp_any< mp_set_contains<S, T>... >; + +int main() +{ + using boost::mp11::mp_true; + using boost::mp11::mp_false; + using boost::mp11::mp_int; + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_int<-7>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_int<0>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<7>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<0>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_true, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_true, mp_false>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false, mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_int<-7>, mp_int<7>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<(size_t)-1>, mp_size_t<1>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_true, mp_true, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false, mp_false, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false, mp_false, mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_true, mp_true, mp_true, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false, mp_false, mp_true, mp_false>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_false, mp_false, mp_false, mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_int<1>, mp_int<2>, mp_int<-11>, mp_int<14>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_int<0>, mp_int<0>, mp_int<-11>, mp_int<0>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_int<0>, mp_int<0>, mp_int<0>, mp_int<0>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<1>, mp_size_t<2>, mp_size_t<114>, mp_size_t<8>, mp_size_t<94>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<0>, mp_size_t<0>, mp_size_t<114>, mp_size_t<0>, mp_size_t<0>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<0>, mp_size_t<0>, mp_size_t<0>, mp_size_t<0>, mp_size_t<0>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<0>, mp_int<0>, mp_false, mp_size_t<141>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any<mp_size_t<0>, mp_int<0>, mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<check1<void, int, float>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<check2<void, int, float>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<check3<void, int, float>, mp_true>)); + + variant_base<void, int, float>(); + + using boost::mp11::mp_list; + + BOOST_TEST_TRAIT_TRUE((std::is_same<in_any_set<void, mp_list<void>, mp_list<int>>, mp_true>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_any_2.cpp b/src/boost/libs/mp11/test/mp_any_2.cpp new file mode 100644 index 000000000..91f23d9fa --- /dev/null +++ b/src/boost/libs/mp11/test/mp_any_2.cpp @@ -0,0 +1,42 @@ +// Copyright 2021 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/mp11/detail/config.hpp> + +#if BOOST_MP11_MSVC +# pragma warning( disable: 4503 ) // decorated name length exceeded +#endif + +#include <boost/mp11/function.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/algorithm.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_any; + + using boost::mp11::mp_list; + using boost::mp11::mp_apply; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + using boost::mp11::mp_repeat_c; + using boost::mp11::mp_push_back; + + int const N = 1089; + + using L1 = mp_repeat_c<mp_list<mp_false>, N>; + using R1 = mp_apply<mp_any, L1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_false>)); + + using L2 = mp_push_back<L1, mp_true>; + using R2 = mp_apply<mp_any, L2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, mp_true>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_any_of.cpp b/src/boost/libs/mp11/test/mp_any_of.cpp new file mode 100644 index 000000000..8fb7d2ae3 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_any_of.cpp @@ -0,0 +1,95 @@ + +// Copyright 2015, 2016 Peter Dimov. +// +// 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/mp11/detail/config.hpp> + +#if BOOST_MP11_MSVC +# pragma warning( disable: 4503 ) // decorated name length exceeded +#endif + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_any_of; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L1, std::is_const>, mp_false>)); + + using L2 = mp_list<X1, X1 const, X1, X1, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L2, std::is_volatile>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L2, std::is_const>, mp_true>)); + + using L3 = mp_list<X1 const, X1 const, X1, X1 const, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L3, std::is_volatile>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L3, std::is_const>, mp_true>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L1, std::is_const>, mp_false>)); + + using L2 = std::tuple<X1, X1 const, X1, X1, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L2, std::is_volatile>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L2, std::is_const>, mp_true>)); + + using L3 = std::tuple<X1 const, X1 const, X1, X1 const, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L3, std::is_volatile>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L3, std::is_const>, mp_true>)); + } + + { + using L2 = std::pair<X1 const, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L2, std::is_volatile>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L2, std::is_const>, mp_true>)); + + using L3 = std::pair<X1 const, X1 const>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L3, std::is_volatile>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of<L3, std::is_const>, mp_true>)); + } + + { + using boost::mp11::mp_repeat_c; + using boost::mp11::mp_to_bool; + using boost::mp11::mp_push_back; + + int const N = 1089; + + using L1 = mp_repeat_c<mp_list<mp_false>, N>; + using R1 = mp_any_of<L1, mp_to_bool>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_false>)); + + using L2 = mp_push_back<L1, mp_true>; + using R2 = mp_any_of<L2, mp_to_bool>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, mp_true>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_any_of_q.cpp b/src/boost/libs/mp11/test/mp_any_of_q.cpp new file mode 100644 index 000000000..17b50dcf0 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_any_of_q.cpp @@ -0,0 +1,74 @@ + +// Copyright 2015, 2016, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_any_of_q; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + using boost::mp11::mp_quote; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L1, mp_quote<std::is_const>>, mp_false>)); + + using L2 = mp_list<X1, X1 const, X1, X1, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L2, mp_quote<std::is_volatile>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L2, mp_quote<std::is_const>>, mp_true>)); + + using L3 = mp_list<X1 const, X1 const, X1, X1 const, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L3, mp_quote<std::is_volatile>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L3, mp_quote<std::is_const>>, mp_true>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L1, mp_quote<std::is_const>>, mp_false>)); + + using L2 = std::tuple<X1, X1 const, X1, X1, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L2, mp_quote<std::is_volatile>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L2, mp_quote<std::is_const>>, mp_true>)); + + using L3 = std::tuple<X1 const, X1 const, X1, X1 const, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L3, mp_quote<std::is_volatile>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L3, mp_quote<std::is_const>>, mp_true>)); + } + + { + using L2 = std::pair<X1 const, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L2, mp_quote<std::is_volatile>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L2, mp_quote<std::is_const>>, mp_true>)); + + using L3 = std::pair<X1 const, X1 const>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L3, mp_quote<std::is_volatile>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_any_of_q<L3, mp_quote<std::is_const>>, mp_true>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_append.cpp b/src/boost/libs/mp11/test/mp_append.cpp new file mode 100644 index 000000000..264359a17 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_append.cpp @@ -0,0 +1,76 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/list.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; +struct X6 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_append; + + using L1 = mp_list<char[1], char[1]>; + using L2 = mp_list<char[2], char[2]>; + using L3 = mp_list<char[3], char[3]>; + using L4 = mp_list<char[4], char[4]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<L1>, mp_list<char[1], char[1]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<L1, L2>, mp_list<char[1], char[1], char[2], char[2]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<L1, L2, L3>, mp_list<char[1], char[1], char[2], char[2], char[3], char[3]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<L1, L2, L3, L4>, mp_list<char[1], char[1], char[2], char[2], char[3], char[3], char[4], char[4]>>)); + + // + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, std::tuple<X1>>, std::tuple<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, std::tuple<X1>, std::tuple<X2>>, std::tuple<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, std::tuple<X1>, std::tuple<X2>, std::tuple<X3>>, std::tuple<X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, std::tuple<X1>, std::tuple<X2>, std::tuple<X3>, std::tuple<X4>>, std::tuple<X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, std::tuple<X1>, std::tuple<X2>, std::tuple<X3>, std::tuple<X4>, std::tuple<X5>>, std::tuple<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, std::tuple<X1>, std::tuple<X2>, std::tuple<X3>, std::tuple<X4>, std::tuple<X5>, std::tuple<X6>>, std::tuple<X1, X2, X3, X4, X5, X6>>)); + + // + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, mp_list<>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, mp_list<X1>>, std::tuple<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, mp_list<X1>, std::tuple<X2>>, std::tuple<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, mp_list<X1>, std::tuple<X2>, mp_list<X3>>, std::tuple<X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, mp_list<X1>, std::tuple<X2>, mp_list<X3>, std::tuple<X4>>, std::tuple<X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, mp_list<X1>, std::tuple<X2>, mp_list<X3>, std::tuple<X4>, mp_list<X5>>, std::tuple<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, mp_list<X1>, std::tuple<X2>, mp_list<X3>, std::tuple<X4>, mp_list<X5>, std::tuple<X6>>, std::tuple<X1, X2, X3, X4, X5, X6>>)); + + // + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, std::pair<X1, X2>>, std::tuple<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, std::pair<X1, X2>, std::pair<X3, X4>>, std::tuple<X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::tuple<>, std::pair<X1, X2>, std::pair<X3, X4>, std::pair<X5, X6>>, std::tuple<X1, X2, X3, X4, X5, X6>>)); + + // + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::pair<X1, X2>>, std::pair<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::pair<X1, X2>, mp_list<>>, std::pair<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::pair<X1, X2>, mp_list<>, mp_list<>>, std::pair<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::pair<X1, X2>, mp_list<>, mp_list<>, mp_list<>>, std::pair<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_append<std::pair<X1, X2>, mp_list<>, mp_list<>, mp_list<>, mp_list<>>, std::pair<X1, X2>>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_append_2.cpp b/src/boost/libs/mp11/test/mp_append_2.cpp new file mode 100644 index 000000000..4b3bebd4f --- /dev/null +++ b/src/boost/libs/mp11/test/mp_append_2.cpp @@ -0,0 +1,38 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/algorithm.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +template<class T> struct W; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_append; + using boost::mp11::mp_iota_c; + using boost::mp11::mp_transform; + using boost::mp11::mp_rename; + using boost::mp11::mp_push_front; + + using L1 = mp_iota_c<125>; + using L2 = mp_transform<W, L1>; + using L3 = mp_push_front<L2, mp_list<>>; + using L4 = mp_rename<L3, mp_append>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<L4, L1>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_append_sf.cpp b/src/boost/libs/mp11/test/mp_append_sf.cpp new file mode 100644 index 000000000..80c417c10 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_append_sf.cpp @@ -0,0 +1,32 @@ + +// Copyright 2019 Peter Dimov. +// +// 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/mp11/list.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> + +int main() +{ + using boost::mp11::mp_append; + using boost::mp11::mp_valid; + using boost::mp11::mp_list; + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, void, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, void, void, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, void, void, void, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, mp_list<>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, mp_list<>, mp_list<>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, mp_list<>, mp_list<>, mp_list<>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, mp_list<>, mp_list<>, mp_list<>, mp_list<>, void>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_apply_q.cpp b/src/boost/libs/mp11/test/mp_apply_q.cpp new file mode 100644 index 000000000..d2a47c04b --- /dev/null +++ b/src/boost/libs/mp11/test/mp_apply_q.cpp @@ -0,0 +1,113 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/utility.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +template<class... T> struct X {}; +template<class... T> using Y = X<T...>; + +struct Q +{ + template<class... T> using fn = X<T...>; +}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_quote; + using boost::mp11::mp_apply_q; + + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<mp_list>, L1>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<std::tuple>, L1>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<X>, L1>, X<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<Y>, L1>, Y<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<Q, L1>, X<>>)); + + using L2 = mp_list<char>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<mp_list>, L2>, mp_list<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<std::tuple>, L2>, std::tuple<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<X>, L2>, X<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<Y>, L2>, Y<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<Q, L2>, X<char>>)); + + using L3 = mp_list<char, double>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<mp_list>, L3>, mp_list<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<std::tuple>, L3>, std::tuple<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<X>, L3>, X<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<Y>, L3>, Y<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<std::pair>, L3>, std::pair<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<Q, L3>, X<char, double>>)); + + using L4 = mp_list<int, char, float>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<mp_list>, L4>, mp_list<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<std::tuple>, L4>, std::tuple<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<X>, L4>, X<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<Y>, L4>, Y<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<Q, L4>, X<int, char, float>>)); + + // + + using L5 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<mp_list>, L5>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<std::tuple>, L5>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<X>, L5>, X<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<Y>, L5>, Y<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<Q, L5>, X<>>)); + + using L6 = std::tuple<char>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<mp_list>, L6>, mp_list<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<std::tuple>, L6>, std::tuple<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<X>, L6>, X<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<Y>, L6>, Y<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<Q, L6>, X<char>>)); + + using L7 = std::tuple<char, double>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<mp_list>, L7>, mp_list<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<std::tuple>, L7>, std::tuple<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<X>, L7>, X<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<Y>, L7>, Y<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<std::pair>, L7>, std::pair<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<Q, L7>, X<char, double>>)); + + using L8 = std::tuple<int, char, float>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<mp_list>, L8>, mp_list<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<std::tuple>, L8>, std::tuple<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<X>, L8>, X<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<Y>, L8>, Y<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<Q, L8>, X<int, char, float>>)); + + // + + using L9 = std::pair<char, double>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<mp_list>, L9>, mp_list<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<std::tuple>, L9>, std::tuple<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<X>, L9>, X<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<Y>, L9>, Y<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<mp_quote<std::pair>, L9>, std::pair<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply_q<Q, L9>, X<char, double>>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_assign.cpp b/src/boost/libs/mp11/test/mp_assign.cpp new file mode 100644 index 000000000..60edd0cb3 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_assign.cpp @@ -0,0 +1,64 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_assign; + + using L1 = mp_list<int, void(), float[]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, mp_list<>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, mp_list<X1>>, mp_list<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, mp_list<X1, X2>>, mp_list<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, mp_list<X1, X2, X3>>, mp_list<X1, X2, X3>>)); + + // + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, std::tuple<>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, std::tuple<X1>>, mp_list<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, std::tuple<X1, X2>>, mp_list<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, std::tuple<X1, X2, X3>>, mp_list<X1, X2, X3>>)); + + // + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L1, std::pair<X1, X2>>, mp_list<X1, X2>>)); + + // + + using L2 = std::tuple<int, char, float>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L2, mp_list<>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L2, mp_list<X1>>, std::tuple<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L2, mp_list<X1, X2>>, std::tuple<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L2, mp_list<X1, X2, X3>>, std::tuple<X1, X2, X3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L2, std::pair<X1, X2>>, std::tuple<X1, X2>>)); + + // + + using L3 = std::pair<int, char>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L3, mp_list<X1, X2>>, std::pair<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_assign<L3, std::pair<X1, X2>>, std::pair<X1, X2>>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_at.cpp b/src/boost/libs/mp11/test/mp_at.cpp new file mode 100644 index 000000000..6ff3fd43b --- /dev/null +++ b/src/boost/libs/mp11/test/mp_at.cpp @@ -0,0 +1,74 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_at; + using boost::mp11::mp_at_c; + using boost::mp11::mp_size_t; + + { + using L1 = mp_list<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 0>, X1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 1>, X2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 2>, X3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 3>, X4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 4>, X5>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<0>>, X1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<1>>, X2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<2>>, X3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<3>>, X4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<4>>, X5>)); + } + + { + using L1 = std::tuple<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 0>, X1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 1>, X2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 2>, X3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 3>, X4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 4>, X5>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<0>>, X1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<1>>, X2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<2>>, X3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<3>>, X4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<4>>, X5>)); + } + + { + using L1 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 0>, X1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 1>, X2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<0>>, X1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<1>>, X2>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_at_sf.cpp b/src/boost/libs/mp11/test/mp_at_sf.cpp new file mode 100644 index 000000000..00463f9ff --- /dev/null +++ b/src/boost/libs/mp11/test/mp_at_sf.cpp @@ -0,0 +1,39 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/mp11/algorithm.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +using boost::mp11::mp_valid; +using boost::mp11::mp_at; +using boost::mp11::mp_size_t; +using boost::mp11::mp_list; + +int main() +{ + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_at>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_at, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_at, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_at, void, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_at, void, mp_size_t<0>>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_at, mp_list<>, mp_size_t<0>>)); + + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_at, mp_list<void>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_at, mp_list<void>, mp_size_t<1>>)); + + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_at, mp_list<void, void>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_at, mp_list<void, void>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_at, mp_list<void, void>, mp_size_t<2>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_back.cpp b/src/boost/libs/mp11/test/mp_back.cpp new file mode 100644 index 000000000..457364eee --- /dev/null +++ b/src/boost/libs/mp11/test/mp_back.cpp @@ -0,0 +1,52 @@ + +// Copyright 2015, 2019 Peter Dimov +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/utility.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_back; + + using L1 = mp_list<void>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_back<L1>, void>)); + + using L2 = mp_list<float, void, int[]>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_back<L2>, int[]>)); + + using L3 = std::tuple<int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_back<L3>, int>)); + + using L4 = std::pair<char, double>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_back<L4>, double>)); + + using L5 = std::add_const<void()>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_back<L5>, void()>)); + + using boost::mp11::mp_iota_c; + using boost::mp11::mp_size_t; + + int const N = 137; + + using L6 = mp_iota_c<N>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_back<L6>, mp_size_t<N-1>>)); + + using boost::mp11::mp_valid; + + using L7 = mp_list<>; + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_back, L7>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_bind.cpp b/src/boost/libs/mp11/test/mp_bind.cpp new file mode 100644 index 000000000..1174bf48c --- /dev/null +++ b/src/boost/libs/mp11/test/mp_bind.cpp @@ -0,0 +1,106 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/bind.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/algorithm.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; +struct X6 {}; +struct X7 {}; +struct X8 {}; +struct X9 {}; + +template<class T> using add_pointer = T*; + +int main() +{ + using namespace boost::mp11; + + BOOST_TEST_TRAIT_TRUE((std::is_same<_1::fn<X1>, X1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<_1::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<_2::fn<X1, X2>, X2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<_2::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<_3::fn<X1, X2, X3>, X3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<_3::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X3>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<_4::fn<X1, X2, X3, X4>, X4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<_4::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X4>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<_5::fn<X1, X2, X3, X4, X5>, X5>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<_5::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X5>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<_6::fn<X1, X2, X3, X4, X5, X6>, X6>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<_6::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X6>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<_7::fn<X1, X2, X3, X4, X5, X6, X7>, X7>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<_7::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X7>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<_8::fn<X1, X2, X3, X4, X5, X6, X7, X8>, X8>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<_8::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X8>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<_9::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X9>)); + + // + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _1>::fn<X1>, X1*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _1>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X1*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _2>::fn<X1, X2>, X2*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _2>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X2*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _3>::fn<X1, X2, X3>, X3*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _3>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X3*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _4>::fn<X1, X2, X3, X4>, X4*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _4>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X4*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _5>::fn<X1, X2, X3, X4, X5>, X5*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _5>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X5*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _6>::fn<X1, X2, X3, X4, X5, X6>, X6*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _6>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X6*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _7>::fn<X1, X2, X3, X4, X5, X6, X7>, X7*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _7>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X7*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _8>::fn<X1, X2, X3, X4, X5, X6, X7, X8>, X8*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _8>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X8*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind<add_pointer, _9>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X9*>)); + + // + + BOOST_TEST_TRAIT_TRUE((std::is_same< + mp_bind<std::tuple, + mp_bind<add_pointer, _9>, + mp_bind<add_pointer, _8>, + mp_bind<add_pointer, _7>, + mp_bind<add_pointer, _6>, + mp_bind<add_pointer, _5>, + mp_bind<add_pointer, _4>, + mp_bind<add_pointer, _3>, + mp_bind<add_pointer, _2>, + mp_bind<add_pointer, _1> + >::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, std::tuple<X9*, X8*, X7*, X6*, X5*, X4*, X3*, X2*, X1*>>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_bind_back.cpp b/src/boost/libs/mp11/test/mp_bind_back.cpp new file mode 100644 index 000000000..f497a13be --- /dev/null +++ b/src/boost/libs/mp11/test/mp_bind_back.cpp @@ -0,0 +1,63 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/bind.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/mp11/algorithm.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +template<class...> struct L {}; +template<class, class> struct P {}; + +template<class T, class U> using is_base_of_t = typename std::is_base_of<T, U>::type; + +struct B1 {}; +struct B2 {}; +struct D: B1, B2 {}; +struct NB {}; + +int main() +{ + using namespace boost::mp11; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_back<L, char[1], char[2]>::fn<int[1], int[2], int[3]>, L<int[1], int[2], int[3], char[1], char[2]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_back_q<mp_quote<L>, char[1], char[2]>::fn<int[1], int[2], int[3]>, L<int[1], int[2], int[3], char[1], char[2]>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_back<P, char[1]>::fn<int[1]>, P<int[1], char[1]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_back_q<mp_quote<P>, char[1]>::fn<int[1]>, P<int[1], char[1]>>)); + + // + + using L1 = L<B1, B2, NB>; + + { + using L2 = mp_transform<mp_bind_back<is_base_of_t, D>::fn, L1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<L2, L<std::true_type, std::true_type, std::false_type>>)); + } + + { + using L2 = mp_transform_q<mp_bind_back<is_base_of_t, D>, L1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<L2, L<std::true_type, std::true_type, std::false_type>>)); + } + + { + using L2 = mp_transform<mp_bind_back_q<mp_quote<is_base_of_t>, D>::fn, L1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<L2, L<std::true_type, std::true_type, std::false_type>>)); + } + + { + using L2 = mp_transform_q<mp_bind_back_q<mp_quote<is_base_of_t>, D>, L1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<L2, L<std::true_type, std::true_type, std::false_type>>)); + } + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_bind_front.cpp b/src/boost/libs/mp11/test/mp_bind_front.cpp new file mode 100644 index 000000000..bce077f1f --- /dev/null +++ b/src/boost/libs/mp11/test/mp_bind_front.cpp @@ -0,0 +1,63 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/bind.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/mp11/algorithm.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +template<class...> struct L {}; +template<class, class> struct P {}; + +template<class T, class U> using is_base_of_t = typename std::is_base_of<T, U>::type; + +struct B {}; +struct D1: B {}; +struct D2: B {}; +struct ND {}; + +int main() +{ + using namespace boost::mp11; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_front<L, char[1], char[2]>::fn<int[1], int[2], int[3]>, L<char[1], char[2], int[1], int[2], int[3]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_front_q<mp_quote<L>, char[1], char[2]>::fn<int[1], int[2], int[3]>, L<char[1], char[2], int[1], int[2], int[3]>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_front<P, char[1]>::fn<int[1]>, P<char[1], int[1]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_front_q<mp_quote<P>, char[1]>::fn<int[1]>, P<char[1], int[1]>>)); + + // + + using L1 = L<D1, D2, ND>; + + { + using L2 = mp_transform<mp_bind_front<is_base_of_t, B>::fn, L1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<L2, L<std::true_type, std::true_type, std::false_type>>)); + } + + { + using L2 = mp_transform_q<mp_bind_front<is_base_of_t, B>, L1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<L2, L<std::true_type, std::true_type, std::false_type>>)); + } + + { + using L2 = mp_transform<mp_bind_front_q<mp_quote<is_base_of_t>, B>::fn, L1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<L2, L<std::true_type, std::true_type, std::false_type>>)); + } + + { + using L2 = mp_transform_q<mp_bind_front_q<mp_quote<is_base_of_t>, B>, L1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<L2, L<std::true_type, std::true_type, std::false_type>>)); + } + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_bind_q.cpp b/src/boost/libs/mp11/test/mp_bind_q.cpp new file mode 100644 index 000000000..0fa495cdf --- /dev/null +++ b/src/boost/libs/mp11/test/mp_bind_q.cpp @@ -0,0 +1,62 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/bind.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; +struct X6 {}; +struct X7 {}; +struct X8 {}; +struct X9 {}; + +template<class T> using add_pointer = typename std::add_pointer<T>::type; + +int main() +{ + using namespace boost::mp11; + + using Q_addp = mp_quote<add_pointer>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _1>::fn<X1>, X1*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _1>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X1*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _2>::fn<X1, X2>, X2*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _2>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X2*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _3>::fn<X1, X2, X3>, X3*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _3>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X3*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _4>::fn<X1, X2, X3, X4>, X4*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _4>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X4*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _5>::fn<X1, X2, X3, X4, X5>, X5*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _5>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X5*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _6>::fn<X1, X2, X3, X4, X5, X6>, X6*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _6>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X6*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _7>::fn<X1, X2, X3, X4, X5, X6, X7>, X7*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _7>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X7*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _8>::fn<X1, X2, X3, X4, X5, X6, X7, X8>, X8*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _8>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X8*>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_bind_q<Q_addp, _9>::fn<X1, X2, X3, X4, X5, X6, X7, X8, X9>, X9*>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_clear.cpp b/src/boost/libs/mp11/test/mp_clear.cpp new file mode 100644 index 000000000..9684c7140 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_clear.cpp @@ -0,0 +1,31 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_clear; + + using L1 = mp_list<int, void(), float[]>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_clear<L1>, mp_list<>>)); + + // + + using L2 = std::tuple<int, char, float>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_clear<L2>, std::tuple<>>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_compose.cpp b/src/boost/libs/mp11/test/mp_compose.cpp new file mode 100644 index 000000000..b8259e8af --- /dev/null +++ b/src/boost/libs/mp11/test/mp_compose.cpp @@ -0,0 +1,70 @@ + +// Copyright 2017, 2020 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> + +template<class T> struct F1 {}; +template<class T> struct F2 {}; +template<class T> struct F3 {}; + +template<class T> using G1 = F1<T>; +template<class T> using G2 = F2<T>; +template<class T> using G3 = F3<T>; + +template<class... T> struct H {}; + +int main() +{ + using namespace boost::mp11; + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1900 ) + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<>::fn<void>, void>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<F1>::fn<void>, F1<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<G1>::fn<void>, F1<void>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<F1, F2>::fn<void>, F2<F1<void>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<G1, G2>::fn<void>, F2<F1<void>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<F1, F2, F3>::fn<void>, F3<F2<F1<void>>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<G1, G2, G3>::fn<void>, F3<F2<F1<void>>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<H>::fn<int, char>, H<int, char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<H, F1>::fn<void, float>, F1<H<void, float>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<H, F1, G1>::fn<void, float>, G1<F1<H<void, float>>>>)); + +#endif + + using QF1 = mp_quote<F1>; + using QF2 = mp_quote<F2>; + using QF3 = mp_quote<F3>; + + using QG1 = mp_quote<G1>; + using QG2 = mp_quote<G2>; + using QG3 = mp_quote<G3>; + + using QH = mp_quote<H>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<>::fn<void>, void>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QF1>::fn<void>, F1<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QG1>::fn<void>, F1<void>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QF1, QF2>::fn<void>, F2<F1<void>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QG1, QG2>::fn<void>, F2<F1<void>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QF1, QF2, QF3>::fn<void>, F3<F2<F1<void>>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QG1, QG2, QG3>::fn<void>, F3<F2<F1<void>>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QH>::fn<int, char>, H<int, char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QH, QF1>::fn<void, float>, F1<H<void, float>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QH, QF1, QG1>::fn<void, float>, G1<F1<H<void, float>>>>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_cond.cpp b/src/boost/libs/mp11/test/mp_cond.cpp new file mode 100644 index 000000000..08a625fa7 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_cond.cpp @@ -0,0 +1,42 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_cond; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_true, char[]>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_true, char[], void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_true, char[], void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_true, char[], void, void, void>, char[]>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_false, int, mp_true, char[]>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_false, int, mp_true, char[], void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_false, int, mp_true, char[], void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_false, int, mp_true, char[], void, void, void>, char[]>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_false, int, mp_false, float, mp_true, char[]>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_false, int, mp_false, float, mp_true, char[], void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_false, int, mp_false, float, mp_true, char[], void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_false, int, mp_false, float, mp_true, char[], void, void, void>, char[]>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_false, int, mp_false, float, mp_false, double, mp_true, char[]>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_false, int, mp_false, float, mp_false, double, mp_true, char[], void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_false, int, mp_false, float, mp_false, double, mp_true, char[], void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_cond<mp_false, int, mp_false, float, mp_false, double, mp_true, char[], void, void, void>, char[]>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_cond_sf.cpp b/src/boost/libs/mp11/test/mp_cond_sf.cpp new file mode 100644 index 000000000..c1bb4de5d --- /dev/null +++ b/src/boost/libs/mp11/test/mp_cond_sf.cpp @@ -0,0 +1,43 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_cond; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + using boost::mp11::mp_valid; + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_cond>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_cond, mp_true>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_cond, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_cond, mp_true, void>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_cond, mp_true, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_cond, mp_false, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_cond, mp_false, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_cond, mp_false, void, mp_true>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_cond, mp_false, void, mp_true, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_cond, mp_false, void, mp_false>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_cond, mp_false, void, mp_false, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_cond, mp_false, void, mp_false, void, mp_true>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_cond, mp_false, void, mp_false, void, mp_true, void>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_contains.cpp b/src/boost/libs/mp11/test/mp_contains.cpp new file mode 100644 index 000000000..04bfac64a --- /dev/null +++ b/src/boost/libs/mp11/test/mp_contains.cpp @@ -0,0 +1,64 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_contains; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L1, void>, mp_false>)); + + using L2 = mp_list<X1, X2, X3, X2, X3, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L2, void>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L2, X1>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L2, X2>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L2, X3>, mp_true>)); + } + + { + using L3 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L3, void>, mp_false>)); + + using L4 = std::tuple<X1, X2, X3, X2, X3, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L4, void>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L4, X1>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L4, X2>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L4, X3>, mp_true>)); + } + + { + using L5 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L5, void>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L5, X1>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_contains<L5, X2>, mp_true>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_copy_if.cpp b/src/boost/libs/mp11/test/mp_copy_if.cpp new file mode 100644 index 000000000..0cf54d498 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_copy_if.cpp @@ -0,0 +1,67 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +using boost::mp11::mp_bool; + +template<class N> using is_even = mp_bool<N::value % 2 == 0>; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_copy_if; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if<L1, std::is_const>, L1>)); + + using L2 = mp_list<X1, X1 const, X1*, X2 const, X2*, X3*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if<L2, std::is_volatile>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if<L2, std::is_const>, mp_list<X1 const, X2 const>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if<L2, std::is_pointer>, mp_list<X1*, X2*, X3*>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if<L1, std::is_const>, L1>)); + + using L2 = std::tuple<X1, X1 const, X1*, X2 const, X2*, X3*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if<L2, std::is_volatile>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if<L2, std::is_const>, std::tuple<X1 const, X2 const>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if<L2, std::is_pointer>, std::tuple<X1*, X2*, X3*>>)); + } + + using boost::mp11::mp_iota_c; + using boost::mp11::mp_size_t; + + { + int const N = 12; + using L1 = mp_iota_c<N>; + + using R1 = mp_copy_if<L1, is_even>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_list<mp_size_t<0>, mp_size_t<2>, mp_size_t<4>, mp_size_t<6>, mp_size_t<8>, mp_size_t<10>>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_copy_if_q.cpp b/src/boost/libs/mp11/test/mp_copy_if_q.cpp new file mode 100644 index 000000000..ef75db222 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_copy_if_q.cpp @@ -0,0 +1,72 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +using boost::mp11::mp_bool; + +struct Q_is_even +{ + template<class N> using fn = mp_bool<N::value % 2 == 0>; +}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_copy_if_q; + using boost::mp11::mp_quote; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if_q<L1, mp_quote<std::is_const>>, L1>)); + + using L2 = mp_list<X1, X1 const, X1*, X2 const, X2*, X3*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if_q<L2, mp_quote<std::is_volatile>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if_q<L2, mp_quote<std::is_const>>, mp_list<X1 const, X2 const>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if_q<L2, mp_quote<std::is_pointer>>, mp_list<X1*, X2*, X3*>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if_q<L1, mp_quote<std::is_const>>, L1>)); + + using L2 = std::tuple<X1, X1 const, X1*, X2 const, X2*, X3*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if_q<L2, mp_quote<std::is_volatile>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if_q<L2, mp_quote<std::is_const>>, std::tuple<X1 const, X2 const>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_copy_if_q<L2, mp_quote<std::is_pointer>>, std::tuple<X1*, X2*, X3*>>)); + } + + using boost::mp11::mp_iota_c; + using boost::mp11::mp_size_t; + + { + int const N = 12; + using L1 = mp_iota_c<N>; + + using R1 = mp_copy_if_q<L1, Q_is_even>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_list<mp_size_t<0>, mp_size_t<2>, mp_size_t<4>, mp_size_t<6>, mp_size_t<8>, mp_size_t<10>>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_count.cpp b/src/boost/libs/mp11/test/mp_count.cpp new file mode 100644 index 000000000..f17227441 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_count.cpp @@ -0,0 +1,80 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/detail/config.hpp> + +#if BOOST_MP11_MSVC +# pragma warning( disable: 4503 ) // decorated name length exceeded +#endif + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_count; + using boost::mp11::mp_size_t; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count<L1, void>, mp_size_t<0>>)); + + using L2 = mp_list<X1, X2, X3, X2, X3, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count<L2, void>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count<L2, X1>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count<L2, X2>, mp_size_t<2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count<L2, X3>, mp_size_t<3>>)); + } + + { + using L3 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count<L3, void>, mp_size_t<0>>)); + + using L4 = std::tuple<X1, X2, X3, X2, X3, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count<L4, void>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count<L4, X1>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count<L4, X2>, mp_size_t<2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count<L4, X3>, mp_size_t<3>>)); + } + + { + using L5 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count<L5, void>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count<L5, X1>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count<L5, X2>, mp_size_t<1>>)); + } + + { + using boost::mp11::mp_repeat_c; + + int const N = 1089; + + using L = mp_repeat_c<mp_list<void>, N>; + using R = mp_count<L, void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R, mp_size_t<N>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_count_if.cpp b/src/boost/libs/mp11/test/mp_count_if.cpp new file mode 100644 index 000000000..911bcf05b --- /dev/null +++ b/src/boost/libs/mp11/test/mp_count_if.cpp @@ -0,0 +1,79 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/detail/config.hpp> + +#if BOOST_MP11_MSVC +# pragma warning( disable: 4503 ) // decorated name length exceeded +#endif + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; + +using boost::mp11::mp_bool; + +template<class T> using is_even = mp_bool< T::value % 2 == 0 >; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_count_if; + using boost::mp11::mp_size_t; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if<L1, std::is_const>, mp_size_t<0>>)); + + using L2 = mp_list<X1, X1 const, X1*, X1 const, X1*, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if<L2, std::is_volatile>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if<L2, std::is_const>, mp_size_t<2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if<L2, std::is_pointer>, mp_size_t<3>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if<L1, std::is_const>, mp_size_t<0>>)); + + using L2 = std::tuple<X1, X1 const, X1*, X1 const, X1*, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if<L2, std::is_volatile>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if<L2, std::is_const>, mp_size_t<2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if<L2, std::is_pointer>, mp_size_t<3>>)); + } + + { + using L2 = std::pair<X1 const, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if<L2, std::is_volatile>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if<L2, std::is_const>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if<L2, std::is_pointer>, mp_size_t<1>>)); + } + + { + using boost::mp11::mp_iota_c; + + int const N = 1089; + + using L = mp_iota_c<N>; + using R = mp_count_if<L, is_even>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R, mp_size_t<(N + 1) / 2>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_count_if_q.cpp b/src/boost/libs/mp11/test/mp_count_if_q.cpp new file mode 100644 index 000000000..d76ab4d2b --- /dev/null +++ b/src/boost/libs/mp11/test/mp_count_if_q.cpp @@ -0,0 +1,61 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_count_if_q; + using boost::mp11::mp_size_t; + using boost::mp11::mp_quote; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if_q<L1, mp_quote<std::is_const>>, mp_size_t<0>>)); + + using L2 = mp_list<X1, X1 const, X1*, X1 const, X1*, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if_q<L2, mp_quote<std::is_volatile>>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if_q<L2, mp_quote<std::is_const>>, mp_size_t<2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if_q<L2, mp_quote<std::is_pointer>>, mp_size_t<3>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if_q<L1, mp_quote<std::is_const>>, mp_size_t<0>>)); + + using L2 = std::tuple<X1, X1 const, X1*, X1 const, X1*, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if_q<L2, mp_quote<std::is_volatile>>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if_q<L2, mp_quote<std::is_const>>, mp_size_t<2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if_q<L2, mp_quote<std::is_pointer>>, mp_size_t<3>>)); + } + + { + using L2 = std::pair<X1 const, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if_q<L2, mp_quote<std::is_volatile>>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if_q<L2, mp_quote<std::is_const>>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_count_if_q<L2, mp_quote<std::is_pointer>>, mp_size_t<1>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_defer.cpp b/src/boost/libs/mp11/test/mp_defer.cpp new file mode 100644 index 000000000..e09973eed --- /dev/null +++ b/src/boost/libs/mp11/test/mp_defer.cpp @@ -0,0 +1,65 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/detail/config.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +using boost::mp11::mp_identity; +using boost::mp11::mp_true; +using boost::mp11::mp_false; + +template<class T> struct has_type +{ + template<class U> static mp_true f( mp_identity<typename U::type>* ); + template<class U> static mp_false f( ... ); + + using type = decltype( f<T>(0) ); + + static const bool value = type::value; +}; + +using boost::mp11::mp_defer; + +template<class T> using add_pointer = T*; +template<class... T> using add_pointer_impl = mp_defer<add_pointer, T...>; + +using boost::mp11::mp_quote; + +using Q_add_pointer = mp_quote<add_pointer>; +template<class... T> using Q_add_pointer_impl = mp_defer<Q_add_pointer::fn, T...>; + +int main() +{ + BOOST_TEST_TRAIT_TRUE((has_type<add_pointer_impl<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<add_pointer_impl<void>::type, void*>)); + + BOOST_TEST_TRAIT_TRUE((has_type<add_pointer_impl<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<add_pointer_impl<int>::type, int*>)); + + BOOST_TEST_TRAIT_FALSE((has_type<add_pointer_impl<>>)); + BOOST_TEST_TRAIT_FALSE((has_type<add_pointer_impl<void, void>>)); + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) + BOOST_TEST_TRAIT_TRUE((has_type<Q_add_pointer_impl<void>>)); +#endif + BOOST_TEST_TRAIT_TRUE((std::is_same<Q_add_pointer_impl<void>::type, void*>)); + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) + BOOST_TEST_TRAIT_TRUE((has_type<Q_add_pointer_impl<int>>)); +#endif + BOOST_TEST_TRAIT_TRUE((std::is_same<Q_add_pointer_impl<int>::type, int*>)); + + BOOST_TEST_TRAIT_FALSE((has_type<Q_add_pointer_impl<>>)); + BOOST_TEST_TRAIT_FALSE((has_type<Q_add_pointer_impl<void, void>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_drop.cpp b/src/boost/libs/mp11/test/mp_drop.cpp new file mode 100644 index 000000000..186aa948e --- /dev/null +++ b/src/boost/libs/mp11/test/mp_drop.cpp @@ -0,0 +1,85 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_drop; + using boost::mp11::mp_drop_c; + using boost::mp11::mp_size_t; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L1, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L1, mp_size_t<0>>, L1>)); + + using L2 = mp_list<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 0>, mp_list<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 1>, mp_list<X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 2>, mp_list<X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 3>, mp_list<X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 4>, mp_list<X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 5>, mp_list<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<0>>, mp_list<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<1>>, mp_list<X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<2>>, mp_list<X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<3>>, mp_list<X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<4>>, mp_list<X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<5>>, mp_list<>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L1, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L1, mp_size_t<0>>, L1>)); + + using L2 = std::tuple<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 0>, std::tuple<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 1>, std::tuple<X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 2>, std::tuple<X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 3>, std::tuple<X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 4>, std::tuple<X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 5>, std::tuple<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<0>>, std::tuple<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<1>>, std::tuple<X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<2>>, std::tuple<X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<3>>, std::tuple<X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<4>>, std::tuple<X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<5>>, std::tuple<>>)); + } + + { + using L1 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L1, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L1, mp_size_t<0>>, L1>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_empty.cpp b/src/boost/libs/mp11/test/mp_empty.cpp new file mode 100644 index 000000000..87e0fb7cf --- /dev/null +++ b/src/boost/libs/mp11/test/mp_empty.cpp @@ -0,0 +1,49 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_empty; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + using L1 = mp_list<>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_empty<L1>, mp_true>)); + + using L2 = mp_list<void>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_empty<L2>, mp_false>)); + + using L3 = mp_list<int[], void, float>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_empty<L3>, mp_false>)); + + using L4 = std::tuple<>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_empty<L4>, mp_true>)); + + using L5 = std::tuple<int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_empty<L5>, mp_false>)); + + using L6 = std::tuple<int, int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_empty<L6>, mp_false>)); + + using L7 = std::pair<char, double>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_empty<L7>, mp_false>)); + + using L8 = std::add_const<void()>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_empty<L8>, mp_false>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_erase.cpp b/src/boost/libs/mp11/test/mp_erase.cpp new file mode 100644 index 000000000..10e9638cf --- /dev/null +++ b/src/boost/libs/mp11/test/mp_erase.cpp @@ -0,0 +1,171 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_erase; + using boost::mp11::mp_erase_c; + using boost::mp11::mp_size_t; + + using _0 = mp_size_t<0>; + using _1 = mp_size_t<1>; + using _2 = mp_size_t<2>; + using _3 = mp_size_t<3>; + using _4 = mp_size_t<4>; + using _5 = mp_size_t<5>; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L1, 0, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L1, _0, _0>, L1>)); + + using L2 = mp_list<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 0, 0>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 1, 1>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 2, 2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 3, 3>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 4, 4>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 5, 5>, L2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _0, _0>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _1, _1>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _2, _2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _3, _3>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _4, _4>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _5, _5>, L2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 0, 1>, mp_list<X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 1, 2>, mp_list<X1, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 2, 3>, mp_list<X1, X2, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 3, 4>, mp_list<X1, X2, X3, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 4, 5>, mp_list<X1, X2, X3, X4>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _0, _1>, mp_list<X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _1, _2>, mp_list<X1, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _2, _3>, mp_list<X1, X2, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _3, _4>, mp_list<X1, X2, X3, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _4, _5>, mp_list<X1, X2, X3, X4>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 0, 2>, mp_list<X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 1, 3>, mp_list<X1, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 2, 4>, mp_list<X1, X2, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 3, 5>, mp_list<X1, X2, X3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _0, _2>, mp_list<X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _1, _3>, mp_list<X1, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _2, _4>, mp_list<X1, X2, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _3, _5>, mp_list<X1, X2, X3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 0, 3>, mp_list<X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 1, 4>, mp_list<X1, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 2, 5>, mp_list<X1, X2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _0, _3>, mp_list<X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _1, _4>, mp_list<X1, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _2, _5>, mp_list<X1, X2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 0, 4>, mp_list<X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 1, 5>, mp_list<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 0, 5>, mp_list<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _0, _4>, mp_list<X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _1, _5>, mp_list<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _0, _5>, mp_list<>>)); + + using L3 = mp_list<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L3, 8, 18>, mp_list<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L3, mp_size_t<8>, mp_size_t<18>>, mp_list<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L1, 0, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L1, _0, _0>, L1>)); + + using L2 = std::tuple<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 0, 0>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 1, 1>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 2, 2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 3, 3>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 4, 4>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 5, 5>, L2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _0, _0>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _1, _1>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _2, _2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _3, _3>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _4, _4>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _5, _5>, L2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 0, 1>, std::tuple<X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 1, 2>, std::tuple<X1, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 2, 3>, std::tuple<X1, X2, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 3, 4>, std::tuple<X1, X2, X3, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 4, 5>, std::tuple<X1, X2, X3, X4>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _0, _1>, std::tuple<X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _1, _2>, std::tuple<X1, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _2, _3>, std::tuple<X1, X2, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _3, _4>, std::tuple<X1, X2, X3, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _4, _5>, std::tuple<X1, X2, X3, X4>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 0, 2>, std::tuple<X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 1, 3>, std::tuple<X1, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 2, 4>, std::tuple<X1, X2, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 3, 5>, std::tuple<X1, X2, X3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _0, _2>, std::tuple<X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _1, _3>, std::tuple<X1, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _2, _4>, std::tuple<X1, X2, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _3, _5>, std::tuple<X1, X2, X3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 0, 3>, std::tuple<X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 1, 4>, std::tuple<X1, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 2, 5>, std::tuple<X1, X2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _0, _3>, std::tuple<X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _1, _4>, std::tuple<X1, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _2, _5>, std::tuple<X1, X2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 0, 4>, std::tuple<X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 1, 5>, std::tuple<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L2, 0, 5>, std::tuple<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _0, _4>, std::tuple<X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _1, _5>, std::tuple<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L2, _0, _5>, std::tuple<>>)); + + using L3 = std::tuple<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase_c<L3, 8, 18>, std::tuple<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_erase<L3, mp_size_t<8>, mp_size_t<18>>, std::tuple<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_eval_if.cpp b/src/boost/libs/mp11/test/mp_eval_if.cpp new file mode 100644 index 000000000..7e44c6750 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_eval_if.cpp @@ -0,0 +1,52 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_eval_if_c; + using boost::mp11::mp_identity; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_c<true, char[], mp_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_c<false, char[], mp_identity, void()>, mp_identity<void()>>)); + + using boost::mp11::mp_eval_if; + using boost::mp11::mp_eval_if_q; + using boost::mp11::mp_quote; + + using qt_identity = mp_quote<mp_identity>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if<std::true_type, char[], mp_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if<std::false_type, char[], mp_identity, void()>, mp_identity<void()>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_q<std::true_type, char[], qt_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_q<std::false_type, char[], qt_identity, void()>, mp_identity<void()>>)); + + using boost::mp11::mp_int; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if<mp_int<-7>, char[], mp_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if<mp_int<0>, char[], mp_identity, void()>, mp_identity<void()>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_q<mp_int<-7>, char[], qt_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_q<mp_int<0>, char[], qt_identity, void()>, mp_identity<void()>>)); + + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if<mp_size_t<14>, char[], mp_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if<mp_size_t<0>, char[], mp_identity, void()>, mp_identity<void()>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_q<mp_size_t<14>, char[], qt_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_q<mp_size_t<0>, char[], qt_identity, void()>, mp_identity<void()>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_eval_if_not.cpp b/src/boost/libs/mp11/test/mp_eval_if_not.cpp new file mode 100644 index 000000000..987e03739 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_eval_if_not.cpp @@ -0,0 +1,47 @@ + +// Copyright 2015, 2017, 2019 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_identity; + using boost::mp11::mp_eval_if_not; + using boost::mp11::mp_eval_if_not_q; + using boost::mp11::mp_quote; + + using qt_identity = mp_quote<mp_identity>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_not<std::false_type, char[], mp_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_not<std::true_type, char[], mp_identity, void()>, mp_identity<void()>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_not_q<std::false_type, char[], qt_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_not_q<std::true_type, char[], qt_identity, void()>, mp_identity<void()>>)); + + using boost::mp11::mp_int; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_not<mp_int<0>, char[], mp_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_not<mp_int<-7>, char[], mp_identity, void()>, mp_identity<void()>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_not_q<mp_int<0>, char[], qt_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_not_q<mp_int<-7>, char[], qt_identity, void()>, mp_identity<void()>>)); + + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_not<mp_size_t<0>, char[], mp_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_not<mp_size_t<14>, char[], mp_identity, void()>, mp_identity<void()>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_not_q<mp_size_t<0>, char[], qt_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_eval_if_not_q<mp_size_t<14>, char[], qt_identity, void()>, mp_identity<void()>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_eval_if_sf.cpp b/src/boost/libs/mp11/test/mp_eval_if_sf.cpp new file mode 100644 index 000000000..aed1191d8 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_eval_if_sf.cpp @@ -0,0 +1,47 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +using boost::mp11::mp_eval_if; +using boost::mp11::mp_eval_if_q; +using boost::mp11::mp_identity_t; +using boost::mp11::mp_valid; +using boost::mp11::mp_quote; + +template<class C, class... A> using eval_if = mp_eval_if<C, void, mp_identity_t, A...>; + +int main() +{ + BOOST_TEST_TRAIT_TRUE((mp_valid<eval_if, std::true_type>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<eval_if, std::true_type, void>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<eval_if, std::true_type, void, void>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<eval_if, std::true_type, void, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<eval_if, std::false_type>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<eval_if, std::false_type, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<eval_if, std::false_type, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<eval_if, std::false_type, void, void, void>)); + + using Qi = mp_quote<mp_identity_t>; + + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_eval_if_q, std::true_type, void, Qi>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_eval_if_q, std::true_type, void, Qi, void>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_eval_if_q, std::true_type, void, Qi, void, void>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_eval_if_q, std::true_type, void, Qi, void, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_eval_if_q, std::false_type, void, Qi>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_eval_if_q, std::false_type, void, Qi, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_eval_if_q, std::false_type, void, Qi, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_eval_if_q, std::false_type, void, Qi, void, void, void>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_eval_or.cpp b/src/boost/libs/mp11/test/mp_eval_or.cpp new file mode 100644 index 000000000..c56a91b46 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_eval_or.cpp @@ -0,0 +1,51 @@ + +// Copyright 2019 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <cstddef> + +template<class T> using difference_type = typename T::difference_type; + +struct X +{ +}; + +struct Y +{ + using difference_type = int; +}; + +int main() +{ + using boost::mp11::mp_eval_or; + using boost::mp11::mp_eval_or_q; + using boost::mp11::mp_identity; + using boost::mp11::mp_quote; + + BOOST_TEST_TRAIT_SAME(mp_eval_or<void, mp_identity>, void); + BOOST_TEST_TRAIT_SAME(mp_eval_or<void, mp_identity, int>, mp_identity<int>); + BOOST_TEST_TRAIT_SAME(mp_eval_or<void, mp_identity, int, int>, void); + + using Q_identity = mp_quote<mp_identity>; + + BOOST_TEST_TRAIT_SAME(mp_eval_or_q<void, Q_identity>, void); + BOOST_TEST_TRAIT_SAME(mp_eval_or_q<void, Q_identity, int>, mp_identity<int>); + BOOST_TEST_TRAIT_SAME(mp_eval_or_q<void, Q_identity, int, int>, void); + + BOOST_TEST_TRAIT_SAME(mp_eval_or<std::ptrdiff_t, difference_type, X>, std::ptrdiff_t); + BOOST_TEST_TRAIT_SAME(mp_eval_or<std::ptrdiff_t, difference_type, Y>, int); + + using Q_diff_type = mp_quote<difference_type>; + + BOOST_TEST_TRAIT_SAME(mp_eval_or_q<std::ptrdiff_t, Q_diff_type, X>, std::ptrdiff_t); + BOOST_TEST_TRAIT_SAME(mp_eval_or_q<std::ptrdiff_t, Q_diff_type, Y>, int); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_fill.cpp b/src/boost/libs/mp11/test/mp_fill.cpp new file mode 100644 index 000000000..1b5fc2ef5 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_fill.cpp @@ -0,0 +1,40 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_fill; + + using L1 = mp_list<int, void(), float[]>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fill<L1, X1>, mp_list<X1, X1, X1>>)); + + // + + using L2 = std::tuple<int, char, float>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fill<L2, X1>, std::tuple<X1, X1, X1>>)); + + // + + using L3 = std::pair<char, double>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fill<L3, X1>, std::pair<X1, X1>>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_filter.cpp b/src/boost/libs/mp11/test/mp_filter.cpp new file mode 100644 index 000000000..6a2ea13f0 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_filter.cpp @@ -0,0 +1,78 @@ + +// Copyright 2019 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> + +using boost::mp11::mp_int; + +template<class N> using mod_2 = mp_int<N::value % 2>; +template<class N> using mod_3 = mp_int<N::value % 3>; +template<class N> using mod_6 = mp_int<N::value % 6>; + +using boost::mp11::mp_not; +using boost::mp11::mp_plus; + +template<class T> using P1 = mp_not<mod_6<T>>; +template<class T1, class... T> using P2 = mp_not<mp_plus<T...>>; + +using boost::mp11::mp_bool; + +template<std::size_t N> struct second_is +{ + template<class T1, class T2> using fn = mp_bool< T2::value == N >; +}; + +using boost::mp11::mp_first; +using boost::mp11::mp_filter_q; +using boost::mp11::mp_iota; +using boost::mp11::mp_size; + +template<class L, std::size_t N> using at_c = mp_first< mp_filter_q< second_is<N>, L, mp_iota<mp_size<L>> > >; + +int main() +{ + using boost::mp11::mp_iota_c; + using boost::mp11::mp_filter; + using boost::mp11::mp_list; + using boost::mp11::mp_size_t; + using boost::mp11::mp_transform; + + { + int const N = 12; + using L1 = mp_iota_c<N>; + + using R1 = mp_filter<P1, L1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_list<mp_size_t<0>, mp_size_t<6>>>)); + + using L2 = mp_transform<mod_2, L1>; + using L3 = mp_transform<mod_3, L1>; + using L6 = mp_transform<mod_6, L1>; + + using R2 = mp_filter<P2, L1, L6>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, mp_list<mp_size_t<0>, mp_size_t<6>>>)); + + using R3 = mp_filter<P2, L1, L2, L3>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R3, mp_list<mp_size_t<0>, mp_size_t<6>>>)); + } + + { + int const N = 64; + int const M = 17; + + using L1 = mp_iota_c<N>; + using R1 = at_c<L1, M>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_size_t<M>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_find.cpp b/src/boost/libs/mp11/test/mp_find.cpp new file mode 100644 index 000000000..21aeb26b6 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_find.cpp @@ -0,0 +1,63 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_find; + using boost::mp11::mp_size_t; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find<L1, void>, mp_size_t<0>>)); + + using L2 = mp_list<X1, X2, X2, X3, X3, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find<L2, void>, mp_size_t<6>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find<L2, X1>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find<L2, X2>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find<L2, X3>, mp_size_t<3>>)); + } + + { + using L3 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find<L3, void>, mp_size_t<0>>)); + + using L4 = std::tuple<X1, X2, X2, X3, X3, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find<L4, void>, mp_size_t<6>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find<L4, X1>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find<L4, X2>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find<L4, X3>, mp_size_t<3>>)); + } + + { + using L5 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find<L5, void>, mp_size_t<2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find<L5, X1>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find<L5, X2>, mp_size_t<1>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_find_if.cpp b/src/boost/libs/mp11/test/mp_find_if.cpp new file mode 100644 index 000000000..6310390eb --- /dev/null +++ b/src/boost/libs/mp11/test/mp_find_if.cpp @@ -0,0 +1,59 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_find_if; + using boost::mp11::mp_size_t; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if<L1, std::is_const>, mp_size_t<0>>)); + + using L2 = mp_list<X1, X1 const, X1 const, X1*, X1*, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if<L2, std::is_volatile>, mp_size_t<6>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if<L2, std::is_const>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if<L2, std::is_pointer>, mp_size_t<3>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if<L1, std::is_const>, mp_size_t<0>>)); + + using L2 = std::tuple<X1, X1 const, X1 const, X1*, X1*, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if<L2, std::is_volatile>, mp_size_t<6>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if<L2, std::is_const>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if<L2, std::is_pointer>, mp_size_t<3>>)); + } + + { + using L2 = std::pair<X1 const, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if<L2, std::is_volatile>, mp_size_t<2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if<L2, std::is_const>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if<L2, std::is_pointer>, mp_size_t<1>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_find_if_q.cpp b/src/boost/libs/mp11/test/mp_find_if_q.cpp new file mode 100644 index 000000000..73aaf4ae3 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_find_if_q.cpp @@ -0,0 +1,61 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_find_if_q; + using boost::mp11::mp_size_t; + using boost::mp11::mp_quote; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if_q<L1, mp_quote<std::is_const>>, mp_size_t<0>>)); + + using L2 = mp_list<X1, X1 const, X1 const, X1*, X1*, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if_q<L2, mp_quote<std::is_volatile>>, mp_size_t<6>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if_q<L2, mp_quote<std::is_const>>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if_q<L2, mp_quote<std::is_pointer>>, mp_size_t<3>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if_q<L1, mp_quote<std::is_const>>, mp_size_t<0>>)); + + using L2 = std::tuple<X1, X1 const, X1 const, X1*, X1*, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if_q<L2, mp_quote<std::is_volatile>>, mp_size_t<6>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if_q<L2, mp_quote<std::is_const>>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if_q<L2, mp_quote<std::is_pointer>>, mp_size_t<3>>)); + } + + { + using L2 = std::pair<X1 const, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if_q<L2, mp_quote<std::is_volatile>>, mp_size_t<2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if_q<L2, mp_quote<std::is_const>>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_find_if_q<L2, mp_quote<std::is_pointer>>, mp_size_t<1>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_flatten.cpp b/src/boost/libs/mp11/test/mp_flatten.cpp new file mode 100644 index 000000000..403b870a1 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_flatten.cpp @@ -0,0 +1,101 @@ + +// Copyright 2019 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_flatten; + using boost::mp11::mp_transform; + + { + using L1 = mp_list<>; + using L2 = mp_list<void>; + using L3 = mp_list<void, void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L1>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L3>, L3>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L1, L1>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L2, L2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L3, L3>, L3>)); + + using L4 = mp_transform<mp_list, L3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L4>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L4, mp_list<>>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L4, std::tuple<>>, L4>)); + + using L5 = mp_transform<std::tuple, L3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L5>, L5>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L5, mp_list<>>, L5>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L5, std::tuple<>>, L3>)); + } + + { + using L1 = std::tuple<>; + using L2 = std::tuple<void>; + using L3 = std::tuple<void, void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L1>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L3>, L3>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L1, L1>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L2, L2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L3, L3>, L3>)); + + using L4 = mp_transform<mp_list, L3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L4>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L4, mp_list<>>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L4, std::tuple<>>, L4>)); + + using L5 = mp_transform<std::tuple, L3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L5>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L5, mp_list<>>, L5>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_flatten<L5, std::tuple<>>, L3>)); + } + + { + using L1 = mp_list<std::tuple<>, int, mp_list<>, void, mp_list<char, double>, std::pair<int, void>>; + + using R1 = mp_flatten<L1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_list<std::tuple<>, int, void, char, double, std::pair<int, void>>>)); + + using R2 = mp_flatten<L1, std::pair<void, void>>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, mp_list<std::tuple<>, int, mp_list<>, void, mp_list<char, double>, int, void>>)); + + using R3 = mp_flatten<L1, std::tuple<>>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R3, mp_list<int, mp_list<>, void, mp_list<char, double>, std::pair<int, void>>>)); + } + + { + using L1 = std::tuple<std::tuple<>, int, mp_list<>, void, mp_list<char, double>, std::pair<int, void>>; + + using R1 = mp_flatten<L1, mp_list<void, void, void, void>>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, std::tuple<std::tuple<>, int, void, char, double, std::pair<int, void>>>)); + + using R2 = mp_flatten<L1, std::pair<void, void>>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, std::tuple<std::tuple<>, int, mp_list<>, void, mp_list<char, double>, int, void>>)); + + using R3 = mp_flatten<L1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R3, std::tuple<int, mp_list<>, void, mp_list<char, double>, std::pair<int, void>>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_fold.cpp b/src/boost/libs/mp11/test/mp_fold.cpp new file mode 100644 index 000000000..8db9cc9e7 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_fold.cpp @@ -0,0 +1,79 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +template<class T1, class T2> struct F {}; + +using boost::mp11::mp_plus; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_fold; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<mp_list<>, void, F>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<mp_list<X1>, void, F>, F<void, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<mp_list<X1, X2>, void, F>, F<F<void, X1>, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<mp_list<X1, X2, X3>, void, F>, F<F<F<void, X1>, X2>, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<mp_list<X1, X2, X3, X4>, void, F>, F<F<F<F<void, X1>, X2>, X3>, X4>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<>, void, F>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<X1>, void, F>, F<void, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<X1, X2>, void, F>, F<F<void, X1>, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<X1, X2, X3>, void, F>, F<F<F<void, X1>, X2>, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<X1, X2, X3, X4>, void, F>, F<F<F<F<void, X1>, X2>, X3>, X4>>)); + } + + using boost::mp11::mp_push_back; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<X1, X2, X3, X4>, mp_list<>, mp_push_back>, mp_list<X1, X2, X3, X4>>)); + } + + using boost::mp11::mp_push_front; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold<std::tuple<X1, X2, X3, X4>, mp_list<>, mp_push_front>, mp_list<X4, X3, X2, X1>>)); + } + + using boost::mp11::mp_iota_c; + using boost::mp11::mp_reverse; + using boost::mp11::mp_size_t; + + { + int const N = 37; + + using L = mp_iota_c<N>; + + using R1 = mp_fold<L, mp_list<>, mp_push_back>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, L>)); + + using R2 = mp_fold<L, mp_list<>, mp_push_front>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, mp_reverse<L>>)); + + using R3 = mp_fold<L, mp_size_t<0>, mp_plus>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R3, mp_size_t<N*(N-1)/2>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_fold_q.cpp b/src/boost/libs/mp11/test/mp_fold_q.cpp new file mode 100644 index 000000000..475cf0828 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_fold_q.cpp @@ -0,0 +1,62 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +template<class T1, class T2> struct F {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_fold_q; + using boost::mp11::mp_quote; + + using Q = mp_quote<F>; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold_q<mp_list<>, void, Q>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold_q<mp_list<X1>, void, Q>, F<void, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold_q<mp_list<X1, X2>, void, Q>, F<F<void, X1>, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold_q<mp_list<X1, X2, X3>, void, Q>, F<F<F<void, X1>, X2>, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold_q<mp_list<X1, X2, X3, X4>, void, Q>, F<F<F<F<void, X1>, X2>, X3>, X4>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold_q<std::tuple<>, void, Q>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold_q<std::tuple<X1>, void, Q>, F<void, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold_q<std::tuple<X1, X2>, void, Q>, F<F<void, X1>, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold_q<std::tuple<X1, X2, X3>, void, Q>, F<F<F<void, X1>, X2>, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold_q<std::tuple<X1, X2, X3, X4>, void, Q>, F<F<F<F<void, X1>, X2>, X3>, X4>>)); + } + + using boost::mp11::mp_push_back; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold_q<std::tuple<X1, X2, X3, X4>, mp_list<>, mp_quote<mp_push_back>>, mp_list<X1, X2, X3, X4>>)); + } + + using boost::mp11::mp_push_front; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_fold_q<std::tuple<X1, X2, X3, X4>, mp_list<>, mp_quote<mp_push_front>>, mp_list<X4, X3, X2, X1>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_for_each.cpp b/src/boost/libs/mp11/test/mp_for_each.cpp new file mode 100644 index 000000000..1842d5a0b --- /dev/null +++ b/src/boost/libs/mp11/test/mp_for_each.cpp @@ -0,0 +1,104 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/detail/config.hpp> + +#if BOOST_MP11_MSVC +# pragma warning( disable: 4503 ) // decorated name length exceeded +# pragma warning( disable: 4307 ) // '*': integral constant overflow +# pragma warning( disable: 4244 ) // conversion from size_t to uint32_t +# pragma warning( disable: 4267 ) // conversion from size_t to uint32_t +#endif + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test.hpp> +#include <tuple> +#include <cstdint> + +#if defined( BOOST_MP11_HAS_CXX14_CONSTEXPR ) +# define CONSTEXPR14 constexpr +#else +# define CONSTEXPR14 +#endif + +struct F +{ + int s; + + CONSTEXPR14 void operator()( int ) { s = s * 10 + 1; } + CONSTEXPR14 void operator()( short ) { s = s * 10 + 2; } + CONSTEXPR14 void operator()( char ) { s = s * 10 + 3; } +}; + +struct G +{ + std::uint32_t s; + CONSTEXPR14 void operator()( std::uint32_t i ) { s = s * 3 + i; } +}; + +using boost::mp11::mp_list; +using boost::mp11::mp_for_each; +using boost::mp11::mp_iota_c; + +int main() +{ + BOOST_TEST_EQ( (mp_for_each<mp_list<>>( 11 )), 11 ); + BOOST_TEST_EQ( (mp_for_each<mp_list<int>>( F{0} ).s), 1 ); + BOOST_TEST_EQ( (mp_for_each<mp_list<int, short>>( F{0} ).s), 12 ); + BOOST_TEST_EQ( (mp_for_each<mp_list<int, short, char>>( F{0} ).s), 123 ); + + BOOST_TEST_EQ( (mp_for_each<std::tuple<>>( 11 )), 11 ); + BOOST_TEST_EQ( (mp_for_each<std::tuple<int>>( F{0} ).s), 1 ); + BOOST_TEST_EQ( (mp_for_each<std::tuple<int, short>>( F{0} ).s), 12 ); + BOOST_TEST_EQ( (mp_for_each<std::tuple<int, short, char>>( F{0} ).s), 123 ); + + BOOST_TEST_EQ( (mp_for_each<std::pair<int, short>>( F{0} ).s), 12 ); + +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) +#else + + using L = mp_iota_c<1089>; + std::uint32_t const R = 598075296; + + BOOST_TEST_EQ( (mp_for_each<L>( G{0} ).s), R ); + + { + G g{0}; + mp_for_each<L>( g ); + BOOST_TEST_EQ( g.s, R ); + } + +#endif + +#if defined( BOOST_MP11_NO_CONSTEXPR ) || ( !defined(_MSC_VER) && !defined( __GLIBCXX__ ) && __cplusplus < 201400L ) +#else + + static_assert( mp_for_each<mp_list<>>( 11 ) == 11, "mp_for_each<mp_list<>>( 11 ) == 11" ); + static_assert( mp_for_each<std::tuple<>>( 12 ) == 12, "mp_for_each<std::tuple<>>( 12 ) == 12" ); + +#endif + +#if defined( BOOST_MP11_HAS_CXX14_CONSTEXPR ) + + constexpr auto r1 = mp_for_each<mp_list<int, short, char>>( F{0} ); + static_assert( r1.s == 123, "r1.s == 123" ); + + constexpr auto r2 = mp_for_each<std::tuple<int, short, char>>( F{0} ); + static_assert( r2.s == 123, "r2.s == 123" ); + + constexpr auto r3 = mp_for_each<std::pair<int, short>>( F{0} ); + static_assert( r3.s == 12, "r3.s == 12" ); + + constexpr auto r4 = mp_for_each<L>( G{0} ); + static_assert( r4.s == R, "r4.s == R" ); + +#endif + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_from_sequence.cpp b/src/boost/libs/mp11/test/mp_from_sequence.cpp new file mode 100644 index 000000000..a06d92827 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_from_sequence.cpp @@ -0,0 +1,43 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/integer_sequence.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +template<class T, T... I> struct S; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_from_sequence; + using boost::mp11::mp_int; + using boost::mp11::mp_size_t; + using boost::mp11::make_integer_sequence; + using boost::mp11::make_index_sequence; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<S<int>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<S<int, 1>>, mp_list<mp_int<1>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<S<int, 1, 3>>, mp_list<mp_int<1>, mp_int<3>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<S<int, 1, 3, 5>>, mp_list<mp_int<1>, mp_int<3>, mp_int<5>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_integer_sequence<int, 0>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_integer_sequence<int, 1>>, mp_list<mp_int<0>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_integer_sequence<int, 2>>, mp_list<mp_int<0>, mp_int<1>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_integer_sequence<int, 3>>, mp_list<mp_int<0>, mp_int<1>, mp_int<2>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_index_sequence<0>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_index_sequence<1>>, mp_list<mp_size_t<0>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_index_sequence<2>>, mp_list<mp_size_t<0>, mp_size_t<1>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_index_sequence<3>>, mp_list<mp_size_t<0>, mp_size_t<1>, mp_size_t<2>>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_front.cpp b/src/boost/libs/mp11/test/mp_front.cpp new file mode 100644 index 000000000..3edb856c3 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_front.cpp @@ -0,0 +1,43 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/list.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_front; + using boost::mp11::mp_first; + + using L1 = mp_list<void>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_front<L1>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_first<L1>, void>)); + + using L2 = mp_list<int[], void, float>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_front<L2>, int[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_first<L2>, int[]>)); + + using L3 = std::tuple<int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_front<L3>, int>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_first<L3>, int>)); + + using L4 = std::pair<char, double>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_front<L4>, char>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_first<L4>, char>)); + + using L5 = std::add_const<void()>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_front<L5>, void()>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_first<L5>, void()>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_identity.cpp b/src/boost/libs/mp11/test/mp_identity.cpp new file mode 100644 index 000000000..3198718b0 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_identity.cpp @@ -0,0 +1,33 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +struct X {}; + +int main() +{ + using boost::mp11::mp_identity; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_identity<void const volatile>::type, void const volatile>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_identity<void()>::type, void()>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_identity<int const[]>::type, int const[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_identity<X>::type, X>)); + + using boost::mp11::mp_identity_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_identity_t<void const volatile>, void const volatile>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_identity_t<void()>, void()>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_identity_t<int const[]>, int const[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_identity_t<X>, X>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_if.cpp b/src/boost/libs/mp11/test/mp_if.cpp new file mode 100644 index 000000000..1a5bca9bb --- /dev/null +++ b/src/boost/libs/mp11/test/mp_if.cpp @@ -0,0 +1,38 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_if_c; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_if_c<true, char[], void()>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_if_c<false, char[], void()>, void()>)); + + using boost::mp11::mp_if; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_if<std::true_type, char[], void()>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_if<std::false_type, char[], void()>, void()>)); + + using boost::mp11::mp_int; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_if<mp_int<-7>, char[], void()>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_if<mp_int<0>, char[], void()>, void()>)); + + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_if<mp_size_t<14>, char[], void()>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_if<mp_size_t<0>, char[], void()>, void()>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_if_sf.cpp b/src/boost/libs/mp11/test/mp_if_sf.cpp new file mode 100644 index 000000000..15ef3091e --- /dev/null +++ b/src/boost/libs/mp11/test/mp_if_sf.cpp @@ -0,0 +1,24 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_if; + using boost::mp11::mp_valid; + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_if, std::false_type, void>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_if, std::false_type, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_if, std::false_type, void, void, void>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_inherit.cpp b/src/boost/libs/mp11/test/mp_inherit.cpp new file mode 100644 index 000000000..dfd5fc462 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_inherit.cpp @@ -0,0 +1,27 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/utility.hpp> +#include <type_traits> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +int main() +{ + using boost::mp11::mp_inherit; + + BOOST_TEST_TRAIT_TRUE((std::is_base_of<X1, mp_inherit<X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_base_of<X2, mp_inherit<X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_base_of<X3, mp_inherit<X1, X2, X3>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_insert.cpp b/src/boost/libs/mp11/test/mp_insert.cpp new file mode 100644 index 000000000..da5bc69b3 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_insert.cpp @@ -0,0 +1,137 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; + +struct Y1 {}; +struct Y2 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_insert; + using boost::mp11::mp_insert_c; + using boost::mp11::mp_size_t; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L1, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L1, mp_size_t<0>>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L1, 0, Y1>, mp_list<Y1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L1, mp_size_t<0>, Y1>, mp_list<Y1>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L1, 0, Y1, Y2>, mp_list<Y1, Y2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L1, mp_size_t<0>, Y1, Y2>, mp_list<Y1, Y2>>)); + + using L2 = mp_list<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 0>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 1>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 3>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 4>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 5>, L2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 0, Y1, Y2>, mp_list<Y1, Y2, X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 1, Y1, Y2>, mp_list<X1, Y1, Y2, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 2, Y1, Y2>, mp_list<X1, X2, Y1, Y2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 3, Y1, Y2>, mp_list<X1, X2, X3, Y1, Y2, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 4, Y1, Y2>, mp_list<X1, X2, X3, X4, Y1, Y2, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 5, Y1, Y2>, mp_list<X1, X2, X3, X4, X5, Y1, Y2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<0>>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<1>>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<2>>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<3>>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<4>>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<5>>, L2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<0>, Y1, Y2>, mp_list<Y1, Y2, X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<1>, Y1, Y2>, mp_list<X1, Y1, Y2, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<2>, Y1, Y2>, mp_list<X1, X2, Y1, Y2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<3>, Y1, Y2>, mp_list<X1, X2, X3, Y1, Y2, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<4>, Y1, Y2>, mp_list<X1, X2, X3, X4, Y1, Y2, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<5>, Y1, Y2>, mp_list<X1, X2, X3, X4, X5, Y1, Y2>>)); + + using L3 = mp_list<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L3, 8>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L3, mp_size_t<9>>, L3>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L3, 8, Y1, Y2>, mp_list<X1, X2, X3, X4, X5, X1, X2, X3, Y1, Y2, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L3, mp_size_t<9>, Y1, Y2>, mp_list<X1, X2, X3, X4, X5, X1, X2, X3, X4, Y1, Y2, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L1, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L1, mp_size_t<0>>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L1, 0, Y1>, std::tuple<Y1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L1, mp_size_t<0>, Y1>, std::tuple<Y1>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L1, 0, Y1, Y2>, std::tuple<Y1, Y2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L1, mp_size_t<0>, Y1, Y2>, std::tuple<Y1, Y2>>)); + + using L2 = std::tuple<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 0>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 1>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 3>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 4>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 5>, L2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 0, Y1, Y2>, std::tuple<Y1, Y2, X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 1, Y1, Y2>, std::tuple<X1, Y1, Y2, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 2, Y1, Y2>, std::tuple<X1, X2, Y1, Y2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 3, Y1, Y2>, std::tuple<X1, X2, X3, Y1, Y2, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 4, Y1, Y2>, std::tuple<X1, X2, X3, X4, Y1, Y2, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L2, 5, Y1, Y2>, std::tuple<X1, X2, X3, X4, X5, Y1, Y2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<0>>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<1>>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<2>>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<3>>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<4>>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<5>>, L2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<0>, Y1, Y2>, std::tuple<Y1, Y2, X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<1>, Y1, Y2>, std::tuple<X1, Y1, Y2, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<2>, Y1, Y2>, std::tuple<X1, X2, Y1, Y2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<3>, Y1, Y2>, std::tuple<X1, X2, X3, Y1, Y2, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<4>, Y1, Y2>, std::tuple<X1, X2, X3, X4, Y1, Y2, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L2, mp_size_t<5>, Y1, Y2>, std::tuple<X1, X2, X3, X4, X5, Y1, Y2>>)); + + using L3 = std::tuple<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L3, 8>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L3, mp_size_t<9>>, L3>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert_c<L3, 8, Y1, Y2>, std::tuple<X1, X2, X3, X4, X5, X1, X2, X3, Y1, Y2, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_insert<L3, mp_size_t<9>, Y1, Y2>, std::tuple<X1, X2, X3, X4, X5, X1, X2, X3, X4, Y1, Y2, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_intersperse.cpp b/src/boost/libs/mp11/test/mp_intersperse.cpp new file mode 100644 index 000000000..5a5ef1618 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_intersperse.cpp @@ -0,0 +1,38 @@ +// Copyright 2021 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_intersperse; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_intersperse<mp_list<>, void>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_intersperse<mp_list<X1>, void>, mp_list<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_intersperse<mp_list<X1, X2>, void>, mp_list<X1, void, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_intersperse<mp_list<X1, X2, X3>, void>, mp_list<X1, void, X2, void, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_intersperse<mp_list<X1, X2, X3, X4>, void>, mp_list<X1, void, X2, void, X3, void, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_intersperse<mp_list<X1, X2, X3, X4, X5>, void>, mp_list<X1, void, X2, void, X3, void, X4, void, X5>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_intersperse<std::tuple<>, void>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_intersperse<std::tuple<X1>, void>, std::tuple<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_intersperse<std::tuple<X1, X2>, void>, std::tuple<X1, void, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_intersperse<std::tuple<X1, X2, X3>, void>, std::tuple<X1, void, X2, void, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_intersperse<std::tuple<X1, X2, X3, X4>, void>, std::tuple<X1, void, X2, void, X3, void, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_intersperse<std::tuple<X1, X2, X3, X4, X5>, void>, std::tuple<X1, void, X2, void, X3, void, X4, void, X5>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_invoke_q.cpp b/src/boost/libs/mp11/test/mp_invoke_q.cpp new file mode 100644 index 000000000..777f44bbf --- /dev/null +++ b/src/boost/libs/mp11/test/mp_invoke_q.cpp @@ -0,0 +1,63 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +using boost::mp11::mp_invoke_q; +using boost::mp11::mp_size_t; + +struct Q1 +{ + template<class...> using fn = void; +}; + +struct Q2 +{ + template<class...> class fn; +}; + +struct Q3 +{ + template<class... T> using fn = mp_size_t<sizeof...(T)>; +}; + +struct Q4 +{ + template<class T1, class... T> using fn = T1; +}; + +struct Q5 +{ + template<class T1, class T2> using fn = T2; +}; + +int main() +{ + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q1>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q1, int>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q1, int[], char[]>, void>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q2>, Q2::fn<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q2, int>, Q2::fn<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q2, int[], char[]>, Q2::fn<int[], char[]>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q3>, mp_size_t<0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q3, int>, mp_size_t<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q3, int[], char[]>, mp_size_t<2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q4, int>, int>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q4, int[], char[]>, int[]>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q5, int, float>, float>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_invoke_q_sf.cpp b/src/boost/libs/mp11/test/mp_invoke_q_sf.cpp new file mode 100644 index 000000000..26e2912b3 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_invoke_q_sf.cpp @@ -0,0 +1,44 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/mp11/detail/config.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +using boost::mp11::mp_invoke_q; +using boost::mp11::mp_quote; +using boost::mp11::mp_quote_trait; +using boost::mp11::mp_valid; +using boost::mp11::mp_identity; +using boost::mp11::mp_identity_t; + +int main() +{ + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke_q>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke_q, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke_q, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke_q, void, void, void>)); + + using Qi = mp_quote<mp_identity_t>; + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke_q, Qi>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_invoke_q, Qi, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke_q, Qi, void, void>)); + + using Qt = mp_quote_trait<mp_identity>; + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke_q, Qt>)); +#endif + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_invoke_q, Qt, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke_q, Qt, void, void>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_iota.cpp b/src/boost/libs/mp11/test/mp_iota.cpp new file mode 100644 index 000000000..044251d63 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_iota.cpp @@ -0,0 +1,42 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_iota; + using boost::mp11::mp_iota_c; + using boost::mp11::mp_int; + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota_c<0>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota_c<1>, mp_list<mp_size_t<0>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota_c<2>, mp_list<mp_size_t<0>, mp_size_t<1>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota_c<3>, mp_list<mp_size_t<0>, mp_size_t<1>, mp_size_t<2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota_c<4>, mp_list<mp_size_t<0>, mp_size_t<1>, mp_size_t<2>, mp_size_t<3>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_size_t<0>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_size_t<1>>, mp_list<mp_size_t<0>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_size_t<2>>, mp_list<mp_size_t<0>, mp_size_t<1>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_size_t<3>>, mp_list<mp_size_t<0>, mp_size_t<1>, mp_size_t<2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_size_t<4>>, mp_list<mp_size_t<0>, mp_size_t<1>, mp_size_t<2>, mp_size_t<3>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_int<0>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_int<1>>, mp_list<mp_int<0>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_int<2>>, mp_list<mp_int<0>, mp_int<1>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_int<3>>, mp_list<mp_int<0>, mp_int<1>, mp_int<2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iota<mp_int<4>>, mp_list<mp_int<0>, mp_int<1>, mp_int<2>, mp_int<3>>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_is_list.cpp b/src/boost/libs/mp11/test/mp_is_list.cpp new file mode 100644 index 000000000..62e602ea6 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_is_list.cpp @@ -0,0 +1,50 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_is_list; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<void>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<int>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<char[]>, mp_false>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<mp_list<>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<mp_list<void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<mp_list<void, void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<mp_list<void, void, void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<mp_list<void, void, void, void>>, mp_true>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<std::tuple<>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<std::tuple<void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<std::tuple<void, void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<std::tuple<void, void, void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<std::tuple<void, void, void, void>>, mp_true>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_list<std::pair<void, void>>, mp_true>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_is_map.cpp b/src/boost/libs/mp11/test/mp_is_map.cpp new file mode 100644 index 000000000..980d14082 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_is_map.cpp @@ -0,0 +1,59 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/map.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_is_map; + using boost::mp11::mp_list; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<void>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<mp_list<>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<std::tuple<>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<mp_list<void>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<std::tuple<void>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<mp_list<mp_list<>>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<std::tuple<std::tuple<>>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<mp_list<mp_list<int>>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<std::tuple<std::tuple<int>>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<mp_list<std::pair<int, int const>>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<std::tuple<std::pair<int, int const>>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<mp_list<std::pair<int, int const>, std::pair<long, long const>>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<std::tuple<std::pair<int, int const>, std::pair<long, long const>>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<std::pair<std::pair<int, int const>, std::pair<long, long const>>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<mp_list<std::pair<int, int const>, std::pair<int, long const>>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<std::tuple<std::pair<int, int const>, std::pair<int, long const>>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<std::pair<std::pair<int, int const>, std::pair<int, long const>>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<std::tuple<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<std::tuple<std::tuple<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<mp_list<mp_list<int>, mp_list<long, long>, mp_list<int, long long, long long>>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<std::tuple<mp_list<int>, mp_list<long, long>, mp_list<int, long long, long long>>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_map<std::tuple<std::tuple<int>, std::pair<long, long>, std::tuple<int, long long, long long>>>, mp_false>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_is_set.cpp b/src/boost/libs/mp11/test/mp_is_set.cpp new file mode 100644 index 000000000..8657dc45d --- /dev/null +++ b/src/boost/libs/mp11/test/mp_is_set.cpp @@ -0,0 +1,73 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/set.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_is_set; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<void>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<int>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<char[]>, mp_false>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<mp_list<>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<mp_list<void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<mp_list<void, void>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<mp_list<void, void, void>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<mp_list<void, void, void, void>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<mp_list<void, int>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<mp_list<void, int, void>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<mp_list<void, int, int>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<mp_list<void, int, char[]>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<mp_list<void, int, char[], void>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<mp_list<void, int, char[], int>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<mp_list<void, int, char[], char[]>>, mp_false>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::tuple<>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::tuple<void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::tuple<void, void>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::tuple<void, void, void>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::tuple<void, void, void, void>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::tuple<void, int>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::tuple<void, int, void>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::tuple<void, int, int>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::tuple<void, int, char[]>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::tuple<void, int, char[], void>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::tuple<void, int, char[], int>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::tuple<void, int, char[], char[]>>, mp_false>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::pair<void, void>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::pair<void, int>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::pair<int, void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_is_set<std::pair<int, int>>, mp_false>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_iterate.cpp b/src/boost/libs/mp11/test/mp_iterate.cpp new file mode 100644 index 000000000..a0d1cb269 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_iterate.cpp @@ -0,0 +1,68 @@ +// Copyright 2020 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <cstddef> + +struct X1 {}; +struct X2 { using first_type = double; using next_type = X1; }; +struct X3 { using first_type = float; using next_type = X2; }; +struct X4 { using first_type = int; using next_type = X3; }; + +template<class T> using first_type = typename T::first_type; +template<class T> using next_type = typename T::next_type; + +template<class T1, class T2> struct cons {}; + +template<class T1, class T2> struct cons2 +{ + using first_type = T1; + using next_type = T2; +}; + +using boost::mp11::mp_reverse_fold; +using boost::mp11::mp_iterate; +using boost::mp11::mp_first; +using boost::mp11::mp_second; +using boost::mp11::mp_rest; + +template<class L1> void test() +{ + using R1 = mp_iterate<L1, mp_first, mp_rest>; + BOOST_TEST_TRAIT_TRUE((std::is_same<L1, R1>)); + + using V2 = mp_reverse_fold<L1, void, cons>; + using R2 = mp_iterate<V2, mp_first, mp_second>; + BOOST_TEST_TRAIT_TRUE((std::is_same<L1, R2>)); + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1900 ) + + using V3 = mp_reverse_fold<L1, void, cons2>; + using R3 = mp_iterate<V3, first_type, next_type>; + BOOST_TEST_TRAIT_TRUE((std::is_same<L1, R3>)); + +#endif +} + +int main() +{ + using boost::mp11::mp_list; + + test< mp_list<> >(); + test< mp_list<int> >(); + test< mp_list<int, void> >(); + test< mp_list<int, void, float> >(); + test< mp_list<int, void, float, double> >(); + + using boost::mp11::mp_identity_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iterate<X4, mp_identity_t, next_type>, mp_list<X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_iterate<X4, first_type, next_type>, mp_list<int, float, double>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_join.cpp b/src/boost/libs/mp11/test/mp_join.cpp new file mode 100644 index 000000000..1f4b986c1 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_join.cpp @@ -0,0 +1,51 @@ +// Copyright 2021 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +struct S {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_join; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<mp_list<mp_list<>>, S>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<mp_list<mp_list<X1>>, S>, mp_list<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<mp_list<mp_list<X1, X2>>, S>, mp_list<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<mp_list<mp_list<X1, X2, X3>>, S>, mp_list<X1, X2, X3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<mp_list<mp_list<>, mp_list<>>, S>, mp_list<S>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<mp_list<mp_list<>, mp_list<>, mp_list<>>, S>, mp_list<S, S>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<mp_list<mp_list<>, mp_list<>, mp_list<>, mp_list<>>, S>, mp_list<S, S, S>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<mp_list<mp_list<X1>, mp_list<X2>>, S>, mp_list<X1, S, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<mp_list<mp_list<X1, X2>, mp_list<X3, X4>>, S>, mp_list<X1, X2, S, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<mp_list<mp_list<>, mp_list<X1, X2>, mp_list<>, mp_list<X3, X4>, mp_list<>>, S>, mp_list<S, X1, X2, S, S, X3, X4, S>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<std::tuple<std::tuple<>>, S>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<std::tuple<std::tuple<X1>>, S>, std::tuple<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<std::tuple<std::tuple<X1, X2>>, S>, std::tuple<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<std::tuple<std::tuple<X1, X2, X3>>, S>, std::tuple<X1, X2, X3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<std::tuple<std::tuple<>, std::tuple<>>, S>, std::tuple<S>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<std::tuple<std::tuple<>, std::tuple<>, std::tuple<>>, S>, std::tuple<S, S>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<std::tuple<std::tuple<>, std::tuple<>, std::tuple<>, std::tuple<>>, S>, std::tuple<S, S, S>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<std::tuple<std::tuple<X1>, std::tuple<X2>>, S>, std::tuple<X1, S, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<std::tuple<std::tuple<X1, X2>, std::tuple<X3, X4>>, S>, std::tuple<X1, X2, S, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_join<std::tuple<std::tuple<>, std::tuple<X1, X2>, std::tuple<>, std::tuple<X3, X4>, std::tuple<>>, S>, std::tuple<S, X1, X2, S, S, X3, X4, S>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_less.cpp b/src/boost/libs/mp11/test/mp_less.cpp new file mode 100644 index 000000000..0e72faf8b --- /dev/null +++ b/src/boost/libs/mp11/test/mp_less.cpp @@ -0,0 +1,68 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/detail/config.hpp> + +#if BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 40800 ) +# pragma GCC diagnostic ignored "-Wsign-compare" +#endif + +#include <boost/mp11/function.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_less; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + using boost::mp11::mp_int; + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<0>, mp_int<-1>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<0>, mp_int<0>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<0>, mp_int<1>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<0>, mp_int<2>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<-1>, mp_int<-2>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<-1>, mp_int<-1>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<-1>, mp_int<0>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<-1>, mp_int<1>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<1>, mp_int<-1>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<1>, mp_int<0>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<1>, mp_int<1>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<1>, mp_int<2>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<0>, mp_size_t<0>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<0>, mp_size_t<1>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<0>, mp_size_t<2>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<0>, mp_size_t<3>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<1>, mp_size_t<0>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<1>, mp_size_t<1>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<1>, mp_size_t<2>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<1>, mp_size_t<3>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<2>, mp_size_t<0>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<2>, mp_size_t<1>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<2>, mp_size_t<2>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<2>, mp_size_t<3>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<0>, mp_int<-1>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<0>, mp_int<0>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_size_t<0>, mp_int<1>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<-1>, mp_size_t<1>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<0>, mp_size_t<1>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<1>, mp_size_t<1>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_less<mp_int<2>, mp_size_t<1>>, mp_false>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_list_c.cpp b/src/boost/libs/mp11/test/mp_list_c.cpp new file mode 100644 index 000000000..d6130ebfc --- /dev/null +++ b/src/boost/libs/mp11/test/mp_list_c.cpp @@ -0,0 +1,27 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_list_c; + using boost::mp11::mp_list; + using boost::mp11::mp_int; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_list_c<int>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_list_c<int, 1>, mp_list<mp_int<1>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_list_c<int, 1, 3>, mp_list<mp_int<1>, mp_int<3>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_list_c<int, 1, 3, 5>, mp_list<mp_int<1>, mp_int<3>, mp_int<5>>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_map_contains.cpp b/src/boost/libs/mp11/test/mp_map_contains.cpp new file mode 100644 index 000000000..777b5c8aa --- /dev/null +++ b/src/boost/libs/mp11/test/mp_map_contains.cpp @@ -0,0 +1,51 @@ + +// Copyright 2016 Peter Dimov. +// +// 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/mp11/map.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_map_contains; + using boost::mp11::mp_list; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<>, char>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<>, int>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<std::pair<int, int const>, std::pair<long, long const>>, char>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<std::pair<int, int const>, std::pair<long, long const>>, int>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<std::pair<int, int const>, std::pair<long, long const>>, long>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, char>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, int>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, long>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::pair<std::pair<int, int const>, std::pair<long, long const>>, char>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::pair<std::pair<int, int const>, std::pair<long, long const>>, int>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::pair<std::pair<int, int const>, std::pair<long, long const>>, long>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, char>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, int>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, long>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, long long>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, char>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, int>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, long>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_contains<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, long long>, mp_true>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_map_erase.cpp b/src/boost/libs/mp11/test/mp_map_erase.cpp new file mode 100644 index 000000000..db0c691f5 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_map_erase.cpp @@ -0,0 +1,60 @@ + +// Copyright 2016, 2017 Peter Dimov. +// +// 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/mp11/map.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_map_erase; + using boost::mp11::mp_list; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<mp_list<>, void>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<std::tuple<>, int>, std::tuple<>>)); + + { + using M = mp_list<std::pair<int, int const>, std::pair<long, long const>>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, char>, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, int>, mp_list<std::pair<long, long const>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, long>, mp_list<std::pair<int, int const>>>)); + } + + { + using M = std::tuple<std::pair<int, int const>, std::pair<long, long const>>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, char>, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, int>, std::tuple<std::pair<long, long const>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, long>, std::tuple<std::pair<int, int const>>>)); + } + + { + using M = mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, char>, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, int>, mp_list<mp_list<long, long>, mp_list<long long, long long, long long>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, long>, mp_list<mp_list<int>, mp_list<long long, long long, long long>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, long long>, mp_list<mp_list<int>, mp_list<long, long>>>)); + } + + { + using M = std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, char>, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, int>, std::tuple<std::pair<long, long>, std::tuple<long long, long long, long long>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, long>, std::tuple<mp_list<int>, std::tuple<long long, long long, long long>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_erase<M, long long>, std::tuple<mp_list<int>, std::pair<long, long>>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_map_find.cpp b/src/boost/libs/mp11/test/mp_map_find.cpp new file mode 100644 index 000000000..2bd614dac --- /dev/null +++ b/src/boost/libs/mp11/test/mp_map_find.cpp @@ -0,0 +1,48 @@ + +// Copyright 2016 Peter Dimov. +// +// 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/mp11/map.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_map_find; + using boost::mp11::mp_list; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<>, char>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<>, int>, void>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<std::pair<int, int const>, std::pair<long, long const>>, char>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<std::pair<int, int const>, std::pair<long, long const>>, int>, std::pair<int, int const>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<std::pair<int, int const>, std::pair<long, long const>>, long>, std::pair<long, long const>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, char>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, int>, std::pair<int, int const>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, long>, std::pair<long, long const>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::pair<std::pair<int, int const>, std::pair<long, long const>>, char>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::pair<std::pair<int, int const>, std::pair<long, long const>>, int>, std::pair<int, int const>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::pair<std::pair<int, int const>, std::pair<long, long const>>, long>, std::pair<long, long const>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, char>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, int>, mp_list<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, long>, mp_list<long, long>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, long long>, mp_list<long long, long long, long long>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, char>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, int>, mp_list<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, long>, std::pair<long, long>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, long long>, std::tuple<long long, long long, long long>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_map_find_2.cpp b/src/boost/libs/mp11/test/mp_map_find_2.cpp new file mode 100644 index 000000000..a46af5d5c --- /dev/null +++ b/src/boost/libs/mp11/test/mp_map_find_2.cpp @@ -0,0 +1,33 @@ + +// Copyright 2016, 2020 Peter Dimov. +// +// 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/mp11/map.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <tuple> + +struct X {}; +struct Y {}; + +int main() +{ + using boost::mp11::mp_map_find; + + using L1 = std::tuple<std::tuple<int, int>, std::tuple<long, long>, std::tuple<bool, X>, std::tuple<X, bool>>; + + BOOST_TEST_TRAIT_SAME( mp_map_find<L1, int>, std::tuple<int, int> ); + BOOST_TEST_TRAIT_SAME( mp_map_find<L1, bool>, std::tuple<bool, X> ); + BOOST_TEST_TRAIT_SAME( mp_map_find<L1, X>, std::tuple<X, bool> ); + + using L2 = std::tuple<std::tuple<X, Y>, std::tuple<Y, X>>; + + BOOST_TEST_TRAIT_SAME( mp_map_find<L2, X>, std::tuple<X, Y> ); + BOOST_TEST_TRAIT_SAME( mp_map_find<L2, Y>, std::tuple<Y, X> ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_map_find_3.cpp b/src/boost/libs/mp11/test/mp_map_find_3.cpp new file mode 100644 index 000000000..cf25c733a --- /dev/null +++ b/src/boost/libs/mp11/test/mp_map_find_3.cpp @@ -0,0 +1,34 @@ + +// Copyright 2016, 2020 Peter Dimov. +// +// 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 + +// Same as mp_map_find_2.cpp, but with includes reversed + +#include <tuple> +#include <boost/mp11/map.hpp> +#include <boost/core/lightweight_test_trait.hpp> + +struct X {}; +struct Y {}; + +int main() +{ + using boost::mp11::mp_map_find; + + using L1 = std::tuple<std::tuple<int, int>, std::tuple<long, long>, std::tuple<bool, X>, std::tuple<X, bool>>; + + BOOST_TEST_TRAIT_SAME( mp_map_find<L1, int>, std::tuple<int, int> ); + BOOST_TEST_TRAIT_SAME( mp_map_find<L1, bool>, std::tuple<bool, X> ); + BOOST_TEST_TRAIT_SAME( mp_map_find<L1, X>, std::tuple<X, bool> ); + + using L2 = std::tuple<std::tuple<X, Y>, std::tuple<Y, X>>; + + BOOST_TEST_TRAIT_SAME( mp_map_find<L2, X>, std::tuple<X, Y> ); + BOOST_TEST_TRAIT_SAME( mp_map_find<L2, Y>, std::tuple<Y, X> ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_map_insert.cpp b/src/boost/libs/mp11/test/mp_map_insert.cpp new file mode 100644 index 000000000..11920a7a3 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_map_insert.cpp @@ -0,0 +1,66 @@ + +// Copyright 2016 Peter Dimov. +// +// 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/mp11/map.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_map_insert; + using boost::mp11::mp_list; + using boost::mp11::mp_push_back; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<mp_list<>, mp_list<void>>, mp_list<mp_list<void>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<std::tuple<>, std::tuple<int>>, std::tuple<std::tuple<int>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<std::tuple<>, std::pair<int, float>>, std::tuple<std::pair<int, float>>>)); + + { + using M = mp_list<std::pair<int, int const>, std::pair<long, long const>>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<int>>, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<long, float>>, M>)); + } + + { + using M = std::tuple<std::pair<int, int const>, std::pair<long, long const>>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<int>>, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<long, float>>, M>)); + } + + { + using M = mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::tuple<int>>, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<long, float>>, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<long long, float, double>>, M>)); + } + + { + using M = std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::tuple<int>>, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, std::pair<long, float>>, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_insert<M, mp_list<long long, float, double>>, M>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_map_keys.cpp b/src/boost/libs/mp11/test/mp_map_keys.cpp new file mode 100644 index 000000000..aa9eb6475 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_map_keys.cpp @@ -0,0 +1,37 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/map.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_map_keys; + using boost::mp11::mp_list; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_keys<mp_list<>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_keys<std::tuple<>>, std::tuple<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_keys<mp_list<std::pair<int, int const>>>, mp_list<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_keys<std::tuple<std::pair<int, int const>>>, std::tuple<int>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_keys<mp_list<std::pair<int, int const>, std::pair<long, long const>>>, mp_list<int, long>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_keys<std::tuple<std::pair<int, int const>, std::pair<long, long const>>>, std::tuple<int, long>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_keys<std::pair<std::pair<int, int const>, std::pair<long, long const>>>, std::pair<int, long>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_keys<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>>, mp_list<int, long, long long>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_keys<std::tuple<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>>, std::tuple<int, long, long long>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_keys<std::tuple<std::tuple<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>>, std::tuple<int, long, long long>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_map_replace.cpp b/src/boost/libs/mp11/test/mp_map_replace.cpp new file mode 100644 index 000000000..c68b05923 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_map_replace.cpp @@ -0,0 +1,66 @@ + +// Copyright 2016 Peter Dimov. +// +// 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/mp11/map.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_map_replace; + using boost::mp11::mp_list; + using boost::mp11::mp_push_back; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<mp_list<>, mp_list<void>>, mp_list<mp_list<void>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<std::tuple<>, std::tuple<int>>, std::tuple<std::tuple<int>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<std::tuple<>, std::pair<int, float>>, std::tuple<std::pair<int, float>>>)); + + { + using M = mp_list<std::pair<int, int const>, std::pair<long, long const>>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<int>>, mp_list<mp_list<int>, std::pair<long, long const>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<long, float>>, mp_list<std::pair<int, int const>, std::pair<long, float>>>)); + } + + { + using M = std::tuple<std::pair<int, int const>, std::pair<long, long const>>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<int>>, std::tuple<mp_list<int>, std::pair<long, long const>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<long, float>>, std::tuple<std::pair<int, int const>, std::pair<long, float>>>)); + } + + { + using M = mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::tuple<int>>, mp_list<std::tuple<int>, mp_list<long, long>, mp_list<long long, long long, long long>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<long, float>>, mp_list<mp_list<int>, std::pair<long, float>, mp_list<long long, long long, long long>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<long long, float, double>>, mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, float, double>>>)); + } + + { + using M = std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<char>>, mp_push_back<M, mp_list<char>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<char, char const>>, mp_push_back<M, std::pair<char, char const>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::tuple<int>>, std::tuple<std::tuple<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, std::pair<long, float>>, std::tuple<mp_list<int>, std::pair<long, float>, std::tuple<long long, long long, long long>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_replace<M, mp_list<long long, float, double>>, std::tuple<mp_list<int>, std::pair<long, long>, mp_list<long long, float, double>>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_map_update.cpp b/src/boost/libs/mp11/test/mp_map_update.cpp new file mode 100644 index 000000000..24e7e775f --- /dev/null +++ b/src/boost/libs/mp11/test/mp_map_update.cpp @@ -0,0 +1,48 @@ + +// Copyright 2016, 2017 Peter Dimov. +// +// 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/mp11/map.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +using boost::mp11::mp_int; + +template<class T, class U> using inc = mp_int<U::value + 1>; + +int main() +{ + using boost::mp11::mp_map_update; + using boost::mp11::mp_list; + + using M1 = mp_list<>; + + using M2 = mp_map_update< M1, std::pair<char, mp_int<0>>, inc >; + BOOST_TEST_TRAIT_TRUE((std::is_same<M2, mp_list<std::pair<char, mp_int<0>>>>)); + + using M3 = mp_map_update< M2, std::pair<char, mp_int<0>>, inc >; + BOOST_TEST_TRAIT_TRUE((std::is_same<M3, mp_list<std::pair<char, mp_int<1>>>>)); + + using M4 = mp_map_update< M3, std::pair<int, mp_int<0>>, inc >; + BOOST_TEST_TRAIT_TRUE((std::is_same<M4, mp_list<std::pair<char, mp_int<1>>, std::pair<int, mp_int<0>>>>)); + + using M5 = mp_map_update< M4, std::pair<long, mp_int<0>>, inc >; + BOOST_TEST_TRAIT_TRUE((std::is_same<M5, mp_list<std::pair<char, mp_int<1>>, std::pair<int, mp_int<0>>, std::pair<long, mp_int<0>>>>)); + + using M6 = mp_map_update< M5, std::pair<long, mp_int<0>>, inc >; + BOOST_TEST_TRAIT_TRUE((std::is_same<M6, mp_list<std::pair<char, mp_int<1>>, std::pair<int, mp_int<0>>, std::pair<long, mp_int<1>>>>)); + + using M7 = mp_map_update< M6, std::pair<char, mp_int<0>>, inc >; + BOOST_TEST_TRAIT_TRUE((std::is_same<M7, mp_list<std::pair<char, mp_int<2>>, std::pair<int, mp_int<0>>, std::pair<long, mp_int<1>>>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_map_update_q.cpp b/src/boost/libs/mp11/test/mp_map_update_q.cpp new file mode 100644 index 000000000..7aae6ddbf --- /dev/null +++ b/src/boost/libs/mp11/test/mp_map_update_q.cpp @@ -0,0 +1,51 @@ + +// Copyright 2016, 2017 Peter Dimov. +// +// 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/mp11/map.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +using boost::mp11::mp_int; + +struct Q_inc +{ + template<class T, class U> using fn = mp_int<U::value + 1>; +}; + +int main() +{ + using boost::mp11::mp_map_update_q; + using boost::mp11::mp_list; + + using M1 = mp_list<>; + + using M2 = mp_map_update_q<M1, std::pair<char, mp_int<0>>, Q_inc>; + BOOST_TEST_TRAIT_TRUE((std::is_same<M2, mp_list<std::pair<char, mp_int<0>>>>)); + + using M3 = mp_map_update_q<M2, std::pair<char, mp_int<0>>, Q_inc>; + BOOST_TEST_TRAIT_TRUE((std::is_same<M3, mp_list<std::pair<char, mp_int<1>>>>)); + + using M4 = mp_map_update_q<M3, std::pair<int, mp_int<0>>, Q_inc>; + BOOST_TEST_TRAIT_TRUE((std::is_same<M4, mp_list<std::pair<char, mp_int<1>>, std::pair<int, mp_int<0>>>>)); + + using M5 = mp_map_update_q<M4, std::pair<long, mp_int<0>>, Q_inc>; + BOOST_TEST_TRAIT_TRUE((std::is_same<M5, mp_list<std::pair<char, mp_int<1>>, std::pair<int, mp_int<0>>, std::pair<long, mp_int<0>>>>)); + + using M6 = mp_map_update_q<M5, std::pair<long, mp_int<0>>, Q_inc>; + BOOST_TEST_TRAIT_TRUE((std::is_same<M6, mp_list<std::pair<char, mp_int<1>>, std::pair<int, mp_int<0>>, std::pair<long, mp_int<1>>>>)); + + using M7 = mp_map_update_q<M6, std::pair<char, mp_int<0>>, Q_inc>; + BOOST_TEST_TRAIT_TRUE((std::is_same<M7, mp_list<std::pair<char, mp_int<2>>, std::pair<int, mp_int<0>>, std::pair<long, mp_int<1>>>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_max.cpp b/src/boost/libs/mp11/test/mp_max.cpp new file mode 100644 index 000000000..577d26bce --- /dev/null +++ b/src/boost/libs/mp11/test/mp_max.cpp @@ -0,0 +1,31 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/detail/config.hpp> + +#if BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 40800 ) +# pragma GCC diagnostic ignored "-Wsign-compare" +#endif + +#include <boost/mp11/function.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_max; + using boost::mp11::mp_int; + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max<mp_int<1>>, mp_int<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max<mp_int<2>, mp_int<1>, mp_int<2>, mp_int<3>>, mp_int<3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max<mp_int<-1>, mp_size_t<1>, mp_int<-2>, mp_size_t<2>>, mp_size_t<2>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_max_element.cpp b/src/boost/libs/mp11/test/mp_max_element.cpp new file mode 100644 index 000000000..18550290b --- /dev/null +++ b/src/boost/libs/mp11/test/mp_max_element.cpp @@ -0,0 +1,55 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +using boost::mp11::mp_bool; + +template<class T, class U> using sizeof_less = mp_bool<(sizeof(T) < sizeof(U))>; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_max_element; + + { + using L1 = mp_list<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element<L1, sizeof_less>, void>)); + + using L2 = mp_list<char[2], char[4], char[3], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element<L2, sizeof_less>, char[4]>)); + + using L3 = mp_list<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element<L3, sizeof_less>, char[4]>)); + } + + { + using L1 = std::tuple<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element<L1, sizeof_less>, void>)); + + using L2 = std::tuple<char[2], char[4], char[3], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element<L2, sizeof_less>, char[4]>)); + + using L3 = std::tuple<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element<L3, sizeof_less>, char[4]>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_max_element_q.cpp b/src/boost/libs/mp11/test/mp_max_element_q.cpp new file mode 100644 index 000000000..36a79c4ce --- /dev/null +++ b/src/boost/libs/mp11/test/mp_max_element_q.cpp @@ -0,0 +1,58 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +using boost::mp11::mp_bool; + +struct Q_sizeof_less +{ + template<class T, class U> using fn = mp_bool<(sizeof(T) < sizeof(U))>; +}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_max_element_q; + + { + using L1 = mp_list<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element_q<L1, Q_sizeof_less>, void>)); + + using L2 = mp_list<char[2], char[4], char[3], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element_q<L2, Q_sizeof_less>, char[4]>)); + + using L3 = mp_list<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element_q<L3, Q_sizeof_less>, char[4]>)); + } + + { + using L1 = std::tuple<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element_q<L1, Q_sizeof_less>, void>)); + + using L2 = std::tuple<char[2], char[4], char[3], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element_q<L2, Q_sizeof_less>, char[4]>)); + + using L3 = std::tuple<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element_q<L3, Q_sizeof_less>, char[4]>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_min.cpp b/src/boost/libs/mp11/test/mp_min.cpp new file mode 100644 index 000000000..a23209842 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_min.cpp @@ -0,0 +1,31 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/detail/config.hpp> + +#if BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 40800 ) +# pragma GCC diagnostic ignored "-Wsign-compare" +#endif + +#include <boost/mp11/function.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_min; + using boost::mp11::mp_int; + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min<mp_int<1>>, mp_int<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min<mp_int<2>, mp_int<1>, mp_int<2>, mp_int<3>>, mp_int<1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min<mp_int<-1>, mp_size_t<1>, mp_int<-2>, mp_size_t<2>>, mp_int<-2>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_min_element.cpp b/src/boost/libs/mp11/test/mp_min_element.cpp new file mode 100644 index 000000000..3a4451e09 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_min_element.cpp @@ -0,0 +1,55 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +using boost::mp11::mp_bool; + +template<class T, class U> using sizeof_less = mp_bool<(sizeof(T) < sizeof(U))>; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_min_element; + + { + using L1 = mp_list<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min_element<L1, sizeof_less>, void>)); + + using L2 = mp_list<char[2], char[4], char[3], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min_element<L2, sizeof_less>, char[1]>)); + + using L3 = mp_list<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min_element<L3, sizeof_less>, char[1]>)); + } + + { + using L1 = std::tuple<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min_element<L1, sizeof_less>, void>)); + + using L2 = std::tuple<char[2], char[4], char[3], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min_element<L2, sizeof_less>, char[1]>)); + + using L3 = std::tuple<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min_element<L3, sizeof_less>, char[1]>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_min_element_q.cpp b/src/boost/libs/mp11/test/mp_min_element_q.cpp new file mode 100644 index 000000000..b1a09202b --- /dev/null +++ b/src/boost/libs/mp11/test/mp_min_element_q.cpp @@ -0,0 +1,58 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +using boost::mp11::mp_bool; + +struct Q_sizeof_less +{ + template<class T, class U> using fn = mp_bool<(sizeof(T) < sizeof(U))>; +}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_min_element_q; + + { + using L1 = mp_list<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min_element_q<L1, Q_sizeof_less>, void>)); + + using L2 = mp_list<char[2], char[4], char[3], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min_element_q<L2, Q_sizeof_less>, char[1]>)); + + using L3 = mp_list<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min_element_q<L3, Q_sizeof_less>, char[1]>)); + } + + { + using L1 = std::tuple<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min_element_q<L1, Q_sizeof_less>, void>)); + + using L2 = std::tuple<char[2], char[4], char[3], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min_element_q<L2, Q_sizeof_less>, char[1]>)); + + using L3 = std::tuple<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_min_element_q<L3, Q_sizeof_less>, char[1]>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_none_of.cpp b/src/boost/libs/mp11/test/mp_none_of.cpp new file mode 100644 index 000000000..ab9ca3b0d --- /dev/null +++ b/src/boost/libs/mp11/test/mp_none_of.cpp @@ -0,0 +1,95 @@ + +// Copyright 2015, 2016 Peter Dimov. +// +// 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/mp11/detail/config.hpp> + +#if BOOST_MP11_MSVC +# pragma warning( disable: 4503 ) // decorated name length exceeded +#endif + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_none_of; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L1, std::is_const>, mp_true>)); + + using L2 = mp_list<X1, X1 const, X1, X1, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L2, std::is_volatile>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L2, std::is_const>, mp_false>)); + + using L3 = mp_list<X1 const, X1 const, X1, X1 const, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L3, std::is_volatile>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L3, std::is_const>, mp_false>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L1, std::is_const>, mp_true>)); + + using L2 = std::tuple<X1, X1 const, X1, X1, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L2, std::is_volatile>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L2, std::is_const>, mp_false>)); + + using L3 = std::tuple<X1 const, X1 const, X1, X1 const, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L3, std::is_volatile>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L3, std::is_const>, mp_false>)); + } + + { + using L2 = std::pair<X1 const, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L2, std::is_volatile>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L2, std::is_const>, mp_false>)); + + using L3 = std::pair<X1 const, X1 const>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L3, std::is_volatile>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of<L3, std::is_const>, mp_false>)); + } + + { + using boost::mp11::mp_repeat_c; + using boost::mp11::mp_to_bool; + using boost::mp11::mp_push_back; + + int const N = 1089; + + using L1 = mp_repeat_c<mp_list<mp_false>, N>; + using R1 = mp_none_of<L1, mp_to_bool>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_true>)); + + using L2 = mp_push_back<L1, mp_true>; + using R2 = mp_none_of<L2, mp_to_bool>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, mp_false>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_none_of_q.cpp b/src/boost/libs/mp11/test/mp_none_of_q.cpp new file mode 100644 index 000000000..dd4ba636f --- /dev/null +++ b/src/boost/libs/mp11/test/mp_none_of_q.cpp @@ -0,0 +1,74 @@ + +// Copyright 2015, 2016, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_none_of_q; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + using boost::mp11::mp_quote; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L1, mp_quote<std::is_const>>, mp_true>)); + + using L2 = mp_list<X1, X1 const, X1, X1, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L2, mp_quote<std::is_volatile>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L2, mp_quote<std::is_const>>, mp_false>)); + + using L3 = mp_list<X1 const, X1 const, X1, X1 const, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L3, mp_quote<std::is_volatile>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L3, mp_quote<std::is_const>>, mp_false>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L1, mp_quote<std::is_const>>, mp_true>)); + + using L2 = std::tuple<X1, X1 const, X1, X1, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L2, mp_quote<std::is_volatile>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L2, mp_quote<std::is_const>>, mp_false>)); + + using L3 = std::tuple<X1 const, X1 const, X1, X1 const, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L3, mp_quote<std::is_volatile>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L3, mp_quote<std::is_const>>, mp_false>)); + } + + { + using L2 = std::pair<X1 const, X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L2, mp_quote<std::is_volatile>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L2, mp_quote<std::is_const>>, mp_false>)); + + using L3 = std::pair<X1 const, X1 const>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L3, mp_quote<std::is_volatile>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_none_of_q<L3, mp_quote<std::is_const>>, mp_false>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_not_fn.cpp b/src/boost/libs/mp11/test/mp_not_fn.cpp new file mode 100644 index 000000000..808e0ab11 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_not_fn.cpp @@ -0,0 +1,36 @@ + +// Copyright 2019 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +template<class T> using is_const_ = std::is_const<T>; + +struct Q_is_const +{ + template<class T> using fn = std::is_const<T>; +}; + +int main() +{ + using boost::mp11::mp_not_fn; + using boost::mp11::mp_not_fn_q; + + BOOST_TEST_TRAIT_TRUE((mp_not_fn<std::is_const>::fn<void>)); + BOOST_TEST_TRAIT_FALSE((mp_not_fn<std::is_const>::fn<void const>)); + + BOOST_TEST_TRAIT_TRUE((mp_not_fn<is_const_>::fn<void>)); + BOOST_TEST_TRAIT_FALSE((mp_not_fn<is_const_>::fn<void const>)); + + BOOST_TEST_TRAIT_TRUE((mp_not_fn_q<Q_is_const>::fn<void>)); + BOOST_TEST_TRAIT_FALSE((mp_not_fn_q<Q_is_const>::fn<void const>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_nth_element.cpp b/src/boost/libs/mp11/test/mp_nth_element.cpp new file mode 100644 index 000000000..8a077d7cc --- /dev/null +++ b/src/boost/libs/mp11/test/mp_nth_element.cpp @@ -0,0 +1,72 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/function.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +int main() +{ + using boost::mp11::mp_nth_element; + using boost::mp11::mp_nth_element_c; + using boost::mp11::mp_list_c; + using boost::mp11::mp_sort; + using boost::mp11::mp_less; + using boost::mp11::mp_at_c; + using boost::mp11::mp_size_t; + using boost::mp11::mp_rename; + + { + using L1 = mp_list_c<int, 7, 1, 11, 3, 2, 2, 4>; + using L2 = mp_sort<L1, mp_less>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 0, mp_less>, mp_at_c<L2, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 1, mp_less>, mp_at_c<L2, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 2, mp_less>, mp_at_c<L2, 2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 3, mp_less>, mp_at_c<L2, 3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 4, mp_less>, mp_at_c<L2, 4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 5, mp_less>, mp_at_c<L2, 5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 6, mp_less>, mp_at_c<L2, 6>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<0>, mp_less>, mp_at_c<L2, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<1>, mp_less>, mp_at_c<L2, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<2>, mp_less>, mp_at_c<L2, 2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<3>, mp_less>, mp_at_c<L2, 3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<4>, mp_less>, mp_at_c<L2, 4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<5>, mp_less>, mp_at_c<L2, 5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<6>, mp_less>, mp_at_c<L2, 6>>)); + } + + { + using L1 = mp_rename<mp_list_c<int, 7, 1, 11, 3, 2, 2, 4>, std::tuple>; + using L2 = mp_sort<L1, mp_less>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 0, mp_less>, mp_at_c<L2, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 1, mp_less>, mp_at_c<L2, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 2, mp_less>, mp_at_c<L2, 2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 3, mp_less>, mp_at_c<L2, 3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 4, mp_less>, mp_at_c<L2, 4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 5, mp_less>, mp_at_c<L2, 5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_c<L1, 6, mp_less>, mp_at_c<L2, 6>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<0>, mp_less>, mp_at_c<L2, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<1>, mp_less>, mp_at_c<L2, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<2>, mp_less>, mp_at_c<L2, 2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<3>, mp_less>, mp_at_c<L2, 3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<4>, mp_less>, mp_at_c<L2, 4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<5>, mp_less>, mp_at_c<L2, 5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element<L1, mp_size_t<6>, mp_less>, mp_at_c<L2, 6>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_nth_element_q.cpp b/src/boost/libs/mp11/test/mp_nth_element_q.cpp new file mode 100644 index 000000000..0c6a333fe --- /dev/null +++ b/src/boost/libs/mp11/test/mp_nth_element_q.cpp @@ -0,0 +1,59 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/function.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +int main() +{ + using boost::mp11::mp_nth_element_q; + using boost::mp11::mp_list_c; + using boost::mp11::mp_sort_q; + using boost::mp11::mp_less; + using boost::mp11::mp_at_c; + using boost::mp11::mp_size_t; + using boost::mp11::mp_rename; + using boost::mp11::mp_quote; + + using Q_less = mp_quote<mp_less>; + + { + using L1 = mp_list_c<int, 7, 1, 11, 3, 2, 2, 4>; + using L2 = mp_sort_q<L1, Q_less>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<0>, Q_less>, mp_at_c<L2, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<1>, Q_less>, mp_at_c<L2, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<2>, Q_less>, mp_at_c<L2, 2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<3>, Q_less>, mp_at_c<L2, 3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<4>, Q_less>, mp_at_c<L2, 4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<5>, Q_less>, mp_at_c<L2, 5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<6>, Q_less>, mp_at_c<L2, 6>>)); + } + + { + using L1 = mp_rename<mp_list_c<int, 7, 1, 11, 3, 2, 2, 4>, std::tuple>; + using L2 = mp_sort_q<L1, Q_less>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<0>, Q_less>, mp_at_c<L2, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<1>, Q_less>, mp_at_c<L2, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<2>, Q_less>, mp_at_c<L2, 2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<3>, Q_less>, mp_at_c<L2, 3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<4>, Q_less>, mp_at_c<L2, 4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<5>, Q_less>, mp_at_c<L2, 5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<6>, Q_less>, mp_at_c<L2, 6>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_or.cpp b/src/boost/libs/mp11/test/mp_or.cpp new file mode 100644 index 000000000..f88097ebf --- /dev/null +++ b/src/boost/libs/mp11/test/mp_or.cpp @@ -0,0 +1,73 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/mp11/function.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_or; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + using boost::mp11::mp_int; + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<-7>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<7>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_true, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>, mp_int<0>>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>, mp_int<5>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<-4>, void>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<7>, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_size_t<4>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_size_t<0>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_true, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_true, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_false, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_false, mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_true, void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_true, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_false, mp_true, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_false, mp_false, mp_true>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_false, mp_false, mp_false, mp_false>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<1>, void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>, mp_int<2>, void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>, mp_int<0>, mp_int<3>, void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>, mp_int<0>, mp_int<0>, mp_int<4>, void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_int<0>, mp_int<0>, mp_int<0>, mp_int<0>, mp_int<0>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<1>, void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_size_t<2>, void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_size_t<0>, mp_size_t<3>, void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_size_t<0>, mp_size_t<0>, mp_size_t<4>, void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_size_t<0>, mp_size_t<0>, mp_size_t<0>, mp_size_t<0>>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_int<0>, mp_false, mp_size_t<141>, void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_or<mp_size_t<0>, mp_int<0>, mp_false>, mp_false>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_pairwise_fold.cpp b/src/boost/libs/mp11/test/mp_pairwise_fold.cpp new file mode 100644 index 000000000..48141a7e2 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_pairwise_fold.cpp @@ -0,0 +1,49 @@ +// Copyright 2020 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +template<class T, class U> using is_same = typename std::is_same<T, U>::type; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_pairwise_fold; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<mp_list<>, mp_list>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<mp_list<X1>, mp_list>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<mp_list<X1, X2>, mp_list>, mp_list<mp_list<X1, X2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<mp_list<X1, X2, X3>, mp_list>, mp_list<mp_list<X1, X2>, mp_list<X2, X3>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<mp_list<X1, X2, X3, X4>, mp_list>, mp_list<mp_list<X1, X2>, mp_list<X2, X3>, mp_list<X3, X4>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<mp_list<>, std::pair>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<mp_list<X1>, std::pair>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<mp_list<X1, X2>, std::pair>, mp_list<std::pair<X1, X2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<mp_list<X1, X2, X3>, std::pair>, mp_list<std::pair<X1, X2>, std::pair<X2, X3>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<mp_list<X1, X2, X3, X4>, std::pair>, mp_list<std::pair<X1, X2>, std::pair<X2, X3>, std::pair<X3, X4>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<std::tuple<>, std::pair>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<std::tuple<X1>, std::pair>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<std::tuple<X1, X2>, std::pair>, std::tuple<std::pair<X1, X2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<std::tuple<X1, X2, X3>, std::pair>, std::tuple<std::pair<X1, X2>, std::pair<X2, X3>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<std::tuple<X1, X2, X3, X4>, std::pair>, std::tuple<std::pair<X1, X2>, std::pair<X2, X3>, std::pair<X3, X4>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<std::tuple<>, is_same>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<std::tuple<X1>, is_same>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<std::tuple<X1, X2>, is_same>, std::tuple<is_same<X1, X2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<std::tuple<X1, X2, X2>, is_same>, std::tuple<is_same<X1, X2>, is_same<X2, X2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pairwise_fold<std::tuple<X1, X2, X2, X1>, is_same>, std::tuple<is_same<X1, X2>, is_same<X2, X2>, is_same<X2, X1>>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_pairwise_fold_q.cpp b/src/boost/libs/mp11/test/mp_pairwise_fold_q.cpp new file mode 100644 index 000000000..b7e995a5f --- /dev/null +++ b/src/boost/libs/mp11/test/mp_pairwise_fold_q.cpp @@ -0,0 +1,18 @@ +// Copyright 2020 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/mp11.hpp> +#include <boost/core/lightweight_test_trait.hpp> + +using namespace boost::mp11; + +template<class L, template<class...> class P> using is_sorted = mp_none_of<mp_pairwise_fold_q<L, mp_bind<P, _2, _1>>, mp_to_bool>; + +int main() +{ + BOOST_TEST_TRAIT_TRUE((is_sorted<mp_list<mp_int<0>, mp_int<0>, mp_int<1>, mp_int<3>, mp_int<3>, mp_int<7>>, mp_less>)); + BOOST_TEST_TRAIT_FALSE((is_sorted<mp_list<mp_int<0>, mp_int<0>, mp_int<1>, mp_int<3>, mp_int<3>, mp_int<2>>, mp_less>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_partial_sum.cpp b/src/boost/libs/mp11/test/mp_partial_sum.cpp new file mode 100644 index 000000000..75366b0f8 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_partial_sum.cpp @@ -0,0 +1,88 @@ +// Copyright 2020 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/function.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <cstddef> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +template<class T1, class T2> struct F {}; + +struct Q +{ + template<class T1, class T2> struct fn {}; +}; + +int main() +{ + using boost::mp11::mp_partial_sum; + using boost::mp11::mp_list; + using boost::mp11::mp_list_c; + using boost::mp11::mp_int; + using boost::mp11::mp_size_t; + using boost::mp11::mp_plus; + using boost::mp11::mp_rename; + using boost::mp11::mp_partial_sum_q; + using boost::mp11::mp_quote; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum< mp_list<>, void, F >, mp_list<> >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum< mp_list<X1>, void, F >, mp_list< F<void, X1> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum< mp_list<X1, X2>, void, F >, mp_list< F<void, X1>, F<F<void, X1>, X2> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum< mp_list<X1, X2, X3>, void, F >, mp_list< F<void, X1>, F<F<void, X1>, X2>, F<F<F<void, X1>, X2>, X3> > >)); + + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum< mp_list_c<int, 7, 7, 2>, mp_int<0>, mp_plus >, mp_list< mp_int<7>, mp_int<14>, mp_int<16> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum< mp_list_c<std::size_t, 7, 7, 2>, mp_size_t<0>, mp_plus >, mp_list< mp_size_t<7>, mp_size_t<14>, mp_size_t<16> > >)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< mp_list<>, void, mp_quote<F> >, mp_list<> >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< mp_list<X1>, void, mp_quote<F> >, mp_list< F<void, X1> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< mp_list<X1, X2>, void, mp_quote<F> >, mp_list< F<void, X1>, F<F<void, X1>, X2> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< mp_list<X1, X2, X3>, void, mp_quote<F> >, mp_list< F<void, X1>, F<F<void, X1>, X2>, F<F<F<void, X1>, X2>, X3> > >)); + + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< mp_list<>, void, Q >, mp_list<> >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< mp_list<X1>, void, Q >, mp_list< Q::fn<void, X1> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< mp_list<X1, X2>, void, Q >, mp_list< Q::fn<void, X1>, Q::fn<Q::fn<void, X1>, X2> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< mp_list<X1, X2, X3>, void, Q >, mp_list< Q::fn<void, X1>, Q::fn<Q::fn<void, X1>, X2>, Q::fn<Q::fn<Q::fn<void, X1>, X2>, X3> > >)); + + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< mp_list_c<int, 7, 7, 2>, mp_int<0>, mp_quote<mp_plus> >, mp_list< mp_int<7>, mp_int<14>, mp_int<16> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< mp_list_c<std::size_t, 7, 7, 2>, mp_size_t<0>, mp_quote<mp_plus> >, mp_list< mp_size_t<7>, mp_size_t<14>, mp_size_t<16> > >)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum< std::tuple<>, void, F >, std::tuple<> >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum< std::tuple<X1>, void, F >, std::tuple< F<void, X1> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum< std::tuple<X1, X2>, void, F >, std::tuple< F<void, X1>, F<F<void, X1>, X2> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum< std::tuple<X1, X2, X3>, void, F >, std::tuple< F<void, X1>, F<F<void, X1>, X2>, F<F<F<void, X1>, X2>, X3> > >)); + + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum< mp_rename<mp_list_c<int, 7, 7, 2>, std::tuple>, mp_int<0>, mp_plus >, std::tuple< mp_int<7>, mp_int<14>, mp_int<16> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum< mp_rename<mp_list_c<std::size_t, 7, 7, 2>, std::tuple>, mp_size_t<0>, mp_plus >, std::tuple< mp_size_t<7>, mp_size_t<14>, mp_size_t<16> > >)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< std::tuple<>, void, mp_quote<F> >, std::tuple<> >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< std::tuple<X1>, void, mp_quote<F> >, std::tuple< F<void, X1> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< std::tuple<X1, X2>, void, mp_quote<F> >, std::tuple< F<void, X1>, F<F<void, X1>, X2> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< std::tuple<X1, X2, X3>, void, mp_quote<F> >, std::tuple< F<void, X1>, F<F<void, X1>, X2>, F<F<F<void, X1>, X2>, X3> > >)); + + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< std::tuple<>, void, Q >, std::tuple<> >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< std::tuple<X1>, void, Q >, std::tuple< Q::fn<void, X1> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< std::tuple<X1, X2>, void, Q >, std::tuple< Q::fn<void, X1>, Q::fn<Q::fn<void, X1>, X2> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< std::tuple<X1, X2, X3>, void, Q >, std::tuple< Q::fn<void, X1>, Q::fn<Q::fn<void, X1>, X2>, Q::fn<Q::fn<Q::fn<void, X1>, X2>, X3> > >)); + + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< mp_rename<mp_list_c<int, 7, 7, 2>, std::tuple>, mp_int<0>, mp_quote<mp_plus> >, std::tuple< mp_int<7>, mp_int<14>, mp_int<16> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_partial_sum_q< mp_rename<mp_list_c<std::size_t, 7, 7, 2>, std::tuple>, mp_size_t<0>, mp_quote<mp_plus> >, std::tuple< mp_size_t<7>, mp_size_t<14>, mp_size_t<16> > >)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_partition.cpp b/src/boost/libs/mp11/test/mp_partition.cpp new file mode 100644 index 000000000..8dc1ac2b1 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_partition.cpp @@ -0,0 +1,50 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_partition; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L1, std::is_const>, mp_list<L1, L1>>)); + + using L2 = mp_list<X1, X1 const, X1*, X2 const, X2*, X3*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L2, std::is_volatile>, mp_list<L1, L2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L2, std::is_const>, mp_list<mp_list<X1 const, X2 const>, mp_list<X1, X1*, X2*, X3*>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L2, std::is_pointer>, mp_list<mp_list<X1*, X2*, X3*>, mp_list<X1, X1 const, X2 const>>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L1, std::is_const>, std::tuple<L1, L1>>)); + + using L2 = std::tuple<X1, X1 const, X1*, X2 const, X2*, X3*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L2, std::is_volatile>, std::tuple<L1, L2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L2, std::is_const>, std::tuple<std::tuple<X1 const, X2 const>, std::tuple<X1, X1*, X2*, X3*>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L2, std::is_pointer>, std::tuple<std::tuple<X1*, X2*, X3*>, std::tuple<X1, X1 const, X2 const>>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_partition_q.cpp b/src/boost/libs/mp11/test/mp_partition_q.cpp new file mode 100644 index 000000000..fc04c52d1 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_partition_q.cpp @@ -0,0 +1,52 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_partition_q; + using boost::mp11::mp_quote; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition_q<L1, mp_quote<std::is_const>>, mp_list<L1, L1>>)); + + using L2 = mp_list<X1, X1 const, X1*, X2 const, X2*, X3*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition_q<L2, mp_quote<std::is_volatile>>, mp_list<L1, L2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition_q<L2, mp_quote<std::is_const>>, mp_list<mp_list<X1 const, X2 const>, mp_list<X1, X1*, X2*, X3*>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition_q<L2, mp_quote<std::is_pointer>>, mp_list<mp_list<X1*, X2*, X3*>, mp_list<X1, X1 const, X2 const>>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition_q<L1, mp_quote<std::is_const>>, std::tuple<L1, L1>>)); + + using L2 = std::tuple<X1, X1 const, X1*, X2 const, X2*, X3*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition_q<L2, mp_quote<std::is_volatile>>, std::tuple<L1, L2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition_q<L2, mp_quote<std::is_const>>, std::tuple<std::tuple<X1 const, X2 const>, std::tuple<X1, X1*, X2*, X3*>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition_q<L2, mp_quote<std::is_pointer>>, std::tuple<std::tuple<X1*, X2*, X3*>, std::tuple<X1, X1 const, X2 const>>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_plus.cpp b/src/boost/libs/mp11/test/mp_plus.cpp new file mode 100644 index 000000000..06c05d2c0 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_plus.cpp @@ -0,0 +1,32 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/mp11/function.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +template<class T, T N> using integral = std::integral_constant<T, N>; + +int main() +{ + using boost::mp11::mp_plus; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_plus<>, integral<int, 0>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_plus<integral<char, 1>>, integral<int, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_plus<integral<short, 2>>, integral<int, 2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_plus<integral<int, 3>>, integral<int, 3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_plus<integral<unsigned, 4>>, integral<unsigned, 4>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_plus<integral<char, 1>, integral<char, 2>>, integral<int, 3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_plus<integral<short, 1>, integral<short, 2>, integral<short, 3>>, integral<int, 6>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_plus<integral<int, 1>, integral<int, 2>, integral<int, 3>, integral<long, 4>>, integral<long, 10>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_pop_back.cpp b/src/boost/libs/mp11/test/mp_pop_back.cpp new file mode 100644 index 000000000..554da9ed1 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_pop_back.cpp @@ -0,0 +1,49 @@ + +// Copyright 2015, 2019 Peter Dimov +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/utility.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_pop_back; + + using L1 = mp_list<void>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pop_back<L1>, mp_list<>>)); + + using L2 = mp_list<float, void, int[]>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pop_back<L2>, mp_list<float, void>>)); + + using L3 = std::tuple<int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pop_back<L3>, std::tuple<>>)); + + using L4 = std::tuple<char, double>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pop_back<L4>, std::tuple<char>>)); + + using boost::mp11::mp_iota_c; + using boost::mp11::mp_size_t; + + int const N = 137; + + using L6 = mp_iota_c<N>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pop_back<L6>, mp_iota_c<N-1>>)); + + using boost::mp11::mp_valid; + + using L7 = mp_list<>; + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_pop_back, L7>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_pop_front.cpp b/src/boost/libs/mp11/test/mp_pop_front.cpp new file mode 100644 index 000000000..f1ff16a50 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_pop_front.cpp @@ -0,0 +1,39 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/list.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_pop_front; + using boost::mp11::mp_rest; + + using L1 = mp_list<void>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pop_front<L1>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rest<L1>, mp_list<>>)); + + using L2 = mp_list<int[], void(), float>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pop_front<L2>, mp_list<void(), float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rest<L2>, mp_list<void(), float>>)); + + using L3 = std::tuple<int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pop_front<L3>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rest<L3>, std::tuple<>>)); + + using L4 = std::tuple<char, double>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_pop_front<L4>, std::tuple<double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rest<L4>, std::tuple<double>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_power_set.cpp b/src/boost/libs/mp11/test/mp_power_set.cpp new file mode 100644 index 000000000..250bfbb02 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_power_set.cpp @@ -0,0 +1,33 @@ +// Copyright 2020 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_power_set; + + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_power_set< mp_list<> >, mp_list<mp_list<>> >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_power_set< mp_list<X1> >, mp_list< mp_list<>, mp_list<X1> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_power_set< mp_list<X2, X1> >, mp_list< mp_list<>, mp_list<X1>, mp_list<X2>, mp_list<X2, X1> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_power_set< mp_list<X1, X1> >, mp_list< mp_list<>, mp_list<X1>, mp_list<X1>, mp_list<X1, X1> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_power_set< mp_list<X3, X2, X1> >, mp_list< mp_list<>, mp_list<X1>, mp_list<X2>, mp_list<X2, X1>, mp_list<X3>, mp_list<X3, X1>, mp_list<X3, X2>, mp_list<X3, X2, X1> > >)); + + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_power_set< std::tuple<> >, std::tuple<std::tuple<>> >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_power_set< std::tuple<X1> >, std::tuple< std::tuple<>, std::tuple<X1> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_power_set< std::tuple<X2, X1> >, std::tuple< std::tuple<>, std::tuple<X1>, std::tuple<X2>, std::tuple<X2, X1> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_power_set< std::tuple<X1, X1> >, std::tuple< std::tuple<>, std::tuple<X1>, std::tuple<X1>, std::tuple<X1, X1> > >)); + BOOST_TEST_TRAIT_TRUE((std::is_same< mp_power_set< std::tuple<X3, X2, X1> >, std::tuple< std::tuple<>, std::tuple<X1>, std::tuple<X2>, std::tuple<X2, X1>, std::tuple<X3>, std::tuple<X3, X1>, std::tuple<X3, X2>, std::tuple<X3, X2, X1> > >)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_product.cpp b/src/boost/libs/mp11/test/mp_product.cpp new file mode 100644 index 000000000..f00bc40fb --- /dev/null +++ b/src/boost/libs/mp11/test/mp_product.cpp @@ -0,0 +1,74 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +struct Y1 {}; + +struct Z1 {}; +struct Z2 {}; + +template<class T> struct F1 {}; +template<class T1, class T2, class T3> struct F3 {}; + +template<class...> struct F {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_product; + using boost::mp11::mp_product_q; + using boost::mp11::mp_quote; + + { + using L1 = std::tuple<X1, X2, X3>; + using L2 = mp_list<Y1>; + using L3 = std::pair<Z1, Z2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product<F3, L1, L2, L3>, std::tuple<F3<X1, Y1, Z1>, F3<X1, Y1, Z2>, F3<X2, Y1, Z1>, F3<X2, Y1, Z2>, F3<X3, Y1, Z1>, F3<X3, Y1, Z2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product_q<mp_quote<F3>, L1, L2, L3>, std::tuple<F3<X1, Y1, Z1>, F3<X1, Y1, Z2>, F3<X2, Y1, Z1>, F3<X2, Y1, Z2>, F3<X3, Y1, Z1>, F3<X3, Y1, Z2>>>)); + } + + { + using L1 = std::tuple<X1, X2, X3>; + using L2 = mp_list<>; + using L3 = std::pair<Z1, Z2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product<F3, L1, L2, L3>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product_q<mp_quote<F3>, L1, L2, L3>, std::tuple<>>)); + } + + { + using L1 = std::tuple<X1, X2, X3>; + using L2 = mp_list<X1, X2, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product<F1, L1>, std::tuple<F1<X1>, F1<X2>, F1<X3>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product_q<mp_quote<F1>, L1>, std::tuple<F1<X1>, F1<X2>, F1<X3>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product<F1, L2>, mp_list<F1<X1>, F1<X2>, F1<X3>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product_q<mp_quote<F1>, L2>, mp_list<F1<X1>, F1<X2>, F1<X3>>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product<F>, mp_list<F<>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_product_q<mp_quote<F>>, mp_list<F<>>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_push_back.cpp b/src/boost/libs/mp11/test/mp_push_back.cpp new file mode 100644 index 000000000..c74fb0315 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_push_back.cpp @@ -0,0 +1,52 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/list.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_push_back; + + using L1 = mp_list<>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L1>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L1, char[1]>, mp_list<char[1]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L1, char[1], char[2]>, mp_list<char[1], char[2]>>)); + + using L2 = mp_list<void>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L2>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L2, char[1]>, mp_list<void, char[1]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L2, char[1], char[2]>, mp_list<void, char[1], char[2]>>)); + + using L3 = mp_list<int[], void, float>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L3>, mp_list<int[], void, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L3, char[1]>, mp_list<int[], void, float, char[1]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L3, char[1], char[2]>, mp_list<int[], void, float, char[1], char[2]>>)); + + using L4 = std::tuple<>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L4>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L4, char>, std::tuple<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L4, char, wchar_t>, std::tuple<char, wchar_t>>)); + + using L5 = std::tuple<int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L5>, std::tuple<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L5, char>, std::tuple<int, char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L5, char, wchar_t>, std::tuple<int, char, wchar_t>>)); + + using L6 = std::tuple<int, int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L6>, std::tuple<int, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L6, char>, std::tuple<int, int, char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_back<L6, char, wchar_t>, std::tuple<int, int, char, wchar_t>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_push_front.cpp b/src/boost/libs/mp11/test/mp_push_front.cpp new file mode 100644 index 000000000..73fcc8b7d --- /dev/null +++ b/src/boost/libs/mp11/test/mp_push_front.cpp @@ -0,0 +1,52 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/list.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_push_front; + + using L1 = mp_list<>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L1>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L1, char[1]>, mp_list<char[1]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L1, char[1], char[2]>, mp_list<char[1], char[2]>>)); + + using L2 = mp_list<void>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L2>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L2, char[1]>, mp_list<char[1], void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L2, char[1], char[2]>, mp_list<char[1], char[2], void>>)); + + using L3 = mp_list<int[], void, float>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L3>, mp_list<int[], void, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L3, char[1]>, mp_list<char[1], int[], void, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L3, char[1], char[2]>, mp_list<char[1], char[2], int[], void, float>>)); + + using L4 = std::tuple<>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L4>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L4, char>, std::tuple<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L4, char, wchar_t>, std::tuple<char, wchar_t>>)); + + using L5 = std::tuple<int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L5>, std::tuple<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L5, char>, std::tuple<char, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L5, char, wchar_t>, std::tuple<char, wchar_t, int>>)); + + using L6 = std::tuple<int, int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L6>, std::tuple<int, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L6, char>, std::tuple<char, int, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_push_front<L6, char, wchar_t>, std::tuple<char, wchar_t, int, int>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_quote.cpp b/src/boost/libs/mp11/test/mp_quote.cpp new file mode 100644 index 000000000..62bc915ba --- /dev/null +++ b/src/boost/libs/mp11/test/mp_quote.cpp @@ -0,0 +1,68 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/mp11/detail/config.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +using boost::mp11::mp_invoke_q; + +template<class...> struct X {}; + +template<template<class...> class F, class... T> using Y = X<F<T>...>; + +template<class Q, class... T> using Z = X<mp_invoke_q<Q, T>...>; + +template<class T, class U> struct P {}; + +template<class T, class U> using first = T; + +int main() +{ + using boost::mp11::mp_identity_t; + using boost::mp11::mp_quote; + + { + using Q = mp_quote<mp_identity_t>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, void>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, int[]>, int[]>)); + } + + { + using Q = mp_quote<mp_identity_t>; + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) + using R1 = Y<Q::fn, void, char, int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, X<void, char, int>>)); +#endif + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 && BOOST_MP11_MSVC >= 1900 ) + using R2 = Z<Q, void, char, int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, X<void, char, int>>)); +#endif + } + + { + using Q = mp_quote<P>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, void, void>, P<void, void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, char[], int[]>, P<char[], int[]>>)); + } + + { + using Q = mp_quote<first>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, void, int>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, char[], int[]>, char[]>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_quote_trait.cpp b/src/boost/libs/mp11/test/mp_quote_trait.cpp new file mode 100644 index 000000000..ab52bb949 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_quote_trait.cpp @@ -0,0 +1,58 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/mp11/detail/config.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_identity; + using boost::mp11::mp_quote_trait; + using boost::mp11::mp_invoke_q; + + { + using Q = mp_quote_trait<mp_identity>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<Q::fn<void>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<Q::fn<int[]>, int[]>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, void>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, int[]>, int[]>)); + } + + { + using Q = mp_quote_trait<std::add_pointer>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<Q::fn<void>, void*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<Q::fn<int[]>, int(*)[]>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, void>, void*>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, int[]>, int(*)[]>)); + } + + { + using Q = mp_quote_trait<std::add_const>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<Q::fn<void>, void const>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<Q::fn<int[]>, int const[]>)); + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 40900 ) + + // g++ 4.7, 4.8 have difficulties with preserving top-level const + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, void>, void const>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, int[]>, int const[]>)); + +#endif + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_remove.cpp b/src/boost/libs/mp11/test/mp_remove.cpp new file mode 100644 index 000000000..87d9c6175 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_remove.cpp @@ -0,0 +1,52 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_remove; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L1, void>, L1>)); + + using L2 = mp_list<X1, X2, X3, X2, X3, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, void>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X1>, mp_list<X2, X3, X2, X3, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X2>, mp_list<X1, X3, X3, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X3>, mp_list<X1, X2, X2>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L1, void>, L1>)); + + using L2 = std::tuple<X1, X2, X3, X2, X3, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, void>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X1>, std::tuple<X2, X3, X2, X3, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X2>, std::tuple<X1, X3, X3, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X3>, std::tuple<X1, X2, X2>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_remove_if.cpp b/src/boost/libs/mp11/test/mp_remove_if.cpp new file mode 100644 index 000000000..883bf6cc7 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_remove_if.cpp @@ -0,0 +1,67 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +using boost::mp11::mp_bool; + +template<class N> using is_odd = mp_bool<N::value % 2 != 0>; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_remove_if; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if<L1, std::is_const>, L1>)); + + using L2 = mp_list<X1, X1 const, X1*, X2 const, X2*, X3*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if<L2, std::is_volatile>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if<L2, std::is_const>, mp_list<X1, X1*, X2*, X3*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if<L2, std::is_pointer>, mp_list<X1, X1 const, X2 const>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if<L1, std::is_const>, L1>)); + + using L2 = std::tuple<X1, X1 const, X1*, X2 const, X2*, X3*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if<L2, std::is_volatile>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if<L2, std::is_const>, std::tuple<X1, X1*, X2*, X3*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if<L2, std::is_pointer>, std::tuple<X1, X1 const, X2 const>>)); + } + + using boost::mp11::mp_iota_c; + using boost::mp11::mp_size_t; + + { + int const N = 12; + using L1 = mp_iota_c<N>; + + using R1 = mp_remove_if<L1, is_odd>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_list<mp_size_t<0>, mp_size_t<2>, mp_size_t<4>, mp_size_t<6>, mp_size_t<8>, mp_size_t<10>>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_remove_if_q.cpp b/src/boost/libs/mp11/test/mp_remove_if_q.cpp new file mode 100644 index 000000000..818cc63d7 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_remove_if_q.cpp @@ -0,0 +1,72 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +using boost::mp11::mp_bool; + +struct Q_is_odd +{ + template<class N> using fn = mp_bool<N::value % 2 != 0>; +}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_remove_if_q; + using boost::mp11::mp_quote; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if_q<L1, mp_quote<std::is_const>>, L1>)); + + using L2 = mp_list<X1, X1 const, X1*, X2 const, X2*, X3*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if_q<L2, mp_quote<std::is_volatile>>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if_q<L2, mp_quote<std::is_const>>, mp_list<X1, X1*, X2*, X3*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if_q<L2, mp_quote<std::is_pointer>>, mp_list<X1, X1 const, X2 const>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if_q<L1, mp_quote<std::is_const>>, L1>)); + + using L2 = std::tuple<X1, X1 const, X1*, X2 const, X2*, X3*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if_q<L2, mp_quote<std::is_volatile>>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if_q<L2, mp_quote<std::is_const>>, std::tuple<X1, X1*, X2*, X3*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove_if_q<L2, mp_quote<std::is_pointer>>, std::tuple<X1, X1 const, X2 const>>)); + } + + using boost::mp11::mp_iota_c; + using boost::mp11::mp_size_t; + + { + int const N = 12; + using L1 = mp_iota_c<N>; + + using R1 = mp_remove_if_q<L1, Q_is_odd>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_list<mp_size_t<0>, mp_size_t<2>, mp_size_t<4>, mp_size_t<6>, mp_size_t<8>, mp_size_t<10>>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_rename.cpp b/src/boost/libs/mp11/test/mp_rename.cpp new file mode 100644 index 000000000..3ad751a44 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_rename.cpp @@ -0,0 +1,146 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/list.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +template<class... T> struct X {}; +template<class... T> using Y = X<T...>; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_rename; + using boost::mp11::mp_apply; + + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, mp_list>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, std::tuple>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, X>, X<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, Y>, Y<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L1>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L1>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L1>, X<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L1>, Y<>>)); + + using L2 = mp_list<char>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, mp_list>, mp_list<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, std::tuple>, std::tuple<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, X>, X<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, Y>, Y<char>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L2>, mp_list<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L2>, std::tuple<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L2>, X<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L2>, Y<char>>)); + + using L3 = mp_list<char, double>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, mp_list>, mp_list<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, std::tuple>, std::tuple<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, X>, X<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, Y>, Y<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, std::pair>, std::pair<char, double>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L3>, mp_list<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L3>, std::tuple<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L3>, X<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L3>, Y<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::pair, L3>, std::pair<char, double>>)); + + using L4 = mp_list<int, char, float>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, mp_list>, mp_list<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, std::tuple>, std::tuple<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, X>, X<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, Y>, Y<int, char, float>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L4>, mp_list<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L4>, std::tuple<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L4>, X<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L4>, Y<int, char, float>>)); + + // + + using L5 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, mp_list>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, std::tuple>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, X>, X<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, Y>, Y<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L5>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L5>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L5>, X<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L5>, Y<>>)); + + using L6 = std::tuple<char>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, mp_list>, mp_list<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, std::tuple>, std::tuple<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, X>, X<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, Y>, Y<char>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L6>, mp_list<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L6>, std::tuple<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L6>, X<char>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L6>, Y<char>>)); + + using L7 = std::tuple<char, double>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, mp_list>, mp_list<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, std::tuple>, std::tuple<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, X>, X<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, Y>, Y<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, std::pair>, std::pair<char, double>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L7>, mp_list<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L7>, std::tuple<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L7>, X<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L7>, Y<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::pair, L7>, std::pair<char, double>>)); + + using L8 = std::tuple<int, char, float>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, mp_list>, mp_list<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, std::tuple>, std::tuple<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, X>, X<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, Y>, Y<int, char, float>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L8>, mp_list<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L8>, std::tuple<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L8>, X<int, char, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L8>, Y<int, char, float>>)); + + // + + using L9 = std::pair<char, double>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, mp_list>, mp_list<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, std::tuple>, std::tuple<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, X>, X<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, Y>, Y<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, std::pair>, std::pair<char, double>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L9>, mp_list<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L9>, std::tuple<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L9>, X<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L9>, Y<char, double>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::pair, L9>, std::pair<char, double>>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_repeat.cpp b/src/boost/libs/mp11/test/mp_repeat.cpp new file mode 100644 index 000000000..574b4fe85 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_repeat.cpp @@ -0,0 +1,132 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_repeat; + using boost::mp11::mp_repeat_c; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + using boost::mp11::mp_int; + using boost::mp11::mp_size_t; + + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L1, 0>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L1, 1>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L1, 2>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L1, 3>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L1, 31>, mp_list<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L1, mp_false>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L1, mp_true>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L1, mp_int<2>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L1, mp_int<3>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L1, mp_size_t<31>>, mp_list<>>)); + + using L2 = mp_list<X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L2, 0>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L2, 1>, mp_list<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L2, 2>, mp_list<X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L2, 3>, mp_list<X1, X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L2, 4>, mp_list<X1, X1, X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L2, 5>, mp_list<X1, X1, X1, X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L2, 6>, mp_list<X1, X1, X1, X1, X1, X1>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L2, mp_false>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L2, mp_true>, mp_list<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L2, mp_int<2>>, mp_list<X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L2, mp_int<3>>, mp_list<X1, X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L2, mp_int<4>>, mp_list<X1, X1, X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L2, mp_size_t<5>>, mp_list<X1, X1, X1, X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L2, mp_size_t<6>>, mp_list<X1, X1, X1, X1, X1, X1>>)); + + using L3 = mp_list<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L3, 0>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L3, 1>, mp_list<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L3, 2>, mp_list<X1, X2, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L3, 3>, mp_list<X1, X2, X1, X2, X1, X2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L3, mp_false>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L3, mp_true>, mp_list<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L3, mp_int<2>>, mp_list<X1, X2, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L3, mp_size_t<3>>, mp_list<X1, X2, X1, X2, X1, X2>>)); + + // + + using L4 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L4, 0>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L4, 1>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L4, 2>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L4, 3>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L4, 31>, std::tuple<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L4, mp_false>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L4, mp_true>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L4, mp_int<2>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L4, mp_int<3>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L4, mp_size_t<31>>, std::tuple<>>)); + + using L5 = std::tuple<X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L5, 0>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L5, 1>, std::tuple<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L5, 2>, std::tuple<X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L5, 3>, std::tuple<X1, X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L5, 4>, std::tuple<X1, X1, X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L5, 5>, std::tuple<X1, X1, X1, X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L5, 6>, std::tuple<X1, X1, X1, X1, X1, X1>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L5, mp_false>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L5, mp_true>, std::tuple<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L5, mp_int<2>>, std::tuple<X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L5, mp_int<3>>, std::tuple<X1, X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L5, mp_int<4>>, std::tuple<X1, X1, X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L5, mp_size_t<5>>, std::tuple<X1, X1, X1, X1, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L5, mp_size_t<6>>, std::tuple<X1, X1, X1, X1, X1, X1>>)); + + using L6 = std::tuple<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L6, 0>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L6, 1>, std::tuple<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L6, 2>, std::tuple<X1, X2, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L6, 3>, std::tuple<X1, X2, X1, X2, X1, X2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L6, mp_false>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L6, mp_true>, std::tuple<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L6, mp_int<2>>, std::tuple<X1, X2, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L6, mp_size_t<3>>, std::tuple<X1, X2, X1, X2, X1, X2>>)); + + // + + using L7 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat_c<L7, 1>, std::pair<X1, X2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_repeat<L7, mp_true>, std::pair<X1, X2>>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_replace.cpp b/src/boost/libs/mp11/test/mp_replace.cpp new file mode 100644 index 000000000..36a0ac6f2 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_replace.cpp @@ -0,0 +1,61 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_replace; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace<L1, void, int[]>, L1>)); + + using L2 = mp_list<X1, X2, X3, X2, X3, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace<L2, void, int[]>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace<L2, X1, int[]>, mp_list<int[], X2, X3, X2, X3, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace<L2, X2, int[]>, mp_list<X1, int[], X3, int[], X3, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace<L2, X3, int[]>, mp_list<X1, X2, int[], X2, int[], int[]>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace<L1, void, int[]>, L1>)); + + using L2 = std::tuple<X1, X2, X3, X2, X3, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace<L2, void, int[]>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace<L2, X1, int[]>, std::tuple<int[], X2, X3, X2, X3, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace<L2, X2, int[]>, std::tuple<X1, int[], X3, int[], X3, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace<L2, X3, int[]>, std::tuple<X1, X2, int[], X2, int[], int[]>>)); + } + + { + using L2 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace<L2, void, int[]>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace<L2, X1, int[]>, std::pair<int[], X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace<L2, X2, int[]>, std::pair<X1, int[]>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_replace_at.cpp b/src/boost/libs/mp11/test/mp_replace_at.cpp new file mode 100644 index 000000000..dfd66e114 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_replace_at.cpp @@ -0,0 +1,64 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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 + + +#if defined(_MSC_VER) +#pragma warning( disable: 4804 ) // '>=': unsafe use of type 'bool' in operation +#endif + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_replace_at; + using boost::mp11::mp_int; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + { + using L = mp_list<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<0>, void>, mp_list<void, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<1>, void>, mp_list<X1, void, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<2>, void>, mp_list<X1, X2, void, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<3>, void>, mp_list<X1, X2, X3, void, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<4>, void>, mp_list<X1, X2, X3, X4, void>>)); + } + + { + using L = std::tuple<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<0>, void>, std::tuple<void, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<1>, void>, std::tuple<X1, void, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<2>, void>, std::tuple<X1, X2, void, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<3>, void>, std::tuple<X1, X2, X3, void, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_int<4>, void>, std::tuple<X1, X2, X3, X4, void>>)); + } + + { + using L = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_false, void>, std::pair<void, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at<L, mp_true, void>, std::pair<X1, void>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_replace_at_c.cpp b/src/boost/libs/mp11/test/mp_replace_at_c.cpp new file mode 100644 index 000000000..5a5bd54b1 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_replace_at_c.cpp @@ -0,0 +1,56 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_replace_at_c; + + { + using L = mp_list<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 0, void>, mp_list<void, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 1, void>, mp_list<X1, void, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 2, void>, mp_list<X1, X2, void, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 3, void>, mp_list<X1, X2, X3, void, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 4, void>, mp_list<X1, X2, X3, X4, void>>)); + } + + { + using L = std::tuple<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 0, void>, std::tuple<void, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 1, void>, std::tuple<X1, void, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 2, void>, std::tuple<X1, X2, void, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 3, void>, std::tuple<X1, X2, X3, void, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 4, void>, std::tuple<X1, X2, X3, X4, void>>)); + } + + { + using L = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 0, void>, std::pair<void, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 1, void>, std::pair<X1, void>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_replace_front.cpp b/src/boost/libs/mp11/test/mp_replace_front.cpp new file mode 100644 index 000000000..07156262e --- /dev/null +++ b/src/boost/libs/mp11/test/mp_replace_front.cpp @@ -0,0 +1,80 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_replace_front; + using boost::mp11::mp_replace_first; + + { + using L1 = mp_list<X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L1, void>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L1, void>, mp_list<void>>)); + + using L2 = mp_list<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L2, void>, mp_list<void, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L2, void>, mp_list<void, X2>>)); + + using L3 = mp_list<X1, X2, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L3, void>, mp_list<void, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L3, void>, mp_list<void, X2, X3>>)); + + using L4 = mp_list<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L4, void>, mp_list<void, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L4, void>, mp_list<void, X2, X3, X4>>)); + } + + { + using L1 = std::tuple<X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L1, void>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L1, void>, std::tuple<void>>)); + + using L2 = std::tuple<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L2, void>, std::tuple<void, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L2, void>, std::tuple<void, X2>>)); + + using L3 = std::tuple<X1, X2, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L3, void>, std::tuple<void, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L3, void>, std::tuple<void, X2, X3>>)); + + using L4 = std::tuple<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L4, void>, std::tuple<void, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L4, void>, std::tuple<void, X2, X3, X4>>)); + } + + { + using L2 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L2, void>, std::pair<void, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L2, void>, std::pair<void, X2>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_replace_if.cpp b/src/boost/libs/mp11/test/mp_replace_if.cpp new file mode 100644 index 000000000..98845d3f0 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_replace_if.cpp @@ -0,0 +1,57 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_replace_if; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if<L1, std::is_const, void>, L1>)); + + using L2 = mp_list<X1, X1 const, X1*, X1 const, X1*, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if<L2, std::is_volatile, void>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if<L2, std::is_const, void>, mp_list<X1, void, X1*, void, X1*, X1*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if<L2, std::is_pointer, void>, mp_list<X1, X1 const, void, X1 const, void, void>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if<L1, std::is_const, void>, L1>)); + + using L2 = std::tuple<X1, X1 const, X1*, X1 const, X1*, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if<L2, std::is_volatile, void>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if<L2, std::is_const, void>, std::tuple<X1, void, X1*, void, X1*, X1*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if<L2, std::is_pointer, void>, std::tuple<X1, X1 const, void, X1 const, void, void>>)); + } + + { + using L2 = std::pair<X1 const, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if<L2, std::is_volatile, void>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if<L2, std::is_const, void>, std::pair<void, X1*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if<L2, std::is_pointer, void>, std::pair<X1 const, void>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_replace_if_q.cpp b/src/boost/libs/mp11/test/mp_replace_if_q.cpp new file mode 100644 index 000000000..a692673fc --- /dev/null +++ b/src/boost/libs/mp11/test/mp_replace_if_q.cpp @@ -0,0 +1,59 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_replace_if_q; + using boost::mp11::mp_quote; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if_q<L1, mp_quote<std::is_const>, void>, L1>)); + + using L2 = mp_list<X1, X1 const, X1*, X1 const, X1*, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if_q<L2, mp_quote<std::is_volatile>, void>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if_q<L2, mp_quote<std::is_const>, void>, mp_list<X1, void, X1*, void, X1*, X1*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if_q<L2, mp_quote<std::is_pointer>, void>, mp_list<X1, X1 const, void, X1 const, void, void>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if_q<L1, mp_quote<std::is_const>, void>, L1>)); + + using L2 = std::tuple<X1, X1 const, X1*, X1 const, X1*, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if_q<L2, mp_quote<std::is_volatile>, void>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if_q<L2, mp_quote<std::is_const>, void>, std::tuple<X1, void, X1*, void, X1*, X1*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if_q<L2, mp_quote<std::is_pointer>, void>, std::tuple<X1, X1 const, void, X1 const, void, void>>)); + } + + { + using L2 = std::pair<X1 const, X1*>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if_q<L2, mp_quote<std::is_volatile>, void>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if_q<L2, mp_quote<std::is_const>, void>, std::pair<void, X1*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_if_q<L2, mp_quote<std::is_pointer>, void>, std::pair<X1 const, void>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_replace_second.cpp b/src/boost/libs/mp11/test/mp_replace_second.cpp new file mode 100644 index 000000000..deaab1b24 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_replace_second.cpp @@ -0,0 +1,62 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_replace_second; + + { + using L2 = mp_list<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_second<L2, void>, mp_list<X1, void>>)); + + using L3 = mp_list<X1, X2, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_second<L3, void>, mp_list<X1, void, X3>>)); + + using L4 = mp_list<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_second<L4, void>, mp_list<X1, void, X3, X4>>)); + } + + { + using L2 = std::tuple<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_second<L2, void>, std::tuple<X1, void>>)); + + using L3 = std::tuple<X1, X2, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_second<L3, void>, std::tuple<X1, void, X3>>)); + + using L4 = std::tuple<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_second<L4, void>, std::tuple<X1, void, X3, X4>>)); + } + + { + using L2 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_second<L2, void>, std::pair<X1, void>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_replace_third.cpp b/src/boost/libs/mp11/test/mp_replace_third.cpp new file mode 100644 index 000000000..c1b53b53b --- /dev/null +++ b/src/boost/libs/mp11/test/mp_replace_third.cpp @@ -0,0 +1,48 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_replace_third; + + { + using L3 = mp_list<X1, X2, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_third<L3, void>, mp_list<X1, X2, void>>)); + + using L4 = mp_list<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_third<L4, void>, mp_list<X1, X2, void, X4>>)); + } + + { + using L3 = std::tuple<X1, X2, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_third<L3, void>, std::tuple<X1, X2, void>>)); + + using L4 = std::tuple<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_third<L4, void>, std::tuple<X1, X2, void, X4>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_reverse.cpp b/src/boost/libs/mp11/test/mp_reverse.cpp new file mode 100644 index 000000000..221440db6 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_reverse.cpp @@ -0,0 +1,94 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; +struct X6 {}; +struct X7 {}; +struct X8 {}; +struct X9 {}; +struct X10 {}; +struct X11 {}; +struct X12 {}; + +using boost::mp11::mp_plus; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_reverse; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1>>, mp_list<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2>>, mp_list<X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3>>, mp_list<X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4>>, mp_list<X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5>>, mp_list<X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6>>, mp_list<X6, X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6, X7>>, mp_list<X7, X6, X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6, X7, X8>>, mp_list<X8, X7, X6, X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6, X7, X8, X9>>, mp_list<X9, X8, X7, X6, X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6, X7, X8, X9, X10>>, mp_list<X10, X9, X8, X7, X6, X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11>>, mp_list<X11, X10, X9, X8, X7, X6, X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<mp_list<X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12>>, mp_list<X12, X11, X10, X9, X8, X7, X6, X5, X4, X3, X2, X1>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1>>, std::tuple<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2>>, std::tuple<X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3>>, std::tuple<X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4>>, std::tuple<X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5>>, std::tuple<X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6>>, std::tuple<X6, X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6, X7>>, std::tuple<X7, X6, X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6, X7, X8>>, std::tuple<X8, X7, X6, X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6, X7, X8, X9>>, std::tuple<X9, X8, X7, X6, X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6, X7, X8, X9, X10>>, std::tuple<X10, X9, X8, X7, X6, X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11>>, std::tuple<X11, X10, X9, X8, X7, X6, X5, X4, X3, X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::tuple<X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12>>, std::tuple<X12, X11, X10, X9, X8, X7, X6, X5, X4, X3, X2, X1>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse<std::pair<X1, X2>>, std::pair<X2, X1>>)); + } + + using boost::mp11::mp_iota_c; + using boost::mp11::mp_size_t; + using boost::mp11::mp_transform; + using boost::mp11::mp_fill; + + { + int const N = 37; + + using L = mp_iota_c<N>; + + using R1 = mp_reverse<L>; + using R2 = mp_reverse<R1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, L>)); + + using R3 = mp_transform<mp_plus, R1, R2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R3, mp_fill<L, mp_size_t<N-1>>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_reverse_fold.cpp b/src/boost/libs/mp11/test/mp_reverse_fold.cpp new file mode 100644 index 000000000..75c308993 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_reverse_fold.cpp @@ -0,0 +1,81 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +template<class T1, class T2> struct F {}; + +using boost::mp11::mp_push_back; +using boost::mp11::mp_push_front; + +template<class T, class L> using rev_push_back = mp_push_back<L, T>; +template<class T, class L> using rev_push_front = mp_push_front<L, T>; + +using boost::mp11::mp_plus; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_reverse_fold; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<mp_list<>, void, F>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<mp_list<X1>, void, F>, F<X1, void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<mp_list<X1, X2>, void, F>, F<X1, F<X2, void>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<mp_list<X1, X2, X3>, void, F>, F<X1, F<X2, F<X3, void>>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<mp_list<X1, X2, X3, X4>, void, F>, F<X1, F<X2, F<X3, F<X4, void>>>>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<>, void, F>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<X1>, void, F>, F<X1, void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<X1, X2>, void, F>, F<X1, F<X2, void>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<X1, X2, X3>, void, F>, F<X1, F<X2, F<X3, void>>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<X1, X2, X3, X4>, void, F>, F<X1, F<X2, F<X3, F<X4, void>>>>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<X1, X2, X3, X4>, mp_list<>, rev_push_back>, mp_list<X4, X3, X2, X1>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold<std::tuple<X1, X2, X3, X4>, mp_list<>, rev_push_front>, mp_list<X1, X2, X3, X4>>)); + } + + using boost::mp11::mp_iota_c; + using boost::mp11::mp_reverse; + using boost::mp11::mp_size_t; + + { + int const N = 37; + + using L = mp_iota_c<N>; + + using R1 = mp_reverse_fold<L, mp_list<>, rev_push_front>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, L>)); + + using R2 = mp_reverse_fold<L, mp_list<>, rev_push_back>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, mp_reverse<L>>)); + + using R3 = mp_reverse_fold<L, mp_size_t<0>, mp_plus>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R3, mp_size_t<N*(N-1)/2>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_reverse_fold_q.cpp b/src/boost/libs/mp11/test/mp_reverse_fold_q.cpp new file mode 100644 index 000000000..09071a8d1 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_reverse_fold_q.cpp @@ -0,0 +1,66 @@ + +// Copyright 2015-2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/bind.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +template<class T1, class T2> struct F {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_reverse_fold_q; + using boost::mp11::mp_quote; + + using Q = mp_quote<F>; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<mp_list<>, void, Q>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<mp_list<X1>, void, Q>, F<X1, void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<mp_list<X1, X2>, void, Q>, F<X1, F<X2, void>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<mp_list<X1, X2, X3>, void, Q>, F<X1, F<X2, F<X3, void>>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<mp_list<X1, X2, X3, X4>, void, Q>, F<X1, F<X2, F<X3, F<X4, void>>>>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<>, void, Q>, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<X1>, void, Q>, F<X1, void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<X1, X2>, void, Q>, F<X1, F<X2, void>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<X1, X2, X3>, void, Q>, F<X1, F<X2, F<X3, void>>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<X1, X2, X3, X4>, void, Q>, F<X1, F<X2, F<X3, F<X4, void>>>>>)); + } + + using boost::mp11::mp_bind; + using boost::mp11::_1; + using boost::mp11::_2; + + using boost::mp11::mp_push_back; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<X1, X2, X3, X4>, mp_list<>, mp_bind<mp_push_back, _2, _1>>, mp_list<X4, X3, X2, X1>>)); + } + + using boost::mp11::mp_push_front; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_reverse_fold_q<std::tuple<X1, X2, X3, X4>, mp_list<>, mp_bind<mp_push_front, _2, _1>>, mp_list<X1, X2, X3, X4>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_rotate_left.cpp b/src/boost/libs/mp11/test/mp_rotate_left.cpp new file mode 100644 index 000000000..0735eed81 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_rotate_left.cpp @@ -0,0 +1,136 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_rotate_left; + using boost::mp11::mp_rotate_left_c; + using boost::mp11::mp_size_t; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 1>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 2>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 3>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 4>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<0>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<1>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<2>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<3>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<4>>, L1>)); + + using L2 = mp_list<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 0>, mp_list<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 1>, mp_list<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 2>, mp_list<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 3>, mp_list<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 4>, mp_list<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 5>, mp_list<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 6>, mp_list<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 7>, mp_list<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 8>, mp_list<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 9>, mp_list<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 10>, mp_list<X1, X2, X3, X4, X5>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<0>>, mp_list<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<1>>, mp_list<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<2>>, mp_list<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<3>>, mp_list<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<4>>, mp_list<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<5>>, mp_list<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<6>>, mp_list<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<7>>, mp_list<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<8>>, mp_list<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<9>>, mp_list<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<10>>, mp_list<X1, X2, X3, X4, X5>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 1>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 2>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 3>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 4>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<0>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<1>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<2>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<3>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<4>>, L1>)); + + using L2 = std::tuple<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 0>, std::tuple<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 1>, std::tuple<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 2>, std::tuple<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 3>, std::tuple<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 4>, std::tuple<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 5>, std::tuple<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 6>, std::tuple<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 7>, std::tuple<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 8>, std::tuple<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 9>, std::tuple<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L2, 10>, std::tuple<X1, X2, X3, X4, X5>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<0>>, std::tuple<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<1>>, std::tuple<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<2>>, std::tuple<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<3>>, std::tuple<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<4>>, std::tuple<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<5>>, std::tuple<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<6>>, std::tuple<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<7>>, std::tuple<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<8>>, std::tuple<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<9>>, std::tuple<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L2, mp_size_t<10>>, std::tuple<X1, X2, X3, X4, X5>>)); + } + + { + using L1 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 2>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 4>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 1>, std::pair<X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 3>, std::pair<X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left_c<L1, 5>, std::pair<X2, X1>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<0>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<2>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<4>>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<1>>, std::pair<X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<3>>, std::pair<X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_left<L1, mp_size_t<5>>, std::pair<X2, X1>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_rotate_right.cpp b/src/boost/libs/mp11/test/mp_rotate_right.cpp new file mode 100644 index 000000000..14ac5d4cd --- /dev/null +++ b/src/boost/libs/mp11/test/mp_rotate_right.cpp @@ -0,0 +1,136 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_rotate_right; + using boost::mp11::mp_rotate_right_c; + using boost::mp11::mp_size_t; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 1>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 2>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 3>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 4>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<0>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<1>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<2>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<3>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<4>>, L1>)); + + using L2 = mp_list<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 0>, mp_list<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 1>, mp_list<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 2>, mp_list<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 3>, mp_list<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 4>, mp_list<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 5>, mp_list<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 6>, mp_list<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 7>, mp_list<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 8>, mp_list<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 9>, mp_list<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 10>, mp_list<X1, X2, X3, X4, X5>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<0>>, mp_list<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<1>>, mp_list<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<2>>, mp_list<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<3>>, mp_list<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<4>>, mp_list<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<5>>, mp_list<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<6>>, mp_list<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<7>>, mp_list<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<8>>, mp_list<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<9>>, mp_list<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<10>>, mp_list<X1, X2, X3, X4, X5>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 1>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 2>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 3>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 4>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<0>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<1>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<2>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<3>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<4>>, L1>)); + + using L2 = std::tuple<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 0>, std::tuple<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 1>, std::tuple<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 2>, std::tuple<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 3>, std::tuple<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 4>, std::tuple<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 5>, std::tuple<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 6>, std::tuple<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 7>, std::tuple<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 8>, std::tuple<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 9>, std::tuple<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L2, 10>, std::tuple<X1, X2, X3, X4, X5>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<0>>, std::tuple<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<1>>, std::tuple<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<2>>, std::tuple<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<3>>, std::tuple<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<4>>, std::tuple<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<5>>, std::tuple<X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<6>>, std::tuple<X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<7>>, std::tuple<X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<8>>, std::tuple<X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<9>>, std::tuple<X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L2, mp_size_t<10>>, std::tuple<X1, X2, X3, X4, X5>>)); + } + + { + using L1 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 2>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 4>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 1>, std::pair<X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 3>, std::pair<X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right_c<L1, 5>, std::pair<X2, X1>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<0>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<2>>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<4>>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<1>>, std::pair<X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<3>>, std::pair<X2, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rotate_right<L1, mp_size_t<5>>, std::pair<X2, X1>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_same.cpp b/src/boost/libs/mp11/test/mp_same.cpp new file mode 100644 index 000000000..912b54e08 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_same.cpp @@ -0,0 +1,51 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/detail/config.hpp> + +#if BOOST_MP11_MSVC +# pragma warning( disable: 4503 ) // decorated name length exceeded +#endif + +#include <boost/mp11/function.hpp> +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_same; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void, void, void>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, int>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, int>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void, int>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_same<void, void, void, void, int>, mp_false>)); + + using boost::mp11::mp_repeat_c; + using boost::mp11::mp_list; + using boost::mp11::mp_apply; + + int const N = 1089; + + using L = mp_repeat_c<mp_list<void>, N>; + using R = mp_apply<mp_same, L>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<R, mp_true>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_second.cpp b/src/boost/libs/mp11/test/mp_second.cpp new file mode 100644 index 000000000..f585bea49 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_second.cpp @@ -0,0 +1,34 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/list.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_second; + + using L1 = mp_list<void, char[]>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_second<L1>, char[]>)); + + using L2 = mp_list<int[], void, float>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_second<L2>, void>)); + + using L3 = std::tuple<int, float>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_second<L3>, float>)); + + using L4 = std::pair<char, double>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_second<L4>, double>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_set_contains.cpp b/src/boost/libs/mp11/test/mp_set_contains.cpp new file mode 100644 index 000000000..d53314613 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_set_contains.cpp @@ -0,0 +1,83 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/set.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_set_contains; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L1, void>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L1, int>, mp_false>)); + + using L2 = mp_list<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L2, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L2, int>, mp_false>)); + + using L3 = mp_list<void, int>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, int>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, void const>, mp_false>)); + + using L4 = mp_list<void, int, char[]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, int>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, char[]>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, void const>, mp_false>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L1, void>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L1, int>, mp_false>)); + + using L2 = std::tuple<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L2, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L2, int>, mp_false>)); + + using L3 = std::tuple<void, int>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, int>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, void const>, mp_false>)); + + using L4 = std::tuple<void, int, char[]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, int>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, char[]>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L4, void const>, mp_false>)); + } + + { + using L3 = std::pair<void, int>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, int>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_contains<L3, void const>, mp_false>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_set_difference.cpp b/src/boost/libs/mp11/test/mp_set_difference.cpp new file mode 100644 index 000000000..9e21f4005 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_set_difference.cpp @@ -0,0 +1,48 @@ + +// Copyright 2019 Peter Dimov. +// +// 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/mp11/set.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_set_difference; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<mp_list<>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<mp_list<void>>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<mp_list<void, int>>, mp_list<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<mp_list<void, int, float>>, mp_list<void, int, float>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<std::tuple<>, std::pair<float, int>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<std::tuple<void>, std::pair<float, int>>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<std::tuple<void, int>, std::pair<float, int>>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<std::tuple<void, int, float>, std::pair<float, int>>, std::tuple<void>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<mp_list<void, int, float>, std::tuple<>>, mp_list<void, int, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<mp_list<void, int, float>, std::tuple<int>>, mp_list<void, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<mp_list<void, int, float>, std::tuple<float, void>>, mp_list<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<mp_list<void, int, float>, std::tuple<float, void, int>>, mp_list<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<std::tuple<>, mp_list<>, std::pair<float, int>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<std::tuple<void>, mp_list<double>, std::pair<float, int>>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<std::tuple<void, int>, mp_list<double, int>, std::pair<float, int>>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<std::tuple<void, int, float>, mp_list<double, int, float>, std::pair<float, int>>, std::tuple<void>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<mp_list<void, int, float, double>, std::pair<double, void>, std::tuple<>>, mp_list<int, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<mp_list<void, int, float, double>, std::pair<double, void>, std::tuple<int>>, mp_list<float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<mp_list<void, int, float, double>, std::pair<double, void>, std::tuple<float, void>>, mp_list<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_difference<mp_list<void, int, float, double>, std::pair<double, void>, std::tuple<float, void, int>>, mp_list<>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_set_difference_sf.cpp b/src/boost/libs/mp11/test/mp_set_difference_sf.cpp new file mode 100644 index 000000000..ddcb63d0e --- /dev/null +++ b/src/boost/libs/mp11/test/mp_set_difference_sf.cpp @@ -0,0 +1,33 @@ + +// Copyright 2019 Peter Dimov. +// +// 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/mp11/set.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> + +int main() +{ + using boost::mp11::mp_set_difference; + using boost::mp11::mp_valid; + using boost::mp11::mp_list; + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_difference>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_difference, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_difference, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_difference, void, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_difference, void, void, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_difference, void, void, void, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_difference, mp_list<>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_difference, mp_list<>, mp_list<>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_difference, mp_list<>, mp_list<>, mp_list<>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_difference, mp_list<>, mp_list<>, mp_list<>, mp_list<>, void>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_set_intersection.cpp b/src/boost/libs/mp11/test/mp_set_intersection.cpp new file mode 100644 index 000000000..d9e16dde1 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_set_intersection.cpp @@ -0,0 +1,49 @@ + +// Copyright 2019 Peter Dimov. +// +// 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/mp11/set.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_set_intersection; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<mp_list<>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<mp_list<void>>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<mp_list<void, int>>, mp_list<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<mp_list<void, int, float>>, mp_list<void, int, float>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<std::tuple<>, std::pair<float, int>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<std::tuple<void>, std::pair<float, int>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<std::tuple<void, int>, std::pair<float, int>>, std::tuple<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<std::tuple<void, int, float>, std::pair<float, int>>, std::tuple<int, float>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<mp_list<void, int, float>, std::tuple<>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<mp_list<void, int, float>, std::tuple<int>>, mp_list<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<mp_list<void, int, float>, std::tuple<float, void>>, mp_list<void, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<mp_list<void, int, float>, std::tuple<float, void, int>>, mp_list<void, int, float>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<std::tuple<>, mp_list<>, std::pair<float, int>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<std::tuple<void>, mp_list<double>, std::pair<float, int>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<std::tuple<void, int>, mp_list<double, int>, std::pair<float, int>>, std::tuple<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<std::tuple<void, int, float>, mp_list<double, int, float>, std::pair<float, int>>, std::tuple<int, float>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<mp_list<void, int, float, double>, std::pair<double, void>, std::tuple<>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<mp_list<void, int, float, double>, std::pair<double, void>, std::tuple<int>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<mp_list<void, int, float, double>, std::pair<double, void>, std::tuple<float, void>>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_intersection<mp_list<void, int, float, double>, std::pair<double, void>, std::tuple<float, void, int>>, mp_list<void>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_set_intersection_sf.cpp b/src/boost/libs/mp11/test/mp_set_intersection_sf.cpp new file mode 100644 index 000000000..21af2ef53 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_set_intersection_sf.cpp @@ -0,0 +1,32 @@ + +// Copyright 2019 Peter Dimov. +// +// 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/mp11/set.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> + +int main() +{ + using boost::mp11::mp_set_intersection; + using boost::mp11::mp_valid; + using boost::mp11::mp_list; + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_intersection, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_intersection, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_intersection, void, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_intersection, void, void, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_intersection, void, void, void, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_intersection, mp_list<>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_intersection, mp_list<>, mp_list<>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_intersection, mp_list<>, mp_list<>, mp_list<>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_intersection, mp_list<>, mp_list<>, mp_list<>, mp_list<>, void>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_set_push_back.cpp b/src/boost/libs/mp11/test/mp_set_push_back.cpp new file mode 100644 index 000000000..279140e0c --- /dev/null +++ b/src/boost/libs/mp11/test/mp_set_push_back.cpp @@ -0,0 +1,122 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/set.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_set_push_back; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, int>, mp_list<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void, int>, mp_list<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void, int, char[]>, mp_list<void, int, char[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void, int, void, int, void, int>, mp_list<void, int>>)); + } + + { + using L2 = mp_list<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, void>, L2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, int>, mp_list<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, int, void>, mp_list<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, int, int, int, void, void, void>, mp_list<void, int>>)); + } + + { + using L3 = mp_list<void, int>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, void>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, int>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, int, int, int, void, void, void>, L3>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, void const>, mp_list<void, int, void const>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, int, char[], int, char[], void, char[], void, char[]>, mp_list<void, int, char[]>>)); + } + + { + using L4 = mp_list<void, int, char[]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, int>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, char[]>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void, int, char[], void, int, char[]>, L4>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void const>, mp_list<void, int, char[], void const>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void const, int const, char const[]>, mp_list<void, int, char[], void const, int const, char const[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void, void const, int, int const, char[], char const[]>, mp_list<void, int, char[], void const, int const, char const[]>>)); + } + + // + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, int>, std::tuple<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void, int>, std::tuple<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void, int, char[]>, std::tuple<void, int, char[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L1, void, int, void, int, void, int>, std::tuple<void, int>>)); + } + + { + using L2 = std::tuple<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, void>, L2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, int>, std::tuple<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, int, void>, std::tuple<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L2, int, int, int, void, void, void>, std::tuple<void, int>>)); + } + + { + using L3 = std::tuple<void, int>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, void>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, int>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, int, int, int, void, void, void>, L3>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, void const>, std::tuple<void, int, void const>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L3, int, char[], int, char[], void, char[], void, char[]>, std::tuple<void, int, char[]>>)); + } + + { + using L4 = std::tuple<void, int, char[]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, int>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, char[]>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void, int, char[], void, int, char[]>, L4>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void const>, std::tuple<void, int, char[], void const>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void const, int const, char const[]>, std::tuple<void, int, char[], void const, int const, char const[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_back<L4, void, void const, int, int const, char[], char const[]>, std::tuple<void, int, char[], void const, int const, char const[]>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_set_push_front.cpp b/src/boost/libs/mp11/test/mp_set_push_front.cpp new file mode 100644 index 000000000..a027ac328 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_set_push_front.cpp @@ -0,0 +1,124 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/set.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_set_push_front; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, int>, mp_list<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void, int>, mp_list<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void, int, char[]>, mp_list<void, int, char[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void, int, void, int, void, int>, mp_list<void, int>>)); + } + + { + using L2 = mp_list<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, void>, L2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, int>, mp_list<int, void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, void, int>, mp_list<int, void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, void, void, void, int, int, int>, mp_list<int, void>>)); + } + + { + using L3 = mp_list<void, int>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, void>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, int>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, int, int, int, void, void, void>, L3>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, void const>, mp_list<void const, void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, void const, int const>, mp_list<void const, int const, void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, int, char[], int, char[], void, char[], void, char[]>, mp_list<char[], void, int>>)); + } + + { + using L4 = mp_list<void, int, char[]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, int>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, char[]>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void, int, char[], void, int, char[]>, L4>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void const>, mp_list<void const, void, int, char[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void const, int const, char const[]>, mp_list<void const, int const, char const[], void, int, char[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void, void const, int, int const, char[], char const[]>, mp_list<void const, int const, char const[], void, int, char[]>>)); + } + + // + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1>, L1>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, int>, std::tuple<int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void, int>, std::tuple<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void, int, char[]>, std::tuple<void, int, char[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L1, void, int, void, int, void, int>, std::tuple<void, int>>)); + } + + { + using L2 = std::tuple<void>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2>, L2>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, void>, L2>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, int>, std::tuple<int, void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, void, int>, std::tuple<int, void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L2, void, void, void, int, int, int>, std::tuple<int, void>>)); + } + + { + using L3 = std::tuple<void, int>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, void>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, int>, L3>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, int, int, int, void, void, void>, L3>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, void const>, std::tuple<void const, void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, void const, int const>, std::tuple<void const, int const, void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L3, int, char[], int, char[], void, char[], void, char[]>, std::tuple<char[], void, int>>)); + } + + { + using L4 = std::tuple<void, int, char[]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, int>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, char[]>, L4>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void, int, char[], void, int, char[]>, L4>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void const>, std::tuple<void const, void, int, char[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void const, int const, char const[]>, std::tuple<void const, int const, char const[], void, int, char[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_push_front<L4, void, void const, int, int const, char[], char const[]>, std::tuple<void const, int const, char const[], void, int, char[]>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_set_union.cpp b/src/boost/libs/mp11/test/mp_set_union.cpp new file mode 100644 index 000000000..0811d293b --- /dev/null +++ b/src/boost/libs/mp11/test/mp_set_union.cpp @@ -0,0 +1,55 @@ + +// Copyright 2019 Peter Dimov. +// +// 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/mp11/set.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_set_union; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<>, mp_list<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<mp_list<>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<mp_list<void>>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<mp_list<void, int>>, mp_list<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<mp_list<void, int, float>>, mp_list<void, int, float>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<std::tuple<>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<std::tuple<void>>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<std::tuple<void, int>>, std::tuple<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<std::tuple<void, int, float>>, std::tuple<void, int, float>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<mp_list<>, std::pair<float, int>>, mp_list<float, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<mp_list<void>, std::pair<float, int>>, mp_list<void, float, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<mp_list<void, int>, std::pair<float, int>>, mp_list<void, int, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<mp_list<void, int, float>, std::pair<float, int>>, mp_list<void, int, float>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<std::tuple<>, mp_list<>, std::pair<float, int>>, std::tuple<float, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<std::tuple<void>, mp_list<double>, std::pair<float, int>>, std::tuple<void, double, float, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<std::tuple<void, int>, mp_list<double, int>, std::pair<float, int>>, std::tuple<void, int, double, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<std::tuple<void, int, float>, mp_list<double, int, float>, std::pair<float, int>>, std::tuple<void, int, float, double>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<mp_list<>, std::pair<float, float>, std::pair<int, int>>, mp_list<float, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<mp_list<void>, std::pair<float, float>, std::pair<int, int>>, mp_list<void, float, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<mp_list<void, int>, std::pair<float, float>, std::pair<int, int>>, mp_list<void, int, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<mp_list<void, int, float>, std::pair<float, float>, std::pair<int, int>>, mp_list<void, int, float>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<std::tuple<>, std::pair<float, float>, std::pair<int, int>, std::pair<void, void>>, std::tuple<float, int, void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<std::tuple<void>, std::pair<float, float>, std::pair<int, int>, std::pair<void, void>>, std::tuple<void, float, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<std::tuple<void, int>, std::pair<float, float>, std::pair<int, int>, std::pair<void, void>>, std::tuple<void, int, float>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_set_union<std::tuple<void, int, float>, std::pair<float, float>, std::pair<int, int>, std::pair<void, void>>, std::tuple<void, int, float>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_set_union_sf.cpp b/src/boost/libs/mp11/test/mp_set_union_sf.cpp new file mode 100644 index 000000000..badf79332 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_set_union_sf.cpp @@ -0,0 +1,32 @@ + +// Copyright 2019 Peter Dimov. +// +// 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/mp11/set.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> + +int main() +{ + using boost::mp11::mp_set_union; + using boost::mp11::mp_valid; + using boost::mp11::mp_list; + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_union, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_union, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_union, void, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_union, void, void, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_union, void, void, void, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_union, mp_list<>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_union, mp_list<>, mp_list<>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_union, mp_list<>, mp_list<>, mp_list<>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_set_union, mp_list<>, mp_list<>, mp_list<>, mp_list<>, void>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_similar.cpp b/src/boost/libs/mp11/test/mp_similar.cpp new file mode 100644 index 000000000..140c4edaa --- /dev/null +++ b/src/boost/libs/mp11/test/mp_similar.cpp @@ -0,0 +1,50 @@ + +// Copyright 2019 Peter Dimov. +// +// 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/mp11/function.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +template<class> class X; +template<class...> class Y; + +int main() +{ + using boost::mp11::mp_similar; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<void, void, void, void>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<void, void, void, void, void>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<void, int>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<void, void, int>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<void, void, void, int>, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<void, void, void, void, int>, mp_false>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<X<void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<X<void>, X<void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<X<void>, X<int>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<X<void>, X<void>, X<void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<X<void>, X<int>, X<float>>, mp_true>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<Y<>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<Y<>, Y<>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<Y<>, Y<void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<Y<>, Y<>, Y<>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<Y<>, Y<void>, Y<void, void>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<Y<>, Y<>, Y<>, Y<>>, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_similar<Y<>, Y<void>, Y<void, void>, Y<void, void, void>>, mp_true>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_size.cpp b/src/boost/libs/mp11/test/mp_size.cpp new file mode 100644 index 000000000..a8ea75f78 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_size.cpp @@ -0,0 +1,48 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_size; + using boost::mp11::mp_size_t; + + using L1 = mp_list<>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_size<L1>, mp_size_t<0>>)); + + using L2 = mp_list<void>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_size<L2>, mp_size_t<1>>)); + + using L3 = mp_list<int[], void, float>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_size<L3>, mp_size_t<3>>)); + + using L4 = std::tuple<>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_size<L4>, mp_size_t<0>>)); + + using L5 = std::tuple<int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_size<L5>, mp_size_t<1>>)); + + using L6 = std::tuple<int, int>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_size<L6>, mp_size_t<2>>)); + + using L7 = std::pair<char, double>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_size<L7>, mp_size_t<2>>)); + + using L8 = std::add_const<void()>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_size<L8>, mp_size_t<1>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_sort.cpp b/src/boost/libs/mp11/test/mp_sort.cpp new file mode 100644 index 000000000..d6b677f48 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_sort.cpp @@ -0,0 +1,55 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +using boost::mp11::mp_bool; + +template<class T, class U> using sizeof_less = mp_bool<(sizeof(T) < sizeof(U))>; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_sort; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort<L1, sizeof_less>, L1>)); + + using L2 = mp_list<char[2], char[4], char[3], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort<L2, sizeof_less>, mp_list<char[1], char[2], char[3], char[4]>>)); + + using L3 = mp_list<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort<L3, sizeof_less>, mp_list<char[1], char[1], char[2], char[2], char[2], char[3], char[4]>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort<L1, sizeof_less>, L1>)); + + using L2 = std::tuple<char[2], char[4], char[3], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort<L2, sizeof_less>, std::tuple<char[1], char[2], char[3], char[4]>>)); + + using L3 = std::tuple<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort<L3, sizeof_less>, std::tuple<char[1], char[1], char[2], char[2], char[2], char[3], char[4]>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_sort_q.cpp b/src/boost/libs/mp11/test/mp_sort_q.cpp new file mode 100644 index 000000000..84f8b455d --- /dev/null +++ b/src/boost/libs/mp11/test/mp_sort_q.cpp @@ -0,0 +1,58 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +using boost::mp11::mp_bool; + +struct Q_sizeof_less +{ + template<class T, class U> using fn = mp_bool<(sizeof(T) < sizeof(U))>; +}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_sort_q; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort_q<L1, Q_sizeof_less>, L1>)); + + using L2 = mp_list<char[2], char[4], char[3], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort_q<L2, Q_sizeof_less>, mp_list<char[1], char[2], char[3], char[4]>>)); + + using L3 = mp_list<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort_q<L3, Q_sizeof_less>, mp_list<char[1], char[1], char[2], char[2], char[2], char[3], char[4]>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort_q<L1, Q_sizeof_less>, L1>)); + + using L2 = std::tuple<char[2], char[4], char[3], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort_q<L2, Q_sizeof_less>, std::tuple<char[1], char[2], char[3], char[4]>>)); + + using L3 = std::tuple<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort_q<L3, Q_sizeof_less>, std::tuple<char[1], char[1], char[2], char[2], char[2], char[3], char[4]>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_split.cpp b/src/boost/libs/mp11/test/mp_split.cpp new file mode 100644 index 000000000..0cea0725e --- /dev/null +++ b/src/boost/libs/mp11/test/mp_split.cpp @@ -0,0 +1,51 @@ +// Copyright 2021 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +struct S {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_split; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<mp_list<>, void>, mp_list<mp_list<>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<mp_list<X1>, void>, mp_list<mp_list<X1>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<mp_list<X1, X2>, void>, mp_list<mp_list<X1, X2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<mp_list<X1, X2, X3>, void>, mp_list<mp_list<X1, X2, X3>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<mp_list<S>, S>, mp_list<mp_list<>, mp_list<>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<mp_list<S, S>, S>, mp_list<mp_list<>, mp_list<>, mp_list<>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<mp_list<S, S, S>, S>, mp_list<mp_list<>, mp_list<>, mp_list<>, mp_list<>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<mp_list<X1, S, X2>, S>, mp_list<mp_list<X1>, mp_list<X2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<mp_list<X1, X2, S, X3, X4>, S>, mp_list<mp_list<X1, X2>, mp_list<X3, X4>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<mp_list<S, X1, X2, S, S, X3, X4, S>, S>, mp_list<mp_list<>, mp_list<X1, X2>, mp_list<>, mp_list<X3, X4>, mp_list<>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<std::tuple<>, void>, std::tuple<std::tuple<>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<std::tuple<X1>, void>, std::tuple<std::tuple<X1>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<std::tuple<X1, X2>, void>, std::tuple<std::tuple<X1, X2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<std::tuple<X1, X2, X3>, void>, std::tuple<std::tuple<X1, X2, X3>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<std::tuple<S>, S>, std::tuple<std::tuple<>, std::tuple<>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<std::tuple<S, S>, S>, std::tuple<std::tuple<>, std::tuple<>, std::tuple<>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<std::tuple<S, S, S>, S>, std::tuple<std::tuple<>, std::tuple<>, std::tuple<>, std::tuple<>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<std::tuple<X1, S, X2>, S>, std::tuple<std::tuple<X1>, std::tuple<X2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<std::tuple<X1, X2, S, X3, X4>, S>, std::tuple<std::tuple<X1, X2>, std::tuple<X3, X4>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_split<std::tuple<S, X1, X2, S, S, X3, X4, S>, S>, std::tuple<std::tuple<>, std::tuple<X1, X2>, std::tuple<>, std::tuple<X3, X4>, std::tuple<>>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_starts_with.cpp b/src/boost/libs/mp11/test/mp_starts_with.cpp new file mode 100644 index 000000000..88012201a --- /dev/null +++ b/src/boost/libs/mp11/test/mp_starts_with.cpp @@ -0,0 +1,64 @@ +// Copyright 2018 Glen Joseph Fernandes +// (glenjofe@gmail.com) +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_starts_with; + using boost::mp11::mp_true; + using boost::mp11::mp_false; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<>, + mp_list<> >, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<>, + mp_list<int> >, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<int>, + mp_list<> >, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<>, + std::tuple<int> >, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<std::tuple<int>, + mp_list<> >, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<int>, + mp_list<int> >, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<int>, + mp_list<char> >, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<std::tuple<int>, + mp_list<int> >, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<int>, + std::tuple<char> >, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<int, void>, + mp_list<int> >, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<int, void>, + mp_list<char> >, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<int>, + mp_list<int, void> >, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<std::pair<int, char>, + mp_list<int> >, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<int>, + std::pair<int, char> >, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<int, void>, + mp_list<int, void> >, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<int, void>, + mp_list<int, int> >, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<std::tuple<int, char>, + mp_list<int, char> >, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<int, char>, + std::tuple<int, int> >, mp_false>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<int, void, int>, + mp_list<int, void> >, mp_true>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_starts_with<mp_list<int, void, int>, + mp_list<int, int> >, mp_false>)); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_starts_with_sf.cpp b/src/boost/libs/mp11/test/mp_starts_with_sf.cpp new file mode 100644 index 000000000..40d757eb1 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_starts_with_sf.cpp @@ -0,0 +1,45 @@ +// Copyright 2018 Glen Joseph Fernandes +// (glenjofe@gmail.com) +// +// 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/mp11/utility.hpp> +#include <boost/mp11/algorithm.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> + +int main() +{ + using boost::mp11::mp_valid; + using boost::mp11::mp_starts_with; + using boost::mp11::mp_list; + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_starts_with>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_starts_with, + void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_starts_with, + mp_list<> >)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_starts_with, + mp_list<int> >)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_starts_with, + void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_starts_with, + mp_list<>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_starts_with, + mp_list<int>, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_starts_with, + void, mp_list<> >)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_starts_with, + void, mp_list<int> >)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_starts_with, + mp_list<>, mp_list<> >)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_starts_with, + mp_list<>, mp_list<int> >)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_starts_with, + mp_list<int>, mp_list<> >)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_starts_with, + mp_list<int>, mp_list<char> >)); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_take.cpp b/src/boost/libs/mp11/test/mp_take.cpp new file mode 100644 index 000000000..c7f042272 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_take.cpp @@ -0,0 +1,106 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; +struct X5 {}; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_take; + using boost::mp11::mp_take_c; + using boost::mp11::mp_size_t; + + { + using L1 = mp_list<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L1, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L1, mp_size_t<0>>, L1>)); + + using L2 = mp_list<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L2, 0>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L2, 1>, mp_list<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L2, 2>, mp_list<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L2, 3>, mp_list<X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L2, 4>, mp_list<X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L2, 5>, mp_list<X1, X2, X3, X4, X5>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L2, mp_size_t<0>>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L2, mp_size_t<1>>, mp_list<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L2, mp_size_t<2>>, mp_list<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L2, mp_size_t<3>>, mp_list<X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L2, mp_size_t<4>>, mp_list<X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L2, mp_size_t<5>>, mp_list<X1, X2, X3, X4, X5>>)); + + using L3 = mp_list<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L3, 6>, mp_list<X1, X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L3, 7>, mp_list<X1, X2, X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L3, 8>, mp_list<X1, X2, X3, X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L3, 9>, mp_list<X1, X2, X3, X4, X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L3, 10>, mp_list<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L3, 11>, mp_list<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L3, mp_size_t< 6>>, mp_list<X1, X2, X3, X4, X5, X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L3, mp_size_t< 7>>, mp_list<X1, X2, X3, X4, X5, X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L3, mp_size_t< 8>>, mp_list<X1, X2, X3, X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L3, mp_size_t< 9>>, mp_list<X1, X2, X3, X4, X5, X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L3, mp_size_t<10>>, mp_list<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L3, mp_size_t<11>>, mp_list<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1>>)); + } + + { + using L1 = std::tuple<>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L1, 0>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L1, mp_size_t<0>>, L1>)); + + using L2 = std::tuple<X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L2, 0>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L2, 1>, std::tuple<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L2, 2>, std::tuple<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L2, 3>, std::tuple<X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L2, 4>, std::tuple<X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L2, 5>, std::tuple<X1, X2, X3, X4, X5>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L2, mp_size_t<0>>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L2, mp_size_t<1>>, std::tuple<X1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L2, mp_size_t<2>>, std::tuple<X1, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L2, mp_size_t<3>>, std::tuple<X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L2, mp_size_t<4>>, std::tuple<X1, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L2, mp_size_t<5>>, std::tuple<X1, X2, X3, X4, X5>>)); + + using L3 = std::tuple<X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5, X1, X2, X3, X4, X5>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L3, 8>, std::tuple<X1, X2, X3, X4, X5, X1, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L3, mp_size_t<9>>, std::tuple<X1, X2, X3, X4, X5, X1, X2, X3, X4>>)); + } + + { + using L1 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take_c<L1, 2>, L1>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_take<L1, mp_size_t<2>>, L1>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_third.cpp b/src/boost/libs/mp11/test/mp_third.cpp new file mode 100644 index 000000000..c43b85da7 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_third.cpp @@ -0,0 +1,28 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/core/lightweight_test_trait.hpp> +#include <boost/mp11/list.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_third; + + using L1 = mp_list<int[], void, float[]>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_third<L1>, float[]>)); + + using L2 = std::tuple<int, float, char>; + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_third<L2>, char>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_transform.cpp b/src/boost/libs/mp11/test/mp_transform.cpp new file mode 100644 index 000000000..ed6f1ddec --- /dev/null +++ b/src/boost/libs/mp11/test/mp_transform.cpp @@ -0,0 +1,105 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +struct Y1 {}; +struct Y2 {}; +struct Y3 {}; +struct Y4 {}; + +struct Z1 {}; +struct Z2 {}; +struct Z3 {}; +struct Z4 {}; + +struct U1 {}; +struct U2 {}; + +struct V1 {}; +struct V2 {}; + +struct W1 {}; +struct W2 {}; + +template<class T> using add_pointer = typename std::add_pointer<T>::type; +template<class T, class U> using is_same = typename std::is_same<T, U>::type; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_transform; + + using L1 = mp_list<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<mp_list, L1>, mp_list<mp_list<X1>, mp_list<X2>, mp_list<X3>, mp_list<X4>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<std::tuple, L1>, mp_list<std::tuple<X1>, std::tuple<X2>, std::tuple<X3>, std::tuple<X4>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<std::add_pointer, L1>, mp_list<std::add_pointer<X1>, std::add_pointer<X2>, std::add_pointer<X3>, std::add_pointer<X4>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<add_pointer, L1>, mp_list<X1*, X2*, X3*, X4*>>)); + + using L2 = std::tuple<Y1, Y2, Y3, Y4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<mp_list, L1, L2>, mp_list<mp_list<X1, Y1>, mp_list<X2, Y2>, mp_list<X3, Y3>, mp_list<X4, Y4>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<std::tuple, L1, L2>, mp_list<std::tuple<X1, Y1>, std::tuple<X2, Y2>, std::tuple<X3, Y3>, std::tuple<X4, Y4>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<std::pair, L1, L2>, mp_list<std::pair<X1, Y1>, std::pair<X2, Y2>, std::pair<X3, Y3>, std::pair<X4, Y4>>>)); + + using L3 = mp_list<Z1, Z2, Z3, Z4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<mp_list, L1, L2, L3>, mp_list<mp_list<X1, Y1, Z1>, mp_list<X2, Y2, Z2>, mp_list<X3, Y3, Z3>, mp_list<X4, Y4, Z4>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<std::tuple, L1, L2, L3>, mp_list<std::tuple<X1, Y1, Z1>, std::tuple<X2, Y2, Z2>, std::tuple<X3, Y3, Z3>, std::tuple<X4, Y4, Z4>>>)); + + // + + using L4 = std::tuple<X1, Y2, X3, Y4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<is_same, L1, L1>, mp_list<std::true_type, std::true_type, std::true_type, std::true_type>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<is_same, L1, L2>, mp_list<std::false_type, std::false_type, std::false_type, std::false_type>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<is_same, L1, L4>, mp_list<std::true_type, std::false_type, std::true_type, std::false_type>>)); + + // + + using L5 = std::pair<X1, X2>; + using L6 = std::pair<Y1, Y2>; + using L7 = std::pair<X1, Y2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<mp_list, L5>, std::pair<mp_list<X1>, mp_list<X2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<mp_list, L5, L6>, std::pair<mp_list<X1, Y1>, mp_list<X2, Y2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<mp_list, L5, L6, L7>, std::pair<mp_list<X1, Y1, X1>, mp_list<X2, Y2, Y2>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<add_pointer, L5>, std::pair<X1*, X2*>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<is_same, L5, L5>, std::pair<std::true_type, std::true_type>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<is_same, L5, L6>, std::pair<std::false_type, std::false_type>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<is_same, L5, L7>, std::pair<std::true_type, std::false_type>>)); + + // + + using L8 = std::pair<Z1, Z2>; + using L9 = std::pair<U1, U2>; + using L10 = std::pair<V1, V2>; + using L11 = std::pair<W1, W2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<std::tuple, L5, L6, L8, L9>, std::pair<std::tuple<X1, Y1, Z1, U1>, std::tuple<X2, Y2, Z2, U2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<std::tuple, L5, L6, L8, L9, L10>, std::pair<std::tuple<X1, Y1, Z1, U1, V1>, std::tuple<X2, Y2, Z2, U2, V2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform<std::tuple, L5, L6, L8, L9, L10, L11>, std::pair<std::tuple<X1, Y1, Z1, U1, V1, W1>, std::tuple<X2, Y2, Z2, U2, V2, W2>>>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_transform_front.cpp b/src/boost/libs/mp11/test/mp_transform_front.cpp new file mode 100644 index 000000000..8711128f6 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_transform_front.cpp @@ -0,0 +1,112 @@ + +// Copyright 2015, 2017, 2019 Peter Dimov. +// +// 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/mp11/list.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +template<class T> using add_pointer_t = T*; +using Q_add_pointer = boost::mp11::mp_quote_trait<std::add_pointer>; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_transform_front; + using boost::mp11::mp_transform_first; + using boost::mp11::mp_transform_front_q; + using boost::mp11::mp_transform_first_q; + + { + using L1 = mp_list<X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L1, add_pointer_t>, mp_list<X1*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L1, add_pointer_t>, mp_list<X1*>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L1, Q_add_pointer>, mp_list<X1*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L1, Q_add_pointer>, mp_list<X1*>>)); + + using L2 = mp_list<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L2, add_pointer_t>, mp_list<X1*, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L2, add_pointer_t>, mp_list<X1*, X2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L2, Q_add_pointer>, mp_list<X1*, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L2, Q_add_pointer>, mp_list<X1*, X2>>)); + + using L3 = mp_list<X1, X2, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L3, add_pointer_t>, mp_list<X1*, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L3, add_pointer_t>, mp_list<X1*, X2, X3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L3, Q_add_pointer>, mp_list<X1*, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L3, Q_add_pointer>, mp_list<X1*, X2, X3>>)); + + using L4 = mp_list<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L4, add_pointer_t>, mp_list<X1*, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L4, add_pointer_t>, mp_list<X1*, X2, X3, X4>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L4, Q_add_pointer>, mp_list<X1*, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L4, Q_add_pointer>, mp_list<X1*, X2, X3, X4>>)); + } + + { + using L1 = std::tuple<X1>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L1, add_pointer_t>, std::tuple<X1*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L1, add_pointer_t>, std::tuple<X1*>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L1, Q_add_pointer>, std::tuple<X1*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L1, Q_add_pointer>, std::tuple<X1*>>)); + + using L2 = std::tuple<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L2, add_pointer_t>, std::tuple<X1*, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L2, add_pointer_t>, std::tuple<X1*, X2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L2, Q_add_pointer>, std::tuple<X1*, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L2, Q_add_pointer>, std::tuple<X1*, X2>>)); + + using L3 = std::tuple<X1, X2, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L3, add_pointer_t>, std::tuple<X1*, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L3, add_pointer_t>, std::tuple<X1*, X2, X3>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L3, Q_add_pointer>, std::tuple<X1*, X2, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L3, Q_add_pointer>, std::tuple<X1*, X2, X3>>)); + + using L4 = std::tuple<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L4, add_pointer_t>, std::tuple<X1*, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L4, add_pointer_t>, std::tuple<X1*, X2, X3, X4>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L4, Q_add_pointer>, std::tuple<X1*, X2, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L4, Q_add_pointer>, std::tuple<X1*, X2, X3, X4>>)); + } + + { + using L2 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L2, add_pointer_t>, std::pair<X1*, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L2, add_pointer_t>, std::pair<X1*, X2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L2, Q_add_pointer>, std::pair<X1*, X2>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L2, Q_add_pointer>, std::pair<X1*, X2>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_transform_if.cpp b/src/boost/libs/mp11/test/mp_transform_if.cpp new file mode 100644 index 000000000..048909aaf --- /dev/null +++ b/src/boost/libs/mp11/test/mp_transform_if.cpp @@ -0,0 +1,74 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +using boost::mp11::mp_not; + +template<class T> using add_pointer = T*; +template<class T, class...> using is_not_ref = mp_not<std::is_reference<T>>; +template<class T1, class T2> using second = T2; +template<class T1, class T2, class T3> using third = T3; +template<class T1, class T2, class T3, class T4> using fourth = T4; +template<class T1, class T2, class T3, class T4, class T5> using fifth = T5; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_transform_if; + using boost::mp11::mp_size_t; + using boost::mp11::mp_size; + using boost::mp11::mp_fill; + using boost::mp11::mp_iota; + + using L1 = mp_list<X1, X2&, X3 const, X4 const&>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, add_pointer, L1>, mp_list<X1*, X2&, X3 const*, X4 const&>>)); + + using L2 = std::tuple<X1, X2&, X3 const, X4 const&>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, add_pointer, L2>, std::tuple<X1*, X2&, X3 const*, X4 const&>>)); + + using L3 = std::pair<X1 const, X2&>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, add_pointer, L3>, std::pair<X1 const*, X2&>>)); + + // + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, second, L1, mp_fill<L1, void>>, mp_list<void, X2&, void, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, second, L2, mp_fill<L2, void>>, std::tuple<void, X2&, void, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, second, L3, mp_fill<L3, void>>, std::pair<void, X2&>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, third, L1, L1, mp_iota<mp_size<L1>>>, mp_list<mp_size_t<0>, X2&, mp_size_t<2>, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, third, L2, L2, mp_iota<mp_size<L2>>>, std::tuple<mp_size_t<0>, X2&, mp_size_t<2>, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, third, L3, L3, mp_iota<mp_size<L3>>>, std::pair<mp_size_t<0>, X2&>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, fourth, L1, L1, L1, mp_iota<mp_size<L1>>>, mp_list<mp_size_t<0>, X2&, mp_size_t<2>, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, fourth, L2, L2, L2, mp_iota<mp_size<L2>>>, std::tuple<mp_size_t<0>, X2&, mp_size_t<2>, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, fourth, L3, L3, L3, mp_iota<mp_size<L3>>>, std::pair<mp_size_t<0>, X2&>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, fifth, L1, L1, L1, L1, mp_iota<mp_size<L1>>>, mp_list<mp_size_t<0>, X2&, mp_size_t<2>, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, fifth, L2, L2, L2, L2, mp_iota<mp_size<L2>>>, std::tuple<mp_size_t<0>, X2&, mp_size_t<2>, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if<is_not_ref, fifth, L3, L3, L3, L3, mp_iota<mp_size<L3>>>, std::pair<mp_size_t<0>, X2&>>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_transform_if_q.cpp b/src/boost/libs/mp11/test/mp_transform_if_q.cpp new file mode 100644 index 000000000..b2087be82 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_transform_if_q.cpp @@ -0,0 +1,87 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +using boost::mp11::mp_not; +using boost::mp11::mp_quote; + +template<class T> using add_pointer = T*; +using Q_add_pointer = mp_quote<add_pointer>; + +template<class T, class...> using is_not_ref = mp_not<std::is_reference<T>>; +using Q_is_not_ref = mp_quote<is_not_ref>; + +template<class T1, class T2> using second = T2; +using Q_second = mp_quote<second>; + +template<class T1, class T2, class T3> using third = T3; +using Q_third = mp_quote<third>; + +template<class T1, class T2, class T3, class T4> using fourth = T4; +using Q_fourth = mp_quote<fourth>; + +template<class T1, class T2, class T3, class T4, class T5> using fifth = T5; +using Q_fifth = mp_quote<fifth>; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_transform_if_q; + using boost::mp11::mp_size_t; + using boost::mp11::mp_size; + using boost::mp11::mp_fill; + using boost::mp11::mp_iota; + + using L1 = mp_list<X1, X2&, X3 const, X4 const&>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_add_pointer, L1>, mp_list<X1*, X2&, X3 const*, X4 const&>>)); + + using L2 = std::tuple<X1, X2&, X3 const, X4 const&>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_add_pointer, L2>, std::tuple<X1*, X2&, X3 const*, X4 const&>>)); + + using L3 = std::pair<X1 const, X2&>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_add_pointer, L3>, std::pair<X1 const*, X2&>>)); + + // + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_second, L1, mp_fill<L1, void>>, mp_list<void, X2&, void, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_second, L2, mp_fill<L2, void>>, std::tuple<void, X2&, void, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_second, L3, mp_fill<L3, void>>, std::pair<void, X2&>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_third, L1, L1, mp_iota<mp_size<L1>>>, mp_list<mp_size_t<0>, X2&, mp_size_t<2>, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_third, L2, L2, mp_iota<mp_size<L2>>>, std::tuple<mp_size_t<0>, X2&, mp_size_t<2>, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_third, L3, L3, mp_iota<mp_size<L3>>>, std::pair<mp_size_t<0>, X2&>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_fourth, L1, L1, L1, mp_iota<mp_size<L1>>>, mp_list<mp_size_t<0>, X2&, mp_size_t<2>, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_fourth, L2, L2, L2, mp_iota<mp_size<L2>>>, std::tuple<mp_size_t<0>, X2&, mp_size_t<2>, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_fourth, L3, L3, L3, mp_iota<mp_size<L3>>>, std::pair<mp_size_t<0>, X2&>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_fifth, L1, L1, L1, L1, mp_iota<mp_size<L1>>>, mp_list<mp_size_t<0>, X2&, mp_size_t<2>, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_fifth, L2, L2, L2, L2, mp_iota<mp_size<L2>>>, std::tuple<mp_size_t<0>, X2&, mp_size_t<2>, X4 const&>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_if_q<Q_is_not_ref, Q_fifth, L3, L3, L3, L3, mp_iota<mp_size<L3>>>, std::pair<mp_size_t<0>, X2&>>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_transform_q.cpp b/src/boost/libs/mp11/test/mp_transform_q.cpp new file mode 100644 index 000000000..6c73cb1d3 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_transform_q.cpp @@ -0,0 +1,114 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +struct Y1 {}; +struct Y2 {}; +struct Y3 {}; +struct Y4 {}; + +struct Z1 {}; +struct Z2 {}; +struct Z3 {}; +struct Z4 {}; + +struct U1 {}; +struct U2 {}; + +struct V1 {}; +struct V2 {}; + +struct W1 {}; +struct W2 {}; + +using boost::mp11::mp_quote; +using boost::mp11::mp_list; + +template<class T> using add_pointer = typename std::add_pointer<T>::type; +using Q_add_pointer = mp_quote<add_pointer>; + +template<class T, class U> using is_same = typename std::is_same<T, U>::type; +using Q_is_same = mp_quote<is_same>; + +using Q_mp_list = mp_quote<mp_list>; +using Q_std_tuple = mp_quote<std::tuple>; +using Q_std_pair = mp_quote<std::pair>; + +int main() +{ + using boost::mp11::mp_transform_q; + + using L1 = mp_list<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_mp_list, L1>, mp_list<mp_list<X1>, mp_list<X2>, mp_list<X3>, mp_list<X4>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_std_tuple, L1>, mp_list<std::tuple<X1>, std::tuple<X2>, std::tuple<X3>, std::tuple<X4>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_add_pointer, L1>, mp_list<X1*, X2*, X3*, X4*>>)); + + using L2 = std::tuple<Y1, Y2, Y3, Y4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_mp_list, L1, L2>, mp_list<mp_list<X1, Y1>, mp_list<X2, Y2>, mp_list<X3, Y3>, mp_list<X4, Y4>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_std_tuple, L1, L2>, mp_list<std::tuple<X1, Y1>, std::tuple<X2, Y2>, std::tuple<X3, Y3>, std::tuple<X4, Y4>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_std_pair, L1, L2>, mp_list<std::pair<X1, Y1>, std::pair<X2, Y2>, std::pair<X3, Y3>, std::pair<X4, Y4>>>)); + + using L3 = mp_list<Z1, Z2, Z3, Z4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_mp_list, L1, L2, L3>, mp_list<mp_list<X1, Y1, Z1>, mp_list<X2, Y2, Z2>, mp_list<X3, Y3, Z3>, mp_list<X4, Y4, Z4>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_std_tuple, L1, L2, L3>, mp_list<std::tuple<X1, Y1, Z1>, std::tuple<X2, Y2, Z2>, std::tuple<X3, Y3, Z3>, std::tuple<X4, Y4, Z4>>>)); + + // + + using L4 = std::tuple<X1, Y2, X3, Y4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_is_same, L1, L1>, mp_list<std::true_type, std::true_type, std::true_type, std::true_type>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_is_same, L1, L2>, mp_list<std::false_type, std::false_type, std::false_type, std::false_type>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_is_same, L1, L4>, mp_list<std::true_type, std::false_type, std::true_type, std::false_type>>)); + + // + + using L5 = std::pair<X1, X2>; + using L6 = std::pair<Y1, Y2>; + using L7 = std::pair<X1, Y2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_mp_list, L5>, std::pair<mp_list<X1>, mp_list<X2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_mp_list, L5, L6>, std::pair<mp_list<X1, Y1>, mp_list<X2, Y2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_mp_list, L5, L6, L7>, std::pair<mp_list<X1, Y1, X1>, mp_list<X2, Y2, Y2>>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_add_pointer, L5>, std::pair<X1*, X2*>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_is_same, L5, L5>, std::pair<std::true_type, std::true_type>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_is_same, L5, L6>, std::pair<std::false_type, std::false_type>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_is_same, L5, L7>, std::pair<std::true_type, std::false_type>>)); + + // + + using L8 = std::pair<Z1, Z2>; + using L9 = std::pair<U1, U2>; + using L10 = std::pair<V1, V2>; + using L11 = std::pair<W1, W2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_std_tuple, L5, L6, L8, L9>, std::pair<std::tuple<X1, Y1, Z1, U1>, std::tuple<X2, Y2, Z2, U2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_std_tuple, L5, L6, L8, L9, L10>, std::pair<std::tuple<X1, Y1, Z1, U1, V1>, std::tuple<X2, Y2, Z2, U2, V2>>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_q<Q_std_tuple, L5, L6, L8, L9, L10, L11>, std::pair<std::tuple<X1, Y1, Z1, U1, V1, W1>, std::tuple<X2, Y2, Z2, U2, V2, W2>>>)); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_transform_second.cpp b/src/boost/libs/mp11/test/mp_transform_second.cpp new file mode 100644 index 000000000..f51dcbb55 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_transform_second.cpp @@ -0,0 +1,73 @@ + +// Copyright 2015, 2017, 2019 Peter Dimov. +// +// 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/mp11/list.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +template<class T> using add_pointer_t = T*; +using Q_add_pointer = boost::mp11::mp_quote_trait<std::add_pointer>; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_transform_second; + using boost::mp11::mp_transform_second_q; + + { + using L2 = mp_list<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L2, add_pointer_t>, mp_list<X1, X2*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L2, Q_add_pointer>, mp_list<X1, X2*>>)); + + using L3 = mp_list<X1, X2, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L3, add_pointer_t>, mp_list<X1, X2*, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L3, Q_add_pointer>, mp_list<X1, X2*, X3>>)); + + using L4 = mp_list<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L4, add_pointer_t>, mp_list<X1, X2*, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L4, Q_add_pointer>, mp_list<X1, X2*, X3, X4>>)); + } + + { + using L2 = std::tuple<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L2, add_pointer_t>, std::tuple<X1, X2*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L2, Q_add_pointer>, std::tuple<X1, X2*>>)); + + using L3 = std::tuple<X1, X2, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L3, add_pointer_t>, std::tuple<X1, X2*, X3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L3, Q_add_pointer>, std::tuple<X1, X2*, X3>>)); + + using L4 = std::tuple<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L4, add_pointer_t>, std::tuple<X1, X2*, X3, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L4, Q_add_pointer>, std::tuple<X1, X2*, X3, X4>>)); + } + + { + using L2 = std::pair<X1, X2>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L2, add_pointer_t>, std::pair<X1, X2*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L2, Q_add_pointer>, std::pair<X1, X2*>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_transform_sf.cpp b/src/boost/libs/mp11/test/mp_transform_sf.cpp new file mode 100644 index 000000000..e4f5515d2 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_transform_sf.cpp @@ -0,0 +1,43 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/detail/config.hpp> +#include <boost/core/lightweight_test_trait.hpp> + +using boost::mp11::mp_transform; +using boost::mp11::mp_list; +using boost::mp11::mp_valid; + +template<class...> using F = void; + +template<class... L> using transform = mp_transform<F, L...>; + +int main() +{ + BOOST_TEST_TRAIT_FALSE((mp_valid<transform>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<transform, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<transform, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<transform, void, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<transform, void, void, void, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<transform, void, void, void, void, void>)); + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) + BOOST_TEST_TRAIT_TRUE((mp_valid<transform, mp_list<>>)); +#endif + + BOOST_TEST_TRAIT_FALSE((mp_valid<transform, mp_list<>, mp_list<void>>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<transform, mp_list<>, mp_list<>, mp_list<void>>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<transform, mp_list<>, mp_list<>, mp_list<>, mp_list<void>>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<transform, mp_list<>, mp_list<>, mp_list<>, mp_list<>, mp_list<void>>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_transform_third.cpp b/src/boost/libs/mp11/test/mp_transform_third.cpp new file mode 100644 index 000000000..7f5376732 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_transform_third.cpp @@ -0,0 +1,56 @@ + +// Copyright 2015, 2017, 2019 Peter Dimov. +// +// 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/mp11/list.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <utility> + +struct X1 {}; +struct X2 {}; +struct X3 {}; +struct X4 {}; + +template<class T> using add_pointer_t = T*; +using Q_add_pointer = boost::mp11::mp_quote_trait<std::add_pointer>; + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_transform_third; + using boost::mp11::mp_transform_third_q; + + { + using L3 = mp_list<X1, X2, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third<L3, add_pointer_t>, mp_list<X1, X2, X3*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third_q<L3, Q_add_pointer>, mp_list<X1, X2, X3*>>)); + + using L4 = mp_list<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third<L4, add_pointer_t>, mp_list<X1, X2, X3*, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third_q<L4, Q_add_pointer>, mp_list<X1, X2, X3*, X4>>)); + } + + { + using L3 = std::tuple<X1, X2, X3>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third<L3, add_pointer_t>, std::tuple<X1, X2, X3*>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third_q<L3, Q_add_pointer>, std::tuple<X1, X2, X3*>>)); + + using L4 = std::tuple<X1, X2, X3, X4>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third<L4, add_pointer_t>, std::tuple<X1, X2, X3*, X4>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third_q<L4, Q_add_pointer>, std::tuple<X1, X2, X3*, X4>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_unique.cpp b/src/boost/libs/mp11/test/mp_unique.cpp new file mode 100644 index 000000000..697d4ce29 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_unique.cpp @@ -0,0 +1,54 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_unique; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<>>, mp_list<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void>>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, void>>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, void, void>>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, void, void, void>>, mp_list<void>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, int>>, mp_list<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, void, void, int, int, int>>, mp_list<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, int, void, int, int, void, int, int, int>>, mp_list<void, int>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, int, char[]>>, mp_list<void, int, char[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<mp_list<void, int, char[], void, int, char[], void, int, char[]>>, mp_list<void, int, char[]>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<>>, std::tuple<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void>>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, void>>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, void, void>>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, void, void, void>>, std::tuple<void>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, int>>, std::tuple<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, void, void, int, int, int>>, std::tuple<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, int, void, int, int, void, int, int, int>>, std::tuple<void, int>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, int, char[]>>, std::tuple<void, int, char[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique<std::tuple<void, int, char[], void, int, char[], void, int, char[]>>, std::tuple<void, int, char[]>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_unique_if.cpp b/src/boost/libs/mp11/test/mp_unique_if.cpp new file mode 100644 index 000000000..3e579a6b8 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_unique_if.cpp @@ -0,0 +1,110 @@ +// Copyright 2015 Peter Dimov. +// Copyright 2019 Kris Jusiak. +// +// 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/mp11/detail/config.hpp> + +#if BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 40800 ) +# pragma GCC diagnostic ignored "-Wsign-compare" +#endif + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> +#include <cstddef> + +using boost::mp11::mp_bool; + +#if !BOOST_MP11_WORKAROUND( BOOST_MSVC, < 1910 ) + +template<class T, class U> using Eq1 = mp_bool< T::value == U::value >; +template<class T, class U> using Eq2 = mp_bool< sizeof(T) == sizeof(U) >; + +#else + +template<class T, class U> struct Eq1: mp_bool< T::value == U::value > {}; +template<class T, class U> struct Eq2: mp_bool< sizeof(T) == sizeof(U) > {}; + +#endif + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_unique_if; + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<mp_list<>, std::is_same>, mp_list<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<mp_list<void>, std::is_same>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<mp_list<void, void>, std::is_same>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<mp_list<void, void, void>, std::is_same>, mp_list<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<mp_list<void, void, void, void>, std::is_same>, mp_list<void>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<mp_list<void, int>, std::is_same>, mp_list<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<mp_list<void, void, void, int, int, int>, std::is_same>, mp_list<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<mp_list<void, int, void, int, int, void, int, int, int>, std::is_same>, mp_list<void, int>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<mp_list<void, int, char[]>, std::is_same>, mp_list<void, int, char[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<mp_list<void, int, char[], void, int, char[], void, int, char[]>, std::is_same>, mp_list<void, int, char[]>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<std::tuple<>, std::is_same>, std::tuple<>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<std::tuple<void>, std::is_same>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<std::tuple<void, void>, std::is_same>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<std::tuple<void, void, void>, std::is_same>, std::tuple<void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<std::tuple<void, void, void, void>, std::is_same>, std::tuple<void>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<std::tuple<void, int>, std::is_same>, std::tuple<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<std::tuple<void, void, void, int, int, int>, std::is_same>, std::tuple<void, int>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<std::tuple<void, int, void, int, int, void, int, int, int>, std::is_same>, std::tuple<void, int>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<std::tuple<void, int, char[]>, std::is_same>, std::tuple<void, int, char[]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<std::tuple<void, int, char[], void, int, char[], void, int, char[]>, std::is_same>, std::tuple<void, int, char[]>>)); + } + + { + using boost::mp11::mp_iota_c; + using boost::mp11::mp_size_t; + + using L1 = mp_iota_c<32>; + + using R1 = mp_unique_if<L1, std::is_same>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, L1>)); + + using R2 = mp_unique_if<L1, Eq1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, L1>)); + + using R3 = mp_unique_if<L1, Eq2>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R3, mp_list<mp_size_t<0>>>)); + } + + { + using boost::mp11::mp_list_c; + using boost::mp11::mp_append; + using boost::mp11::mp_push_back; + using boost::mp11::mp_int; + + using L1 = mp_list_c<std::size_t, 0, 1, 2, 3>; + using L2 = mp_list_c<int, 1, 2, 3, 4>; + using L3 = mp_list_c<long, 2, 3, 4, 5>; + + using R1 = mp_unique_if<mp_append<L1, L2, L3>, Eq1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_push_back<L1, mp_int<4>, std::integral_constant<long, 5>>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<std::tuple<char[1], char[2], char[1], char[2], char[2], char[1], char[2], char[2], char[2]>, Eq2>, std::tuple<char[1], char[2]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if<std::tuple<char[1], char[2], char[3], char[1], char[2], char[3], char[1], char[2], char[3]>, Eq2>, std::tuple<char[1], char[2], char[3]>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_unique_if_q.cpp b/src/boost/libs/mp11/test/mp_unique_if_q.cpp new file mode 100644 index 000000000..10fc47961 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_unique_if_q.cpp @@ -0,0 +1,93 @@ +// Copyright 2015 Peter Dimov. +// Copyright 2019 Kris Jusiak. +// +// 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/mp11/detail/config.hpp> + +#if BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 40800 ) +# pragma GCC diagnostic ignored "-Wsign-compare" +#endif + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/list.hpp> +#include <boost/mp11/integral.hpp> +#include <boost/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +using boost::mp11::mp_bool; + +#if !BOOST_MP11_WORKAROUND( BOOST_MSVC, < 1910 ) + +struct Q1 +{ + template<class T, class U> using fn = mp_bool< T::value == U::value >; +}; + +struct Q2 +{ + template<class T, class U> using fn = mp_bool< sizeof(T) == sizeof(U) >; +}; + +#else + +struct Q1 +{ + template<class T, class U> struct fn: mp_bool< T::value == U::value > {}; +}; + +struct Q2 +{ + template<class T, class U> struct fn: mp_bool< sizeof(T) == sizeof(U) > {}; +}; + +#endif + +int main() +{ + using boost::mp11::mp_list; + using boost::mp11::mp_unique_if_q; + using boost::mp11::mp_quote_trait; + + { + using boost::mp11::mp_iota_c; + using boost::mp11::mp_size_t; + + using L1 = mp_iota_c<32>; + + using R1 = mp_unique_if_q<L1, mp_quote_trait<std::is_same>>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, L1>)); + + using R2 = mp_unique_if_q<L1, Q1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R2, L1>)); + + using R3 = mp_unique_if_q<L1, Q2>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R3, mp_list<mp_size_t<0>>>)); + } + + { + using boost::mp11::mp_list_c; + using boost::mp11::mp_append; + using boost::mp11::mp_push_back; + using boost::mp11::mp_int; + + using L1 = mp_list_c<std::size_t, 0, 1, 2, 3>; + using L2 = mp_list_c<int, 1, 2, 3, 4>; + using L3 = mp_list_c<long, 2, 3, 4, 5>; + + using R1 = mp_unique_if_q<mp_append<L1, L2, L3>, Q1>; + BOOST_TEST_TRAIT_TRUE((std::is_same<R1, mp_push_back<L1, mp_int<4>, std::integral_constant<long, 5>>>)); + } + + { + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if_q<std::tuple<char[1], char[2], char[1], char[2], char[2], char[1], char[2], char[2], char[2]>, Q2>, std::tuple<char[1], char[2]>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unique_if_q<std::tuple<char[1], char[2], char[3], char[1], char[2], char[3], char[1], char[2], char[3]>, Q2>, std::tuple<char[1], char[2], char[3]>>)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_valid.cpp b/src/boost/libs/mp11/test/mp_valid.cpp new file mode 100644 index 000000000..9a95b944b --- /dev/null +++ b/src/boost/libs/mp11/test/mp_valid.cpp @@ -0,0 +1,99 @@ + +// Copyright 2015 Peter Dimov. +// +// 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/mp11/utility.hpp> +#include <boost/mp11/detail/config.hpp> +#include <boost/core/lightweight_test_trait.hpp> + +template<class T> struct Xi +{ +}; + +template<> struct Xi<void> +{ + using type = void; +}; + +template<class T> using X = typename Xi<T>::type; + +template<class T> using add_pointer = T*; +template<class T> using add_reference = T&; +template<class T> using add_extents = T[]; + +using boost::mp11::mp_quote; + +using QX = mp_quote<X>; +using Q_add_pointer = mp_quote<add_pointer>; + +int main() +{ + using boost::mp11::mp_valid; + using boost::mp11::mp_valid_q; + using boost::mp11::mp_identity; + + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_identity>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<mp_identity, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<mp_identity, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<X>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<X, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<X, int>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<X, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<QX::fn>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<QX::fn, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<QX::fn, int>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<QX::fn, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid_q<QX>)); + BOOST_TEST_TRAIT_TRUE((mp_valid_q<QX, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid_q<QX, int>)); + BOOST_TEST_TRAIT_FALSE((mp_valid_q<QX, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<add_pointer>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<add_pointer, void>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<add_pointer, int>)); +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) + // msvc-12.0 can form pointer to reference + BOOST_TEST_TRAIT_FALSE((mp_valid<add_pointer, int&>)); +#endif + BOOST_TEST_TRAIT_FALSE((mp_valid<add_pointer, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid<Q_add_pointer::fn>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<Q_add_pointer::fn, void>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<Q_add_pointer::fn, int>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<Q_add_pointer::fn, void, void>)); + + BOOST_TEST_TRAIT_FALSE((mp_valid_q<Q_add_pointer>)); + BOOST_TEST_TRAIT_TRUE((mp_valid_q<Q_add_pointer, void>)); + BOOST_TEST_TRAIT_TRUE((mp_valid_q<Q_add_pointer, int>)); + BOOST_TEST_TRAIT_FALSE((mp_valid_q<Q_add_pointer, void, void>)); + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 70000 ) + // g++ up to at least 6.3 doesn't like add_reference for some reason or other + BOOST_TEST_TRAIT_FALSE((mp_valid<add_reference>)); +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) + // msvc-12.0 gives an internal error here + BOOST_TEST_TRAIT_FALSE((mp_valid<add_reference, void>)); +#endif + BOOST_TEST_TRAIT_TRUE((mp_valid<add_reference, int>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<add_reference, int, int>)); +#endif + + BOOST_TEST_TRAIT_FALSE((mp_valid<add_extents>)); + BOOST_TEST_TRAIT_TRUE((mp_valid<add_extents, int>)); +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 ) + // msvc-12.0 can form arrays to void or int& + BOOST_TEST_TRAIT_FALSE((mp_valid<add_extents, void>)); + BOOST_TEST_TRAIT_FALSE((mp_valid<add_extents, int&>)); +#endif + BOOST_TEST_TRAIT_FALSE((mp_valid<add_extents, int, int>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_valid_and_true.cpp b/src/boost/libs/mp11/test/mp_valid_and_true.cpp new file mode 100644 index 000000000..31cf8fd6e --- /dev/null +++ b/src/boost/libs/mp11/test/mp_valid_and_true.cpp @@ -0,0 +1,48 @@ +// Copyright 2022 Dmitry Arkhipov (grisumbras@gmail.com) +// +// 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/mp11/utility.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <cstddef> + +template<class T> +using has_size_t_difference_type + = std::is_same<typename T::difference_type, std::size_t>; + +struct X +{ +}; + +struct Y +{ + using difference_type = int; +}; + +struct Z +{ + using difference_type = std::size_t; +}; + +int main() +{ + using boost::mp11::mp_valid_and_true; + using boost::mp11::mp_valid_and_true_q; + using boost::mp11::mp_quote; + + BOOST_TEST_TRAIT_FALSE((mp_valid_and_true<has_size_t_difference_type, X>)); + BOOST_TEST_TRAIT_FALSE((mp_valid_and_true<has_size_t_difference_type, Y>)); + BOOST_TEST_TRAIT_TRUE((mp_valid_and_true<has_size_t_difference_type, Z>)); + + using Q_size_t_diff = mp_quote<has_size_t_difference_type>; + + BOOST_TEST_TRAIT_FALSE((mp_valid_and_true_q<Q_size_t_diff, X>)); + BOOST_TEST_TRAIT_FALSE((mp_valid_and_true_q<Q_size_t_diff, Y>)); + BOOST_TEST_TRAIT_TRUE((mp_valid_and_true_q<Q_size_t_diff, Z>)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_with_index.cpp b/src/boost/libs/mp11/test/mp_with_index.cpp new file mode 100644 index 000000000..85a142d16 --- /dev/null +++ b/src/boost/libs/mp11/test/mp_with_index.cpp @@ -0,0 +1,95 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/detail/config.hpp> + +#if BOOST_MP11_MSVC +# pragma warning( disable: 4503 ) // decorated name length exceeded +#endif + +#include <boost/mp11/algorithm.hpp> +#include <boost/mp11/detail/config.hpp> +#include <boost/core/lightweight_test.hpp> +#include <tuple> + +using boost::mp11::mp_size_t; +using boost::mp11::mp_for_each; +using boost::mp11::mp_with_index; +using boost::mp11::mp_iota_c; + +struct F +{ + std::size_t i_; + + explicit F( std::size_t i ): i_( i ) {} + + template<std::size_t I> bool operator()( mp_size_t<I> ) const + { + BOOST_TEST_EQ( I, i_ ); + return false; + } +}; + +struct G +{ + void operator()( mp_size_t<0> ) const + { + } + + template<std::size_t N> void operator()( mp_size_t<N> ) const + { + for( std::size_t i = 0; i < N; ++i ) + { + mp_with_index<N>( i, F(i) ); + mp_with_index<mp_size_t<N>>( i, F(i) ); + } + } +}; + +int main() +{ +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1900 ) + + G()( mp_size_t<1>{} ); + G()( mp_size_t<2>{} ); + G()( mp_size_t<3>{} ); + G()( mp_size_t<4>{} ); + G()( mp_size_t<5>{} ); + G()( mp_size_t<6>{} ); + G()( mp_size_t<7>{} ); + G()( mp_size_t<8>{} ); + G()( mp_size_t<9>{} ); + G()( mp_size_t<10>{} ); + G()( mp_size_t<11>{} ); + G()( mp_size_t<12>{} ); + G()( mp_size_t<13>{} ); + G()( mp_size_t<14>{} ); + G()( mp_size_t<15>{} ); + G()( mp_size_t<16>{} ); + + G()( mp_size_t<32+1>{} ); + + G()( mp_size_t<48+2>{} ); + + G()( mp_size_t<64+3>{} ); + + G()( mp_size_t<96+4>{} ); + + G()( mp_size_t<112+5>{} ); + + G()( mp_size_t<128+6>{} ); + +#else + + mp_for_each<mp_iota_c<134>>( G() ); + +#endif + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mp_with_index_cx.cpp b/src/boost/libs/mp11/test/mp_with_index_cx.cpp new file mode 100644 index 000000000..3be9c2cfe --- /dev/null +++ b/src/boost/libs/mp11/test/mp_with_index_cx.cpp @@ -0,0 +1,39 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/detail/config.hpp> + +#if !defined( BOOST_MP11_HAS_CXX14_CONSTEXPR ) + +int main() {} + +#else + +#include <boost/mp11/algorithm.hpp> +#include <boost/core/lightweight_test.hpp> + +using boost::mp11::mp_size_t; +using boost::mp11::mp_with_index; + +struct F +{ + template<std::size_t I> constexpr std::size_t operator()( mp_size_t<I> ) const + { + return I; + } +}; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +int main() +{ + constexpr std::size_t i = mp_with_index<64>( 57, F{} ); + STATIC_ASSERT( i == 57 ); +} + +#endif diff --git a/src/boost/libs/mp11/test/mpl.cpp b/src/boost/libs/mp11/test/mpl.cpp new file mode 100644 index 000000000..5e9551eca --- /dev/null +++ b/src/boost/libs/mp11/test/mpl.cpp @@ -0,0 +1,108 @@ + +// Copyright 2017 Peter Dimov. +// +// 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/mp11/mpl.hpp> +#include <boost/mp11/list.hpp> + +#include <boost/mpl/at.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/back.hpp> +#include <boost/mpl/begin.hpp> +#include <boost/mpl/end.hpp> +#include <boost/mpl/distance.hpp> +#include <boost/mpl/clear.hpp> +#include <boost/mpl/empty.hpp> +#include <boost/mpl/erase.hpp> +#include <boost/mpl/front.hpp> +#include <boost/mpl/insert.hpp> +#include <boost/mpl/insert_range.hpp> +#include <boost/mpl/is_sequence.hpp> +#include <boost/mpl/pop_front.hpp> +#include <boost/mpl/push_back.hpp> +#include <boost/mpl/push_front.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/mpl/transform.hpp> +#include <boost/mpl/reverse.hpp> +#include <boost/mpl/remove.hpp> +#include <boost/mpl/copy.hpp> +#include <boost/mpl/back_inserter.hpp> + +#include <boost/core/lightweight_test_trait.hpp> +#include <type_traits> +#include <tuple> + +template<class T> using add_pointer_t = typename std::add_pointer<T>::type; + +template<class L1> void test() +{ + namespace mpl = boost::mpl; + using namespace boost::mp11; + + // intrinsics + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at<L1, mpl::int_<0>>::type, mp_at_c<L1, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at<L1, mpl::int_<1>>::type, mp_at_c<L1, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at<L1, mpl::int_<2>>::type, mp_at_c<L1, 2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at_c<L1, 0>::type, mp_at_c<L1, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at_c<L1, 1>::type, mp_at_c<L1, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at_c<L1, 2>::type, mp_at_c<L1, 2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::back<L1>::type, float>)); + + BOOST_TEST_EQ((mpl::distance<typename mpl::begin<L1>::type, typename mpl::end<L1>::type>::type::value), mp_size<L1>::value); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::clear<L1>::type, mp_clear<L1>>)); + + BOOST_TEST_TRAIT_FALSE((typename mpl::empty<L1>::type)); + BOOST_TEST_TRAIT_TRUE((typename mpl::empty<mp_clear<L1>>::type)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::erase<L1, typename mpl::begin<L1>::type>::type, mp_pop_front<L1>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::front<L1>::type, mp_front<L1>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::insert<L1, typename mpl::begin<L1>::type, void>::type, mp_push_front<L1, void>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::insert<L1, typename mpl::end<L1>::type, void>::type, mp_push_back<L1, void>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::insert_range<L1, typename mpl::end<L1>::type, L1>::type, mp_append<L1, L1>>)); + + BOOST_TEST_TRAIT_TRUE((typename mpl::is_sequence<L1>::type)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::pop_front<L1>::type, mp_pop_front<L1>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::push_back<L1, char>::type, mp_push_back<L1, char>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::push_front<L1, char>::type, mp_push_front<L1, char>>)); + + BOOST_TEST_EQ((mpl::size<L1>::type::value), mp_size<L1>::value); + + // algorithms + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::transform<L1, std::add_pointer<mpl::_1>>::type, mp_transform<add_pointer_t, L1>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::reverse<L1>::type, mp_reverse<L1>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::remove<L1, int>::type, mp_remove<L1, int>>)); + + using L2 = typename mpl::copy<L1, mpl::back_inserter<mpl::vector<>>>::type; + using L3 = typename mpl::copy<L2, mpl::back_inserter<mp_clear<L1>>>::type; + + BOOST_TEST_TRAIT_TRUE((std::is_same<L1, L3>)); +} + +int main() +{ + using boost::mp11::mp_list; + + test<mp_list<int, void, float>>(); + test<std::tuple<int, long, float>>(); // MPL instantiates the tuple, so no 'void' + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mpl_list.cpp b/src/boost/libs/mp11/test/mpl_list.cpp new file mode 100644 index 000000000..dfdb44ebf --- /dev/null +++ b/src/boost/libs/mp11/test/mpl_list.cpp @@ -0,0 +1,36 @@ + +// Copyright 2017, 2019 Peter Dimov. +// +// 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/mp11/mpl_list.hpp> +#include <boost/mp11/list.hpp> + +#include <boost/mpl/at.hpp> +#include <boost/mpl/size.hpp> + +#include <boost/core/lightweight_test_trait.hpp> + +int main() +{ + namespace mpl = boost::mpl; + using namespace boost::mp11; + + using L1 = mp_list<void, int, float>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at<L1, mpl::int_<0>>::type, mp_at_c<L1, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at<L1, mpl::int_<1>>::type, mp_at_c<L1, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at<L1, mpl::int_<2>>::type, mp_at_c<L1, 2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at_c<L1, 0>::type, mp_at_c<L1, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at_c<L1, 1>::type, mp_at_c<L1, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at_c<L1, 2>::type, mp_at_c<L1, 2>>)); + + BOOST_TEST_EQ((mpl::size<L1>::type::value), mp_size<L1>::value); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mpl_tuple.cpp b/src/boost/libs/mp11/test/mpl_tuple.cpp new file mode 100644 index 000000000..d85c36c0b --- /dev/null +++ b/src/boost/libs/mp11/test/mpl_tuple.cpp @@ -0,0 +1,36 @@ + +// Copyright 2017, 2019 Peter Dimov. +// +// 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/mp11/mpl_tuple.hpp> +#include <tuple> + +#include <boost/mpl/at.hpp> +#include <boost/mpl/size.hpp> + +#include <boost/core/lightweight_test_trait.hpp> + +int main() +{ + namespace mpl = boost::mpl; + using namespace boost::mp11; + + using L1 = std::tuple<char, int, float>; + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at<L1, mpl::int_<0>>::type, mp_at_c<L1, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at<L1, mpl::int_<1>>::type, mp_at_c<L1, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at<L1, mpl::int_<2>>::type, mp_at_c<L1, 2>>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at_c<L1, 0>::type, mp_at_c<L1, 0>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at_c<L1, 1>::type, mp_at_c<L1, 1>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same<typename mpl::at_c<L1, 2>::type, mp_at_c<L1, 2>>)); + + BOOST_TEST_EQ((mpl::size<L1>::type::value), mp_size<L1>::value); + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/mpl_version.cpp b/src/boost/libs/mp11/test/mpl_version.cpp new file mode 100644 index 000000000..f0d4c1bc1 --- /dev/null +++ b/src/boost/libs/mp11/test/mpl_version.cpp @@ -0,0 +1,17 @@ + +// Copyright 2019 Peter Dimov +// +// 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/mp11/mpl.hpp> +#include <boost/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_MP11_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/set_version.cpp b/src/boost/libs/mp11/test/set_version.cpp new file mode 100644 index 000000000..057a251c6 --- /dev/null +++ b/src/boost/libs/mp11/test/set_version.cpp @@ -0,0 +1,17 @@ + +// Copyright 2019 Peter Dimov +// +// 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/mp11/set.hpp> +#include <boost/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_MP11_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/tuple_apply.cpp b/src/boost/libs/mp11/test/tuple_apply.cpp new file mode 100644 index 000000000..dc5095927 --- /dev/null +++ b/src/boost/libs/mp11/test/tuple_apply.cpp @@ -0,0 +1,136 @@ + +// Copyright 2015, 2017 Peter Dimov. +// +// 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 + + +#if defined(_MSC_VER) +#pragma warning( disable: 4244 ) // 'initializing': conversion from 'int' to 'char', possible loss of data +#endif + +#include <boost/mp11/tuple.hpp> +#include <boost/core/lightweight_test.hpp> +#include <tuple> +#include <memory> +#include <utility> +#include <array> + +int main() +{ + using boost::mp11::tuple_apply; + + { + std::tuple<int, short, char> tp{ 1, 2, 3 }; + + { + int s = tuple_apply( [&]( int x, int y, int z ){ return 100 * x + 10 * y + z; }, tp ); + BOOST_TEST_EQ( s, 123 ); + } + + { + int s = tuple_apply( [&]( int x, int y, int z ){ return 100 * x + 10 * y + z; }, std::move(tp) ); + BOOST_TEST_EQ( s, 123 ); + } + } + + { + std::tuple<int, short, char> const tp{ 1, 2, 3 }; + + { + int s = tuple_apply( [&]( int x, int y, int z ){ return 100 * x + 10 * y + z; }, tp ); + BOOST_TEST_EQ( s, 123 ); + } + + { + int s = tuple_apply( [&]( int x, int y, int z ){ return 100 * x + 10 * y + z; }, std::move(tp) ); + BOOST_TEST_EQ( s, 123 ); + } + } + +#if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 8 +#else + + { + std::tuple<std::unique_ptr<int>, std::unique_ptr<int>, std::unique_ptr<int>> tp{ std::unique_ptr<int>(new int(1)), std::unique_ptr<int>(new int(2)), std::unique_ptr<int>(new int(3)) }; + + int s = tuple_apply( [&]( std::unique_ptr<int> px, std::unique_ptr<int> py, std::unique_ptr<int> pz ){ return 100 * *px + 10 * *py + *pz; }, std::move(tp) ); + BOOST_TEST_EQ( s, 123 ); + } + +#endif + + { + std::pair<int, short> tp{ 1, 2 }; + + { + int s = tuple_apply( [&]( int x, int y ){ return 10 * x + y; }, tp ); + BOOST_TEST_EQ( s, 12 ); + } + + { + int s = tuple_apply( [&]( int x, int y ){ return 10 * x + y; }, std::move(tp) ); + BOOST_TEST_EQ( s, 12 ); + } + } + + { + std::pair<int, short> const tp{ 1, 2 }; + + { + int s = tuple_apply( [&]( int x, int y ){ return 10 * x + y; }, tp ); + BOOST_TEST_EQ( s, 12 ); + } + + { + int s = tuple_apply( [&]( int x, int y ){ return 10 * x + y; }, std::move(tp) ); + BOOST_TEST_EQ( s, 12 ); + } + } + + { + std::array<int, 3> tp{{ 1, 2, 3 }}; + + { + int s = tuple_apply( [&]( int x, int y, int z ){ return 100 * x + 10 * y + z; }, tp ); + BOOST_TEST_EQ( s, 123 ); + } + + { + int s = tuple_apply( [&]( int x, int y, int z ){ return 100 * x + 10 * y + z; }, std::move(tp) ); + BOOST_TEST_EQ( s, 123 ); + } + } + + { + std::array<int, 3> const tp{{ 1, 2, 3 }}; + + { + int s = tuple_apply( [&]( int x, int y, int z ){ return 100 * x + 10 * y + z; }, tp ); + BOOST_TEST_EQ( s, 123 ); + } + + { + int s = tuple_apply( [&]( int x, int y, int z ){ return 100 * x + 10 * y + z; }, std::move(tp) ); + BOOST_TEST_EQ( s, 123 ); + } + } + + { + std::tuple<> tp; + + BOOST_TEST_EQ( tuple_apply( []{ return 11; }, tp ), 11 ); + BOOST_TEST_EQ( tuple_apply( []{ return 12; }, std::move( tp ) ), 12 ); + } + + { + std::array<int, 0> tp; + + BOOST_TEST_EQ( tuple_apply( []{ return 11; }, tp ), 11 ); + BOOST_TEST_EQ( tuple_apply( []{ return 12; }, std::move( tp ) ), 12 ); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/tuple_apply_cx.cpp b/src/boost/libs/mp11/test/tuple_apply_cx.cpp new file mode 100644 index 000000000..bcd26779d --- /dev/null +++ b/src/boost/libs/mp11/test/tuple_apply_cx.cpp @@ -0,0 +1,77 @@ + +// Copyright 2015 Peter Dimov. +// +// 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 + + +#if defined(_MSC_VER) +#pragma warning( disable: 4244 ) // 'initializing': conversion from 'int' to 'char', possible loss of data +#endif + +#include <boost/mp11/tuple.hpp> +#include <boost/mp11/detail/config.hpp> + +// Technically std::tuple isn't constexpr enabled in C++11, but it works with libstdc++ + +#if defined( BOOST_MP11_NO_CONSTEXPR ) || ( !defined(_MSC_VER) && !defined( __GLIBCXX__ ) && __cplusplus < 201400L ) + +int main() {} + +#else + +#include <tuple> +#include <array> +#include <utility> + +constexpr int f( int x, int y, int z ) +{ + return x * 100 + y * 10 + z; +} + +constexpr int g( int x, int y ) +{ + return x * 10 + y; +} + +constexpr int h() +{ + return 11; +} + +int main() +{ + { + constexpr std::tuple<int, short, char> tp{ 1, 2, 3 }; + constexpr auto r = boost::mp11::tuple_apply( f, tp ); + static_assert( r == 123, "r == 123" ); + } + + { + constexpr std::pair<short, char> tp{ 1, 2 }; + constexpr auto r = boost::mp11::tuple_apply( g, tp ); + static_assert( r == 12, "r == 12" ); + } + + { + constexpr std::array<short, 3> tp{{ 1, 2, 3 }}; + constexpr auto r = boost::mp11::tuple_apply( f, tp ); + static_assert( r == 123, "r == 123" ); + } + +#if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 9 +// "error: default initialization of an object of const type 'const std::tuple<>' without a user-provided default constructor" +#else + + { + constexpr std::tuple<> tp; + constexpr auto r = boost::mp11::tuple_apply( h, tp ); + static_assert( r == 11, "r == 11" ); + } + +#endif +} + +#endif diff --git a/src/boost/libs/mp11/test/tuple_for_each.cpp b/src/boost/libs/mp11/test/tuple_for_each.cpp new file mode 100644 index 000000000..a7e9428b6 --- /dev/null +++ b/src/boost/libs/mp11/test/tuple_for_each.cpp @@ -0,0 +1,175 @@ + +// Copyright 2015 Peter Dimov. +// +// 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 + + +#if defined(_MSC_VER) +#pragma warning( disable: 4244 ) // 'initializing': conversion from 'int' to 'char', possible loss of data +#endif + +#include <boost/mp11/tuple.hpp> +#include <boost/core/lightweight_test.hpp> +#include <tuple> +#include <memory> +#include <utility> +#include <array> + +int main() +{ + using boost::mp11::tuple_for_each; + + { + std::tuple<int, short, char> tp{ 1, 2, 3 }; + + { + int s = 0; + + tuple_for_each( tp, [&]( int x ){ s = s * 10 + x; } ); + + BOOST_TEST_EQ( s, 123 ); + } + + { + int s = 0; + + tuple_for_each( std::move(tp), [&]( int x ){ s = s * 10 + x; } ); + + BOOST_TEST_EQ( s, 123 ); + } + } + + { + std::tuple<int, short, char> const tp{ 1, 2, 3 }; + + { + int s = 0; + + tuple_for_each( tp, [&]( int x ){ s = s * 10 + x; } ); + + BOOST_TEST_EQ( s, 123 ); + } + + { + int s = 0; + + tuple_for_each( std::move(tp), [&]( int x ){ s = s * 10 + x; } ); + + BOOST_TEST_EQ( s, 123 ); + } + } + +#if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 8 +#else + + { + std::tuple<std::unique_ptr<int>, std::unique_ptr<int>, std::unique_ptr<int>> tp{ std::unique_ptr<int>(new int(1)), std::unique_ptr<int>(new int(2)), std::unique_ptr<int>(new int(3)) }; + + int s = 0; + + tuple_for_each( std::move(tp), [&]( std::unique_ptr<int> p ){ s = s * 10 + *p; } ); + + BOOST_TEST_EQ( s, 123 ); + } + +#endif + + { + std::pair<int, short> tp{ 1, 2 }; + + { + int s = 0; + + tuple_for_each( tp, [&]( int x ){ s = s * 10 + x; } ); + + BOOST_TEST_EQ( s, 12 ); + } + + { + int s = 0; + + tuple_for_each( std::move(tp), [&]( int x ){ s = s * 10 + x; } ); + + BOOST_TEST_EQ( s, 12 ); + } + } + + { + std::pair<int, short> const tp{ 1, 2 }; + + { + int s = 0; + + tuple_for_each( tp, [&]( int x ){ s = s * 10 + x; } ); + + BOOST_TEST_EQ( s, 12 ); + } + + { + int s = 0; + + tuple_for_each( std::move(tp), [&]( int x ){ s = s * 10 + x; } ); + + BOOST_TEST_EQ( s, 12 ); + } + } + + { + std::array<int, 3> tp{{ 1, 2, 3 }}; + + { + int s = 0; + + tuple_for_each( tp, [&]( int x ){ s = s * 10 + x; } ); + + BOOST_TEST_EQ( s, 123 ); + } + + { + int s = 0; + + tuple_for_each( std::move(tp), [&]( int x ){ s = s * 10 + x; } ); + + BOOST_TEST_EQ( s, 123 ); + } + } + + { + std::array<int, 3> const tp{{ 1, 2, 3 }}; + + { + int s = 0; + + tuple_for_each( tp, [&]( int x ){ s = s * 10 + x; } ); + + BOOST_TEST_EQ( s, 123 ); + } + + { + int s = 0; + + tuple_for_each( std::move(tp), [&]( int x ){ s = s * 10 + x; } ); + + BOOST_TEST_EQ( s, 123 ); + } + } + + { + std::tuple<> tp; + + BOOST_TEST_EQ( tuple_for_each( tp, 11 ), 11 ); + BOOST_TEST_EQ( tuple_for_each( std::move( tp ), 12 ), 12 ); + } + + { + std::array<int, 0> tp; + + BOOST_TEST_EQ( tuple_for_each( tp, 11 ), 11 ); + BOOST_TEST_EQ( tuple_for_each( std::move( tp ), 12 ), 12 ); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/tuple_for_each_cx.cpp b/src/boost/libs/mp11/test/tuple_for_each_cx.cpp new file mode 100644 index 000000000..7316f30b3 --- /dev/null +++ b/src/boost/libs/mp11/test/tuple_for_each_cx.cpp @@ -0,0 +1,58 @@ + +// Copyright 2015 Peter Dimov. +// +// 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 + + +#if defined(_MSC_VER) +#pragma warning( disable: 4244 ) // 'initializing': conversion from 'int' to 'char', possible loss of data +#endif + +#include <boost/mp11/tuple.hpp> +#include <boost/mp11/detail/config.hpp> + +// Technically std::tuple isn't constexpr enabled in C++11, but it works with libstdc++ + +#if defined( BOOST_MP11_NO_CONSTEXPR ) || ( !defined(_MSC_VER) && !defined( __GLIBCXX__ ) && __cplusplus < 201400L ) + +int main() {} + +#else + +#include <tuple> +#include <type_traits> + +struct assert_is_integral +{ + template<class T> constexpr bool operator()( T ) const + { + static_assert( std::is_integral<T>::value, "T must be an integral type" ); + return true; + } +}; + +int main() +{ + { + constexpr std::tuple<int, short, char> tp{ 1, 2, 3 }; + constexpr auto r = boost::mp11::tuple_for_each( tp, assert_is_integral() ); + (void)r; + } + +#if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 9 +// "error: default initialization of an object of const type 'const std::tuple<>' without a user-provided default constructor" +#else + + { + constexpr std::tuple<> tp; + constexpr auto r = boost::mp11::tuple_for_each( tp, 11 ); + static_assert( r == 11, "r == 11" ); + } + +#endif +} + +#endif diff --git a/src/boost/libs/mp11/test/tuple_transform.cpp b/src/boost/libs/mp11/test/tuple_transform.cpp new file mode 100644 index 000000000..22ed0ea0c --- /dev/null +++ b/src/boost/libs/mp11/test/tuple_transform.cpp @@ -0,0 +1,190 @@ + +// Copyright 2020 Hans Dembinski. +// +// 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/mp11/tuple.hpp> +#include <boost/core/lightweight_test.hpp> +#include <boost/core/lightweight_test_trait.hpp> +#include <tuple> +#include <utility> +#include <iosfwd> + +// family of test types with state +template <int N> +struct T { + int value; + T() : value{N} {}; + explicit T(int n) : value{n} {} +}; + +template <int N> +std::ostream& operator<<( std::ostream& os, T<N> const& t ) +{ + os << t.value; + return os; +} + +// test function changes type and value +struct F { + template<int N, int M=1> T<N+M> operator()( T<N> a, T<M> b={} ) const + { + return T<N+M>{a.value + b.value + 1}; + } +}; + +int main() +{ + using boost::mp11::tuple_transform; + + { + std::tuple<T<1>, T<2>, T<3>> tp; + std::tuple<T<4>, T<5>, T<6>> tp2; + + { + std::tuple<T<2>, T<3>, T<4>> s = tuple_transform( F{}, tp ); + BOOST_TEST_EQ( std::get<0>(s).value, 3 ); + BOOST_TEST_EQ( std::get<1>(s).value, 4 ); + BOOST_TEST_EQ( std::get<2>(s).value, 5 ); + } + + { + std::tuple<T<2>, T<3>, T<4>> s = tuple_transform( F{}, std::move(tp) ); + BOOST_TEST_EQ( std::get<0>(s).value, 3 ); + BOOST_TEST_EQ( std::get<1>(s).value, 4 ); + BOOST_TEST_EQ( std::get<2>(s).value, 5 ); + } + + { + std::tuple<T<5>, T<7>, T<9>> s = tuple_transform( F{}, tp, tp2 ); + BOOST_TEST_EQ( std::get<0>(s).value, 6 ); + BOOST_TEST_EQ( std::get<1>(s).value, 8 ); + BOOST_TEST_EQ( std::get<2>(s).value, 10 ); + } + + { + std::tuple<T<5>, T<7>, T<9>> s = tuple_transform( + F{}, std::move(tp), std::move(tp2) + ); + BOOST_TEST_EQ( std::get<0>(s).value, 6 ); + BOOST_TEST_EQ( std::get<1>(s).value, 8 ); + BOOST_TEST_EQ( std::get<2>(s).value, 10 ); + } + } + + { + std::tuple<T<1>, T<2>, T<3>> const tp; + std::tuple<T<4>, T<5>, T<6>> const tp2; + + { + std::tuple<T<2>, T<3>, T<4>> s = tuple_transform( F{}, tp ); + BOOST_TEST_EQ( std::get<0>(s).value, 3 ); + BOOST_TEST_EQ( std::get<1>(s).value, 4 ); + BOOST_TEST_EQ( std::get<2>(s).value, 5 ); + } + + { + std::tuple<T<2>, T<3>, T<4>> s = tuple_transform( F{}, std::move(tp) ); + BOOST_TEST_EQ( std::get<0>(s).value, 3 ); + BOOST_TEST_EQ( std::get<1>(s).value, 4 ); + BOOST_TEST_EQ( std::get<2>(s).value, 5 ); + } + + { + std::tuple<T<5>, T<7>, T<9>> s = tuple_transform( F{}, tp, tp2 ); + BOOST_TEST_EQ( std::get<0>(s).value, 6 ); + BOOST_TEST_EQ( std::get<1>(s).value, 8 ); + BOOST_TEST_EQ( std::get<2>(s).value, 10 ); + } + + { + std::tuple<T<5>, T<7>, T<9>> s = tuple_transform( + F{}, std::move(tp), std::move(tp2) + ); + BOOST_TEST_EQ( std::get<0>(s).value, 6 ); + BOOST_TEST_EQ( std::get<1>(s).value, 8 ); + BOOST_TEST_EQ( std::get<2>(s).value, 10 ); + } + } + + { + std::pair<T<1>, T<2>> tp; + std::pair<T<3>, T<4>> tp2; + + { + std::tuple<T<2>, T<3>> s = tuple_transform( F{}, tp ); + BOOST_TEST_EQ( std::get<0>(s).value, 3 ); + BOOST_TEST_EQ( std::get<1>(s).value, 4 ); + } + + { + std::tuple<T<2>, T<3>> s = tuple_transform( F{}, std::move(tp) ); + BOOST_TEST_EQ( std::get<0>(s).value, 3 ); + BOOST_TEST_EQ( std::get<1>(s).value, 4 ); + } + + { + std::tuple<T<4>, T<6>> s = tuple_transform( F{}, tp, tp2 ); + BOOST_TEST_EQ( std::get<0>(s).value, 5 ); + BOOST_TEST_EQ( std::get<1>(s).value, 7 ); + } + + { + std::tuple<T<4>, T<6>> s = tuple_transform( + F{}, std::move(tp), std::move(tp2) + ); + BOOST_TEST_EQ( std::get<0>(s).value, 5 ); + BOOST_TEST_EQ( std::get<1>(s).value, 7 ); + } + } + + { + std::pair<T<1>, T<2>> const tp; + std::pair<T<3>, T<4>> const tp2; + + { + std::tuple<T<2>, T<3>> s = tuple_transform( F{}, tp ); + BOOST_TEST_EQ( std::get<0>(s).value, 3 ); + BOOST_TEST_EQ( std::get<1>(s).value, 4 ); + } + + { + std::tuple<T<2>, T<3>> s = tuple_transform( F{}, std::move(tp) ); + BOOST_TEST_EQ( std::get<0>(s).value, 3 ); + BOOST_TEST_EQ( std::get<1>(s).value, 4 ); + } + + { + std::tuple<T<4>, T<6>> s = tuple_transform( F{}, tp, tp2 ); + BOOST_TEST_EQ( std::get<0>(s).value, 5 ); + BOOST_TEST_EQ( std::get<1>(s).value, 7 ); + } + + { + std::tuple<T<4>, T<6>> s = tuple_transform( + F{}, std::move(tp), std::move(tp2) + ); + BOOST_TEST_EQ( std::get<0>(s).value, 5 ); + BOOST_TEST_EQ( std::get<1>(s).value, 7 ); + } + } + + { + std::tuple<> tp; + + { + auto s = tuple_transform( F{}, tp ); + BOOST_TEST_TRAIT_TRUE((std::is_same<decltype(s), std::tuple<>>)); + } + + { + auto s = tuple_transform( F{}, std::move(tp) ); + BOOST_TEST_TRAIT_TRUE((std::is_same<decltype(s), std::tuple<>>)); + } + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/tuple_transform_2.cpp b/src/boost/libs/mp11/test/tuple_transform_2.cpp new file mode 100644 index 000000000..0c556ef7f --- /dev/null +++ b/src/boost/libs/mp11/test/tuple_transform_2.cpp @@ -0,0 +1,166 @@ +// Copyright 2020 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/mp11/tuple.hpp> +#include <boost/mp11/algorithm.hpp> +#include <boost/core/lightweight_test.hpp> +#include <tuple> +#include <utility> +#include <array> +#include <cstddef> + +int f( int x ) +{ + return x + 1; +} + +int g( int x, int y ) +{ + return x + y; +} + +int h( int x, int y, int z ) +{ + return x + y + z; +} + +int q( int x, int y, int z, int v ) +{ + return x + y + z + v; +} + +template<class T1, class... T> std::array<T1, 1 + sizeof...(T)> make_array( T1 t1, T... t ) +{ + return { { t1, t... } }; +} + +template<class Tp> struct test_element +{ + Tp& tp; + + template<int I> void operator()( boost::mp11::mp_int<I> ) const + { + BOOST_TEST_EQ( std::get<I>( tp ), q( I, I, I, I ) ); + } +}; + +int main() +{ + using boost::mp11::tuple_transform; + + // + + { + std::tuple<int> r = tuple_transform( f, std::make_tuple( 1 ) ); + + BOOST_TEST_EQ( std::get<0>( r ), 2 ); + } + + { + std::tuple<int> r = tuple_transform( f, ::make_array( 1 ) ); + + BOOST_TEST_EQ( std::get<0>( r ), 2 ); + } + + { + std::tuple<int> r = tuple_transform( g, ::make_array( 1 ), std::make_tuple( 2 ) ); + + BOOST_TEST_EQ( std::get<0>( r ), 3 ); + } + + { + std::tuple<int> r = tuple_transform( h, ::make_array( 1 ), std::make_tuple( 2 ), ::make_array( 3 ) ); + + BOOST_TEST_EQ( std::get<0>( r ), 6 ); + } + + // + + { + std::tuple<int, int> r = tuple_transform( f, std::make_tuple( 1, 2 ) ); + + BOOST_TEST_EQ( std::get<0>( r ), 2 ); + BOOST_TEST_EQ( std::get<1>( r ), 3 ); + } + + { + std::tuple<int, int> r = tuple_transform( f, std::make_pair( 1, 2 ) ); + + BOOST_TEST_EQ( std::get<0>( r ), 2 ); + BOOST_TEST_EQ( std::get<1>( r ), 3 ); + } + + { + std::tuple<int, int> r = tuple_transform( f, ::make_array( 1, 2 ) ); + + BOOST_TEST_EQ( std::get<0>( r ), 2 ); + BOOST_TEST_EQ( std::get<1>( r ), 3 ); + } + + { + std::tuple<int, int> r = tuple_transform( g, ::make_array( 1, 2 ), std::make_pair( 3, 4 ) ); + + BOOST_TEST_EQ( std::get<0>( r ), 4 ); + BOOST_TEST_EQ( std::get<1>( r ), 6 ); + } + + { + std::tuple<int, int> r = tuple_transform( h, ::make_array( 1, 2 ), std::make_pair( 3, 4 ), std::make_tuple( 5, 6 ) ); + + BOOST_TEST_EQ( std::get<0>( r ), 9 ); + BOOST_TEST_EQ( std::get<1>( r ), 12 ); + } + + // + + { + std::tuple<int, int, int> r = tuple_transform( f, std::make_tuple( 1, 2, 3 ) ); + + BOOST_TEST_EQ( std::get<0>( r ), 2 ); + BOOST_TEST_EQ( std::get<1>( r ), 3 ); + BOOST_TEST_EQ( std::get<2>( r ), 4 ); + } + + { + std::tuple<int, int, int> r = tuple_transform( f, ::make_array( 1, 2, 3 ) ); + + BOOST_TEST_EQ( std::get<0>( r ), 2 ); + BOOST_TEST_EQ( std::get<1>( r ), 3 ); + BOOST_TEST_EQ( std::get<2>( r ), 4 ); + } + + { + std::tuple<int, int, int> r = tuple_transform( g, ::make_array( 1, 2, 3 ), std::make_tuple( 4, 5, 6 ) ); + + BOOST_TEST_EQ( std::get<0>( r ), 5 ); + BOOST_TEST_EQ( std::get<1>( r ), 7 ); + BOOST_TEST_EQ( std::get<2>( r ), 9 ); + } + + { + std::tuple<int, int, int> r = tuple_transform( h, ::make_array( 1, 2, 3 ), std::make_tuple( 4, 5, 6 ), ::make_array( 7, 8, 9 ) ); + + BOOST_TEST_EQ( std::get<0>( r ), 12 ); + BOOST_TEST_EQ( std::get<1>( r ), 15 ); + BOOST_TEST_EQ( std::get<2>( r ), 18 ); + } + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1900 ) + + { + using namespace boost::mp11; + + int const N = 12; + + using Tp = mp_rename<mp_iota< mp_int<N> >, std::tuple>; + + auto const r = tuple_transform( q, Tp(), Tp(), Tp(), Tp() ); + + mp_for_each<Tp>( test_element<decltype(r)>{ r } ); + } + +#endif + + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/tuple_transform_cx.cpp b/src/boost/libs/mp11/test/tuple_transform_cx.cpp new file mode 100644 index 000000000..f5e7dbdbe --- /dev/null +++ b/src/boost/libs/mp11/test/tuple_transform_cx.cpp @@ -0,0 +1,65 @@ +// Copyright 2015, 2020 Peter Dimov +// Copyright 2020 Hans Dembinski +// +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include <boost/mp11/tuple.hpp> +#include <boost/mp11/detail/config.hpp> + +// Technically std::tuple isn't constexpr enabled in C++11, but it works with libstdc++ + +#if defined( BOOST_MP11_NO_CONSTEXPR ) || ( !defined(_MSC_VER) && !defined( __GLIBCXX__ ) && __cplusplus < 201400L ) || BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 40800 ) + +int main() {} + +#else + +#include <tuple> +#include <utility> + +constexpr int f( int x ) +{ + return x + 1; +} + +constexpr int g( int x, int y ) +{ + return x + y + 1; +} + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +int main() +{ + { + constexpr std::tuple<int, int, int> tp( 1, 2, 3 ); + + constexpr auto r = boost::mp11::tuple_transform( f, tp ); + + STATIC_ASSERT( r == std::make_tuple( 2, 3, 4 ) ); + } + + { + constexpr std::tuple<int, int> tp1( 1, 2 ); + constexpr std::pair<int, int> tp2( 3, 4 ); + + constexpr auto r = boost::mp11::tuple_transform( g, tp1, tp2 ); + + STATIC_ASSERT( r == std::make_tuple( 5, 7 ) ); + } + +#if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 9 +// "error: default initialization of an object of const type 'const std::tuple<>' without a user-provided default constructor" +#else + + { + constexpr std::tuple<> tp; + constexpr std::tuple<> r = boost::mp11::tuple_transform( f, tp ); + (void)r; + } + +#endif +} + +#endif diff --git a/src/boost/libs/mp11/test/tuple_version.cpp b/src/boost/libs/mp11/test/tuple_version.cpp new file mode 100644 index 000000000..d4d80f59e --- /dev/null +++ b/src/boost/libs/mp11/test/tuple_version.cpp @@ -0,0 +1,17 @@ + +// Copyright 2019 Peter Dimov +// +// 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/mp11/tuple.hpp> +#include <boost/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_MP11_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/utility_version.cpp b/src/boost/libs/mp11/test/utility_version.cpp new file mode 100644 index 000000000..64a84eae2 --- /dev/null +++ b/src/boost/libs/mp11/test/utility_version.cpp @@ -0,0 +1,17 @@ + +// Copyright 2019 Peter Dimov +// +// 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/mp11/utility.hpp> +#include <boost/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_MP11_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/test/version.cpp b/src/boost/libs/mp11/test/version.cpp new file mode 100644 index 000000000..0b8d4a59b --- /dev/null +++ b/src/boost/libs/mp11/test/version.cpp @@ -0,0 +1,17 @@ + +// Copyright 2019 Peter Dimov +// +// 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/mp11/version.hpp> +#include <boost/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_MP11_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} diff --git a/src/boost/libs/mp11/tools/single-header.bat b/src/boost/libs/mp11/tools/single-header.bat new file mode 100644 index 000000000..52edfac91 --- /dev/null +++ b/src/boost/libs/mp11/tools/single-header.bat @@ -0,0 +1 @@ +python2.7 tools\single-header.py > include\boost\mp11_single.hpp
\ No newline at end of file diff --git a/src/boost/libs/mp11/tools/single-header.py b/src/boost/libs/mp11/tools/single-header.py new file mode 100644 index 000000000..c5af76df2 --- /dev/null +++ b/src/boost/libs/mp11/tools/single-header.py @@ -0,0 +1,54 @@ + +# Copyright 2017 Peter Dimov. +# +# 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 + +import os.path +import re +import sys + +included = [] + +def scan_header( prefix, dir, fn ): + + path = os.path.join( prefix, dir, fn ) + + if path in included: + + return + + included.append( path ) + + with open( path, 'r' ) as header: + + for line in header: + + m = re.match( '[ \t]*#[ \t]*include[ \t]*(["<])([^">]*)[">]', line ) + + r = False + + if m: + + h = m.group( 2 ) + + hfn1 = os.path.join( prefix, h ) + hfn2 = os.path.join( prefix, dir, h ) + + if m.group( 1 ) == '"' and os.path.exists( hfn2 ): + + scan_header( prefix, os.path.join( dir, os.path.dirname( hfn2 ) ), os.path.basename( hfn2 ) ) + r = True + + elif os.path.exists( hfn1 ): + + scan_header( prefix, os.path.dirname( h ), os.path.basename( h ) ) + r = True + + if not r: + + sys.stdout.write( line ) + +scan_header( 'include', 'boost', 'mp11.hpp' ) |