early-access version 3088

This commit is contained in:
pineappleEA
2022-11-05 15:35:56 +01:00
parent 4e4fc25ce3
commit b601909c6d
35519 changed files with 5996896 additions and 860 deletions

View File

@@ -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()

View File

@@ -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 ;

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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>)

View File

@@ -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;
}

View File

@@ -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>)

View File

@@ -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;
}

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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()
{
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

Some files were not shown because too many files have changed in this diff Show More