GSI Forum - RDF feed
type: channel
description: GSI Helmholtzzentrum für Schwerionenforschung
items: The power of templates!

The power of templates!
type: item
description: There are classes A and B. How to check that B is inherited from class A? Compile-time task. It could be useful for someone: template<typename A, typename B> class isd { class no{}; class yes{no[2]}; static yes test(B*); static no test(...); public: enum {is=sizeof(test(static_cast<A*>(0)))==sizeof(yes)}; }; Just read the code.......................... Now you understand what this code is made for?! Do you see the power?! This is just an ART, isn't it? Extensible Templates: Via Inheritance or Traits?
creator: Anar Manafov
date: 2005-03-31T22:42:39-00:00