I wish to know if it's possible in C++ to somehow handle the following situations:
Situation 1) (Easily handled)
class BasicFacility { }
template <typename U1, typename U2> class Facility : public BasicFacility { }
Suppose now that we want to have some compilation-time assertion and we want to check if the arbitrary type typename T
models the Facility
. This is pretty simple:
(boost::is_base_of<BasicFacility, T>::type)
Situation 2) (???)
Now let's assume that in the same situation we just have our template class:
template <typename U1, typename U2> class Facility { }
Obviously we can't use the same solution from situation one, because we can't write statement<Facility, T>
(Facility
is a template itself).
So, is there a way (maybe, dirty, involving ugly casts, alignment-specific, ANYTHING that might work) to check if some T
actually equals some template type
without introducing specific empty (auxiliary) base classes (because sometimes you simply can't) ?
Thank you.
It's pretty straightforward to roll your own test:
template <typename T>
struct is_facility : public boost::false_type { };
template <typename U1, typename U2>
struct is_facility< Facility<U1, U2> > : public boost::true_type { };
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