From d5e39913c856b46ba7137a487f2089715c8ee333 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 26 Jun 2017 16:07:23 +0300 Subject: [PATCH] Add mp_quote_trait --- include/boost/mp11/utility.hpp | 6 +++++ test/Jamfile | 1 + test/mp_invoke_sf.cpp | 11 +++++++++ test/mp_quote.cpp | 2 +- test/mp_quote_trait.cpp | 41 ++++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 test/mp_quote_trait.cpp diff --git a/include/boost/mp11/utility.hpp b/include/boost/mp11/utility.hpp index bf58361..f82d613 100644 --- a/include/boost/mp11/utility.hpp +++ b/include/boost/mp11/utility.hpp @@ -116,6 +116,12 @@ template class F> struct mp_quote template using fn = typename mp_defer::type; }; +// mp_quote_trait +template class F> struct mp_quote_trait +{ + template using fn = typename F::type; +}; + // mp_invoke #if BOOST_WORKAROUND( BOOST_MSVC, < 1900 ) diff --git a/test/Jamfile b/test/Jamfile index dbcd718..05eefac 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -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) ; diff --git a/test/mp_invoke_sf.cpp b/test/mp_invoke_sf.cpp index 7c2feb6..f100670 100644 --- a/test/mp_invoke_sf.cpp +++ b/test/mp_invoke_sf.cpp @@ -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)); BOOST_TEST_TRAIT_FALSE((mp_valid)); + using Qt = mp_quote_trait; + +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) +#else + BOOST_TEST_TRAIT_FALSE((mp_valid)); +#endif + BOOST_TEST_TRAIT_TRUE((mp_valid)); + BOOST_TEST_TRAIT_FALSE((mp_valid)); + return boost::report_errors(); } diff --git a/test/mp_quote.cpp b/test/mp_quote.cpp index 9d2ca6a..0e5d1a5 100644 --- a/test/mp_quote.cpp +++ b/test/mp_quote.cpp @@ -1,5 +1,5 @@ -// Copyright 2015, 2017 Peter Dimov. +// Copyright 2015, 2017 Peter Dimov. // // Distributed under the Boost Software License, Version 1.0. // diff --git a/test/mp_quote_trait.cpp b/test/mp_quote_trait.cpp new file mode 100644 index 0000000..dd0018c --- /dev/null +++ b/test/mp_quote_trait.cpp @@ -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 +#include +#include + +int main() +{ + using boost::mp11::mp_identity; + using boost::mp11::mp_quote_trait; + using boost::mp11::mp_invoke; + + { + using Q = mp_quote_trait; + + BOOST_TEST_TRAIT_TRUE((std::is_same, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, int[]>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same, void>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, int[]>)); + } + + { + using Q = mp_quote_trait; + + BOOST_TEST_TRAIT_TRUE((std::is_same, void const>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, int const[]>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same, void const>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, int const[]>)); + } + + return boost::report_errors(); +}