Можете ли вы использовать концепции C++ так же, как и полиморфные интерфейсы?C++

Программы на C++. Форум разработчиков
Anonymous
Можете ли вы использовать концепции C++ так же, как и полиморфные интерфейсы?

Сообщение Anonymous »


I have just stumbled over C++20's "concepts", something that I've wanted in the language for years... well kind of.

Consider the code below:

#include #include template concept IFoo = requires(T t) { { t.foo() } -> std::convertible_to; }; class FooImpl { public: int foo() const { return 3; } }; template void doSomething(const Foo& foo) { std::cout

Источник: https://stackoverflow.com/questions/780 ... interfaces

Вернуться в «C++»