forked from boostorg/mp11
Add indirection in mp_quote to enable expansions of T... into a fixed parameter list
This commit is contained in:
@@ -106,7 +106,16 @@ template<template<class...> class F, class... T> using mp_defer = mp_if<mp_valid
|
|||||||
// mp_quote
|
// mp_quote
|
||||||
template<template<class...> class F, class... T> struct mp_quote
|
template<template<class...> class F, class... T> struct mp_quote
|
||||||
{
|
{
|
||||||
template<class... U> using fn = F<T..., U...>;
|
private:
|
||||||
|
|
||||||
|
template<class... U> struct _fn { using type = F<T..., U...>; };
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// the indirection through _fn works around the language inability
|
||||||
|
// to expand T.. to expand into a fixed parameter list of an alias template
|
||||||
|
|
||||||
|
template<class... U> using fn = typename _fn<U...>::type;
|
||||||
};
|
};
|
||||||
|
|
||||||
// mp_unquote
|
// mp_unquote
|
||||||
|
@@ -35,6 +35,11 @@ struct Q4
|
|||||||
template<class T1, class... T> using fn = T1;
|
template<class T1, class... T> using fn = T1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Q5
|
||||||
|
{
|
||||||
|
template<class T1, class T2> using fn = T2;
|
||||||
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q1>, void>));
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q1>, void>));
|
||||||
@@ -52,5 +57,7 @@ int main()
|
|||||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q4, int>, int>));
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q4, int>, int>));
|
||||||
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q4, int[], char[]>, int[]>));
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q4, int[], char[]>, int[]>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q5, int, float>, float>));
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ struct D1: B {};
|
|||||||
struct D2: B {};
|
struct D2: B {};
|
||||||
struct ND {};
|
struct ND {};
|
||||||
|
|
||||||
template<class... T> using is_base_of_t = typename std::is_base_of<T...>::type;
|
template<class T, class U> using is_base_of_t = typename std::is_base_of<T, U>::type;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -54,10 +54,11 @@ int main()
|
|||||||
{
|
{
|
||||||
using Q = mp_quote<mp_identity_t>;
|
using Q = mp_quote<mp_identity_t>;
|
||||||
|
|
||||||
// using R1 = Y<Q::fn, void, char, int>;
|
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
|
||||||
// BOOST_TEST_TRAIT_TRUE((std::is_same<R1, X<void, char, int>>));
|
#else
|
||||||
//
|
using R1 = Y<Q::fn, void, char, int>;
|
||||||
// error: pack expansion used as argument for non-pack parameter of alias template
|
BOOST_TEST_TRAIT_TRUE((std::is_same<R1, X<void, char, int>>));
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1910 && BOOST_MSVC >= 1900 )
|
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1910 && BOOST_MSVC >= 1900 )
|
||||||
#else
|
#else
|
||||||
|
Reference in New Issue
Block a user