Passing a concept to a function
Is there any way to get closer to this?
Well, no, not really. Not in C++20. There is no notion in the language today of a template concept-parameter. Even variable templates cannot be used as template parameters. So if have a concept to begin with, we can't avoid wrapping.
But what we can do is write simpler wrappers. If we agree to use "old style" type traits as predicates, specifically those that behave like std::integral_constant
s, then we can have ourselves pretty terse "concept" definitions that can be used as predicates.
template<typename T>
using FloatLike = std::is_same<T, float>;
template<template <typename> class Predicate, typename... T>
constexpr bool all_types()
{
return (Predicate<T>{} && ...);
}
It's as good as it can get, as far as I can see.