Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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
12namespace JLANG {}
13namespace JPP { using namespace JLANG; }
14
15namespace 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
Auxialiary class to assert type conversion.
Auxiliary classes and methods for language specific functionality.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Template class test for polymorphism.
static const bool is_same
true, if JDerived_t is equal to JBase_t
static const bool is_derived
true, if JDerived_t derives from JBase_t