Код: Выделить всё
template
constexpr auto foo(T arg, Callable&& make)
-> decltype(make(std::declval())) {
return make(arg);
}
Теперь я делаю следующее:
Код: Выделить всё
template
constexpr auto bar(T arg, Callable&& make){
return make(arg);
}
Код: Выделить всё
barЭто полный пример:
Код: Выделить всё
#include
#include
#include
template
constexpr auto foo(T arg, Callable&& make)
-> decltype(make(std::declval())) {
return make(arg);
}
template
constexpr auto bar(T arg, Callable&& make) {
return make(arg);
}
double make_double(int i) { return 3.14 * i; }
int make_int(int i) { return i; }
int main() {
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79815483/how-to-apply-a-concept-to-a-trailing-return-type[/url]
Мобильная версия