mp_replace_third.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2015, 2017 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. #include <utility>
  13. struct X1 {};
  14. struct X2 {};
  15. struct X3 {};
  16. struct X4 {};
  17. int main()
  18. {
  19. using boost::mp11::mp_list;
  20. using boost::mp11::mp_replace_third;
  21. {
  22. using L3 = mp_list<X1, X2, X3>;
  23. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_third<L3, void>, mp_list<X1, X2, void>>));
  24. using L4 = mp_list<X1, X2, X3, X4>;
  25. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_third<L4, void>, mp_list<X1, X2, void, X4>>));
  26. }
  27. {
  28. using L3 = std::tuple<X1, X2, X3>;
  29. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_third<L3, void>, std::tuple<X1, X2, void>>));
  30. using L4 = std::tuple<X1, X2, X3, X4>;
  31. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_third<L4, void>, std::tuple<X1, X2, void, X4>>));
  32. }
  33. return boost::report_errors();
  34. }