Jpp  18.0.1-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JConversion.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JCONVERSION__
2 #define __JLANG__JCONVERSION__
3 
4 #include <type_traits>
5 #include "JLang/JAssert.hh"
6 
7 
8 /**
9  * \author mdejong
10  */
11 
12 namespace JLANG {}
13 namespace JPP { using namespace JLANG; }
14 
15 namespace JLANG {
16 
17 
18  /**
19  * Template class test for polymorphism.
20  */
21  template<class JDerived_t, class JBase_t>
22  struct JConversion {
23  static const bool is_derived = std::is_base_of<JBase_t, JDerived_t>::value; //!< true, if JDerived_t derives from JBase_t
24  static const bool is_same = std::is_same <JBase_t, JDerived_t>::value; //!< true, if JDerived_t is equal to JBase_t
25  };
26 
27 
28  /**
29  * Specialisation of JConversion for identical types.
30  */
31  template<class T>
32  struct JConversion<T,T>
33  {
34  static const bool is_derived = true;
35  static const bool is_same = true;
36  };
37 
38 
39  /**
40  * Auxialiary class to assert type conversion.
41  */
42  template<class JDerived_t, class JBase_t, bool is_derived = JConversion<JDerived_t,JBase_t>::is_derived>
44 
45  /**
46  * Implementation of a valid type conversion.
47  */
48  template<class JDerived_t, class JBase_t>
49  class JAssertConversion<JDerived_t, JBase_t, true> {};
50 }
51 
52 #endif
static const bool is_same
true, if JDerived_t is equal to JBase_t
Definition: JConversion.hh:24
Auxialiary class to assert type conversion.
Definition: JConversion.hh:43
static const bool is_derived
true, if JDerived_t derives from JBase_t
Definition: JConversion.hh:23
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Template class test for polymorphism.
Definition: JConversion.hh:22