I have a simple metafunction:
template <typename T>
using is_const_lvalue_reference = mpl::and_<
std::is_lvalue_reference<T>,
std::is_const<typename std::remove_reference<T>::type>
>;
Apparently, it doesn't work if T
is an MPL placeholder because remove_reference
is evaluated for the placeholder class instead of the substituted type. How to do this correctly to be able to use this metafunction in MPL algorithms?
UPDATE: The suggested solution was to replace the alias with a struct, which will delay the template instantiation in std::remove_reference
. The question is, how to delay the instantiation inline, not using any helper structs?
template <typename Sequence>
using are_const_lvalue_references = mpl::fold<
Sequence,
mpl::true_,
mpl::and_<
mpl::_1,
mpl::and_<
std::is_lvalue_reference<mpl::_2>,
std::is_const<typename std::remove_reference<mpl::_2>::type>
>
>
>;
This example will apparently fail for the same reason. What should I change to make it correct?