forked from boostorg/mp11
Add mp_quote_trait
This commit is contained in:
@@ -116,6 +116,12 @@ template<template<class...> class F> struct mp_quote
|
|||||||
template<class... T> using fn = typename mp_defer<F, T...>::type;
|
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
|
// mp_invoke
|
||||||
#if BOOST_WORKAROUND( BOOST_MSVC, < 1900 )
|
#if BOOST_WORKAROUND( BOOST_MSVC, < 1900 )
|
||||||
|
|
||||||
|
@@ -89,6 +89,7 @@ run mp_defer.cpp : : : $(REQ) ;
|
|||||||
run mp_quote.cpp : : : $(REQ) ;
|
run mp_quote.cpp : : : $(REQ) ;
|
||||||
run mp_invoke.cpp : : : $(REQ) ;
|
run mp_invoke.cpp : : : $(REQ) ;
|
||||||
run mp_invoke_sf.cpp : : : $(REQ) ;
|
run mp_invoke_sf.cpp : : : $(REQ) ;
|
||||||
|
run mp_quote_trait.cpp : : : $(REQ) ;
|
||||||
|
|
||||||
# integer_sequence
|
# integer_sequence
|
||||||
run integer_sequence.cpp : : : $(REQ) ;
|
run integer_sequence.cpp : : : $(REQ) ;
|
||||||
|
@@ -13,7 +13,9 @@
|
|||||||
|
|
||||||
using boost::mp11::mp_invoke;
|
using boost::mp11::mp_invoke;
|
||||||
using boost::mp11::mp_quote;
|
using boost::mp11::mp_quote;
|
||||||
|
using boost::mp11::mp_quote_trait;
|
||||||
using boost::mp11::mp_valid;
|
using boost::mp11::mp_valid;
|
||||||
|
using boost::mp11::mp_identity;
|
||||||
using boost::mp11::mp_identity_t;
|
using boost::mp11::mp_identity_t;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@@ -29,5 +31,14 @@ int main()
|
|||||||
BOOST_TEST_TRAIT_TRUE((mp_valid<mp_invoke, Qi, void>));
|
BOOST_TEST_TRAIT_TRUE((mp_valid<mp_invoke, Qi, void>));
|
||||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke, Qi, void, 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();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
// Copyright 2015, 2017 Peter Dimov.
|
// Copyright 2015, 2017 Peter Dimov.
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
//
|
//
|
||||||
|
41
test/mp_quote_trait.cpp
Normal file
41
test/mp_quote_trait.cpp
Normal 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();
|
||||||
|
}
|
Reference in New Issue
Block a user