mp_quote.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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/utility.hpp>
  8. #include <boost/mp11/detail/config.hpp>
  9. #include <boost/core/lightweight_test_trait.hpp>
  10. #include <type_traits>
  11. using boost::mp11::mp_invoke_q;
  12. template<class...> struct X {};
  13. template<template<class...> class F, class... T> using Y = X<F<T>...>;
  14. template<class Q, class... T> using Z = X<mp_invoke_q<Q, T>...>;
  15. template<class T, class U> struct P {};
  16. template<class T, class U> using first = T;
  17. int main()
  18. {
  19. using boost::mp11::mp_identity_t;
  20. using boost::mp11::mp_quote;
  21. {
  22. using Q = mp_quote<mp_identity_t>;
  23. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, void>, void>));
  24. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, int[]>, int[]>));
  25. }
  26. {
  27. using Q = mp_quote<mp_identity_t>;
  28. #if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 )
  29. using R1 = Y<Q::fn, void, char, int>;
  30. BOOST_TEST_TRAIT_TRUE((std::is_same<R1, X<void, char, int>>));
  31. #endif
  32. #if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 && BOOST_MP11_MSVC >= 1900 )
  33. using R2 = Z<Q, void, char, int>;
  34. BOOST_TEST_TRAIT_TRUE((std::is_same<R2, X<void, char, int>>));
  35. #endif
  36. }
  37. {
  38. using Q = mp_quote<P>;
  39. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, void, void>, P<void, void>>));
  40. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, char[], int[]>, P<char[], int[]>>));
  41. }
  42. {
  43. using Q = mp_quote<first>;
  44. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, void, int>, void>));
  45. BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, char[], int[]>, char[]>));
  46. }
  47. return boost::report_errors();
  48. }