• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright 2015, 2017 Peter Dimov.
3 //
4 // Distributed under the Boost Software License, Version 1.0.
5 //
6 // See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt
8 
9 
10 #include <boost/mp11/utility.hpp>
11 #include <boost/mp11/detail/config.hpp>
12 #include <boost/core/lightweight_test_trait.hpp>
13 #include <type_traits>
14 
15 using boost::mp11::mp_invoke_q;
16 
17 template<class...> struct X {};
18 
19 template<template<class...> class F, class... T> using Y = X<F<T>...>;
20 
21 template<class Q, class... T> using Z = X<mp_invoke_q<Q, T>...>;
22 
23 template<class T, class U> struct P {};
24 
25 template<class T, class U> using first = T;
26 
main()27 int main()
28 {
29     using boost::mp11::mp_identity_t;
30     using boost::mp11::mp_quote;
31 
32     {
33         using Q = mp_quote<mp_identity_t>;
34 
35         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, void>, void>));
36         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, int[]>, int[]>));
37     }
38 
39     {
40         using Q = mp_quote<mp_identity_t>;
41 
42 #if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 )
43         using R1 = Y<Q::fn, void, char, int>;
44         BOOST_TEST_TRAIT_TRUE((std::is_same<R1, X<void, char, int>>));
45 #endif
46 
47 #if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 && BOOST_MP11_MSVC >= 1900 )
48         using R2 = Z<Q, void, char, int>;
49         BOOST_TEST_TRAIT_TRUE((std::is_same<R2, X<void, char, int>>));
50 #endif
51     }
52 
53     {
54         using Q = mp_quote<P>;
55 
56         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, void, void>, P<void, void>>));
57         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, char[], int[]>, P<char[], int[]>>));
58     }
59 
60     {
61         using Q = mp_quote<first>;
62 
63         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, void, int>, void>));
64         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke_q<Q, char[], int[]>, char[]>));
65     }
66 
67     return boost::report_errors();
68 }
69