swap.cpp 961 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2015.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include <boost/metaparse/v1/swap.hpp>
  6. #include <boost/type_traits/is_same.hpp>
  7. #include <boost/mpl/assert.hpp>
  8. #include "test_case.hpp"
  9. namespace
  10. {
  11. struct returns_first
  12. {
  13. typedef returns_first type;
  14. template <class A, class>
  15. struct apply
  16. {
  17. typedef A type;
  18. };
  19. };
  20. struct returns_second
  21. {
  22. typedef returns_second type;
  23. template <class, class B>
  24. struct apply
  25. {
  26. typedef B type;
  27. };
  28. };
  29. }
  30. BOOST_METAPARSE_TEST_CASE(swap)
  31. {
  32. using boost::metaparse::v1::swap;
  33. using boost::is_same;
  34. BOOST_MPL_ASSERT((
  35. is_same<double, swap<returns_first>::apply<int, double>::type>
  36. ));
  37. BOOST_MPL_ASSERT((
  38. is_same<int, swap<returns_second>::apply<int, double>::type>
  39. ));
  40. }