forked from boostorg/mp11
Add mp_quote, mp_unquote.
This commit is contained in:
@@ -101,6 +101,30 @@ struct mp_no_type
|
||||
|
||||
template<template<class...> class F, class... T> using mp_defer = mp_if<mp_valid<F, T...>, detail::mp_defer_impl<F, T...>, detail::mp_no_type>;
|
||||
|
||||
// mp_quote
|
||||
template<template<class...> class F> struct mp_quote
|
||||
{
|
||||
template<class... T> using apply = F<T...>;
|
||||
};
|
||||
|
||||
// mp_unquote
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class Q, class... T> struct mp_unquote_impl
|
||||
{
|
||||
using type = typename Q::template apply<T...>;
|
||||
};
|
||||
|
||||
template<template<class...> class F, class... T> struct mp_unquote_impl<mp_quote<F>, T...>
|
||||
{
|
||||
using type = F<T...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class Q, class... T> using mp_unquote = typename detail::mp_unquote_impl<Q, T...>::type;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_MP11_UTILITY_HPP_INCLUDED
|
||||
|
@@ -66,6 +66,7 @@ run mp_if.cpp : : : $(REQ) ;
|
||||
run mp_eval_if.cpp : : : $(REQ) ;
|
||||
run mp_valid.cpp : : : $(REQ) ;
|
||||
run mp_defer.cpp : : : $(REQ) ;
|
||||
run mp_quote.cpp : : : $(REQ) ;
|
||||
|
||||
# integer_sequence
|
||||
run integer_sequence.cpp : : : $(REQ) ;
|
||||
|
28
test/mp_quote.cpp
Normal file
28
test/mp_quote.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
// Copyright 2015 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>
|
||||
|
||||
struct X {};
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp_identity_t;
|
||||
using boost::mp_quote;
|
||||
using boost::mp_unquote;
|
||||
|
||||
using Q = mp_quote<mp_identity_t>;
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unquote<Q, void>, void>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_unquote<Q, int[]>, int[]>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user