Is there equivalent of extends T>
, super T>
in C++?
Also, does extends T>
,
It doesn't have quite nice syntactic sugar as in Java but it's manageable well with boost/type_traits . See http://www.boost.org/doc/libs/1_40_0/libs/type_traits/doc/html/index.html for more info.
#include
#include
class Base {};
class Derived_from_Base : public Base {};
class Not_derived_from_Base {};
template
void workOnBase()
{
BOOST_STATIC_ASSERT((boost::is_base_of ::value));
}
int main()
{
workOnBase (); // OK
workOnBase (); // FAIL
return 0;
}
1>d:...\main.cpp(11) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE' 1> with 1> [ 1> x=false 1> ]