I don't think this is possible in C++, what options do I have to simulate the behavior?
Use std::is_base_of
as:
template<typename T>
class A
{
static_assert(std::is_base_of<IMyInterface, T>::value,
"T must derive from IMyInterface");
};
You can same in function template as well.
You can use std::is_base_of<YourInterface, YourParameter>
, and make an error if the result is false
. Remember this is C++11.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With