diff --git a/include/boost/mp11/utility.hpp b/include/boost/mp11/utility.hpp index b6ac117..a438a33 100644 --- a/include/boost/mp11/utility.hpp +++ b/include/boost/mp11/utility.hpp @@ -101,6 +101,30 @@ struct mp_no_type template class F, class... T> using mp_defer = mp_if, detail::mp_defer_impl, detail::mp_no_type>; +// mp_quote +template class F> struct mp_quote +{ + template using apply = F; +}; + +// mp_unquote +namespace detail +{ + +template struct mp_unquote_impl +{ + using type = typename Q::template apply; +}; + +template class F, class... T> struct mp_unquote_impl, T...> +{ + using type = F; +}; + +} // namespace detail + +template using mp_unquote = typename detail::mp_unquote_impl::type; + } // namespace boost #endif // #ifndef BOOST_MP11_UTILITY_HPP_INCLUDED diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1499b23..76efec9 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -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) ; diff --git a/test/mp_quote.cpp b/test/mp_quote.cpp new file mode 100644 index 0000000..74a8193 --- /dev/null +++ b/test/mp_quote.cpp @@ -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 +#include +#include + +struct X {}; + +int main() +{ + using boost::mp_identity_t; + using boost::mp_quote; + using boost::mp_unquote; + + using Q = mp_quote; + + BOOST_TEST_TRAIT_TRUE((std::is_same, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, int[]>)); + + return boost::report_errors(); +}