mp_remove.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2015 Peter Dimov.
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. //
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. #include <boost/mp11/algorithm.hpp>
  8. #include <boost/mp11/list.hpp>
  9. #include <boost/core/lightweight_test_trait.hpp>
  10. #include <type_traits>
  11. #include <tuple>
  12. struct X1 {};
  13. struct X2 {};
  14. struct X3 {};
  15. int main()
  16. {
  17. using boost::mp11::mp_list;
  18. using boost::mp11::mp_remove;
  19. {
  20. using L1 = mp_list<>;
  21. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L1, void>, L1>));
  22. using L2 = mp_list<X1, X2, X3, X2, X3, X3>;
  23. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, void>, L2>));
  24. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X1>, mp_list<X2, X3, X2, X3, X3>>));
  25. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X2>, mp_list<X1, X3, X3, X3>>));
  26. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X3>, mp_list<X1, X2, X2>>));
  27. }
  28. {
  29. using L1 = std::tuple<>;
  30. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L1, void>, L1>));
  31. using L2 = std::tuple<X1, X2, X3, X2, X3, X3>;
  32. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, void>, L2>));
  33. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X1>, std::tuple<X2, X3, X2, X3, X3>>));
  34. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X2>, std::tuple<X1, X3, X3, X3>>));
  35. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_remove<L2, X3>, std::tuple<X1, X2, X2>>));
  36. }
  37. return boost::report_errors();
  38. }