The question is pretty much given in the titel. Please considere the following godbolted code:
#include <iostream>
struct Base{};
struct Derived : Base{};
template<typename T>
concept IsDerivedFromBase = std::same_as<T, Base>;
template<typename T>
concept IsNotDerivedFromBase = not IsDerivedFromBase<T>;
template <IsDerivedFromBase T>
void foo(T bar) {std::cout << "IsBase" << std::endl;}
template <IsNotDerivedFromBase T>
void foo(T bar) {std::cout << "IsNotBase" << std::endl;}
int main()
{
Base a;
foo(a);
Derived b;
foo(b);
Base* c = new Derived{};
foo(*c);
delete c;
}
The output of the above code reads:
IsBase
IsNotBase
IsBase
I am asking if it is possible to modify the concepts somehow in order to mimic polymorphism. The output should read:
IsBase
IsNotBase
IsNotBase