GSI Forum
GSI Helmholtzzentrum für Schwerionenforschung

Home » Scientific Computing » C++ » The power of templates!
icon14.gif  The power of templates! [message #1560] Fri, 01 April 2005 00:42
Anar Manafov is currently offline  Anar Manafov
Messages: 81
Registered: August 2004
Location: Germany, Darmstadt
continuous participant

There are classes A and B. How to check that B is inherited from class A? Smile 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(...);
   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? Smile

Extensible Templates: Via Inheritance or Traits?

1 horsepower = 745.699872 Watts
Read Message icon14.gif
Previous Topic: Exceptional C++
Next Topic: Anar's Wiki - C++ Development
Goto Forum:

Current Time: Mon Jul 15 13:11:25 CEST 2024

Total time taken to generate the page: 0.00695 seconds