Предположим следующую концепцию C++:
Код: Выделить всё
template
concept has_set = requires(T t, std::string s) {
{ t.set(s) } -> std::same_as; };
};
Код: Выделить всё
template
concept has_set = requires(T t, std::convertible_to s) {
{ t.set(s) } -> std::same_as; };
};
Код: Выделить всё
std::string use(has_set auto & f) { /* ... use f.set(...) ... */ }
Подробнее здесь: https://stackoverflow.com/questions/791 ... hen-use-it
Мобильная версия