Можете ли вы использовать концепции C++ так же, как и полиморфные интерфейсы? ⇐ C++
Можете ли вы использовать концепции C++ так же, как и полиморфные интерфейсы?
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
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
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Как я могу использовать полиморфные атрибуты с Boost :: Spirit :: Qi Parsers?
Anonymous » » в форуме C++ - 0 Ответы
- 9 Просмотры
-
Последнее сообщение Anonymous
-