1
0
forked from boostorg/mp11

Add mp_quote_trait

This commit is contained in:
Peter Dimov
2017-06-26 16:07:23 +03:00
parent a81745308c
commit d5e39913c8
5 changed files with 60 additions and 1 deletions

View File

@@ -116,6 +116,12 @@ template<template<class...> class F> struct mp_quote
template<class... T> using fn = typename mp_defer<F, T...>::type;
};
// mp_quote_trait
template<template<class...> class F> struct mp_quote_trait
{
template<class... T> using fn = typename F<T...>::type;
};
// mp_invoke
#if BOOST_WORKAROUND( BOOST_MSVC, < 1900 )

View File

@@ -89,6 +89,7 @@ run mp_defer.cpp : : : $(REQ) ;
run mp_quote.cpp : : : $(REQ) ;
run mp_invoke.cpp : : : $(REQ) ;
run mp_invoke_sf.cpp : : : $(REQ) ;
run mp_quote_trait.cpp : : : $(REQ) ;
# integer_sequence
run integer_sequence.cpp : : : $(REQ) ;

View File

@@ -13,7 +13,9 @@
using boost::mp11::mp_invoke;
using boost::mp11::mp_quote;
using boost::mp11::mp_quote_trait;
using boost::mp11::mp_valid;
using boost::mp11::mp_identity;
using boost::mp11::mp_identity_t;
int main()
@@ -29,5 +31,14 @@ int main()
BOOST_TEST_TRAIT_TRUE((mp_valid<mp_invoke, Qi, void>));
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke, Qi, void, void>));
using Qt = mp_quote_trait<mp_identity>;
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
#else
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke, Qt>));
#endif
BOOST_TEST_TRAIT_TRUE((mp_valid<mp_invoke, Qt, void>));
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke, Qt, void, void>));
return boost::report_errors();
}

View File

@@ -1,5 +1,5 @@
// Copyright 2015, 2017 Peter Dimov.
// Copyright 2015, 2017 Peter Dimov.
//
// Distributed under the Boost Software License, Version 1.0.
//

41
test/mp_quote_trait.cpp Normal file
View File

@@ -0,0 +1,41 @@
// Copyright 2015, 2017 Peter Dimov.
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/mp11/utility.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
int main()
{
using boost::mp11::mp_identity;
using boost::mp11::mp_quote_trait;
using boost::mp11::mp_invoke;
{
using Q = mp_quote_trait<mp_identity>;
BOOST_TEST_TRAIT_TRUE((std::is_same<Q::fn<void>, void>));
BOOST_TEST_TRAIT_TRUE((std::is_same<Q::fn<int[]>, int[]>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q, void>, void>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q, int[]>, int[]>));
}
{
using Q = mp_quote_trait<std::add_const>;
BOOST_TEST_TRAIT_TRUE((std::is_same<Q::fn<void>, void const>));
BOOST_TEST_TRAIT_TRUE((std::is_same<Q::fn<int[]>, int const[]>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q, void>, void const>));
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q, int[]>, int const[]>));
}
return boost::report_errors();
}