mirror of https://github.com/edouarda/brigand.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.3 KiB
C++
57 lines
2.3 KiB
C++
#include <brigand/algorithms/partition.hpp>
|
|
#include <brigand/algorithms/wrap.hpp>
|
|
#include <brigand/functions/lambda/bind.hpp>
|
|
#include <brigand/sequences/list.hpp>
|
|
#include <brigand/types/integer.hpp>
|
|
#include <type_traits>
|
|
|
|
template <typename N>
|
|
using is_odd = brigand::size_t<(N::value % 2) != 0>;
|
|
|
|
template <unsigned int... List>
|
|
using size_t_list = brigand::integral_list<unsigned int, List...>;
|
|
|
|
using odd_list = size_t_list<1, 3, 5, 7, 9, 11>;
|
|
using even_list = size_t_list<0, 2, 4, 6, 8, 10>;
|
|
using full_list = size_t_list<0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11>;
|
|
|
|
brigand::partition<odd_list, brigand::bind<is_odd, brigand::_1>> partition_test1 =
|
|
brigand::pair<odd_list, size_t_list<>>{};
|
|
brigand::partition<even_list, brigand::bind<is_odd, brigand::_1>> partition_test2 =
|
|
brigand::pair<size_t_list<>, even_list>{};
|
|
brigand::partition<full_list, brigand::bind<is_odd, brigand::_1>> partition_test3 =
|
|
brigand::pair<odd_list, even_list>{};
|
|
|
|
brigand::partition<size_t_list<>, brigand::bind<is_odd, brigand::_1>> partition_test4 =
|
|
brigand::pair<size_t_list<>, size_t_list<>>{};
|
|
|
|
brigand::partition<brigand::list<int, float, char, double>, std::is_floating_point<brigand::_1>>
|
|
partition_test5 = brigand::pair<brigand::list<float, double>, brigand::list<int, char>>{};
|
|
// custom list tests
|
|
namespace custom
|
|
{
|
|
template <class...>
|
|
class custom_list
|
|
{
|
|
};
|
|
template <unsigned int... List>
|
|
using size_t_list = brigand::wrap<brigand::integral_list<unsigned int, List...>, custom_list>;
|
|
|
|
using odd_list = size_t_list<1, 3, 5, 7, 9, 11>;
|
|
using even_list = size_t_list<0, 2, 4, 6, 8, 10>;
|
|
using full_list = size_t_list<0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11>;
|
|
|
|
brigand::partition<odd_list, brigand::bind<is_odd, brigand::_1>> partition_test1 =
|
|
brigand::pair<odd_list, size_t_list<>>{};
|
|
brigand::partition<even_list, brigand::bind<is_odd, brigand::_1>> partition_test2 =
|
|
brigand::pair<size_t_list<>, even_list>{};
|
|
brigand::partition<full_list, brigand::bind<is_odd, brigand::_1>> partition_test3 =
|
|
brigand::pair<odd_list, even_list>{};
|
|
|
|
brigand::partition<size_t_list<>, brigand::bind<is_odd, brigand::_1>> partition_test4 =
|
|
brigand::pair<size_t_list<>, size_t_list<>>{};
|
|
|
|
brigand::partition<brigand::list<int, float, char, double>, std::is_floating_point<brigand::_1>>
|
|
partition_test5 = brigand::pair<brigand::list<float, double>, brigand::list<int, char>>{};
|
|
}
|