mp_replace_at_c.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. struct X5 {};
  18. int main()
  19. {
  20. using boost::mp11::mp_list;
  21. using boost::mp11::mp_replace_at_c;
  22. {
  23. using L = mp_list<X1, X2, X3, X4, X5>;
  24. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 0, void>, mp_list<void, X2, X3, X4, X5>>));
  25. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 1, void>, mp_list<X1, void, X3, X4, X5>>));
  26. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 2, void>, mp_list<X1, X2, void, X4, X5>>));
  27. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 3, void>, mp_list<X1, X2, X3, void, X5>>));
  28. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 4, void>, mp_list<X1, X2, X3, X4, void>>));
  29. }
  30. {
  31. using L = std::tuple<X1, X2, X3, X4, X5>;
  32. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 0, void>, std::tuple<void, X2, X3, X4, X5>>));
  33. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 1, void>, std::tuple<X1, void, X3, X4, X5>>));
  34. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 2, void>, std::tuple<X1, X2, void, X4, X5>>));
  35. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 3, void>, std::tuple<X1, X2, X3, void, X5>>));
  36. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 4, void>, std::tuple<X1, X2, X3, X4, void>>));
  37. }
  38. {
  39. using L = std::pair<X1, X2>;
  40. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 0, void>, std::pair<void, X2>>));
  41. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_at_c<L, 1, void>, std::pair<X1, void>>));
  42. }
  43. return boost::report_errors();
  44. }