#ifndef __JLANG__JCONVERSION__ #define __JLANG__JCONVERSION__ #include "JLang/JAssert.hh" #include "JLang/JTest.hh" /** * \author mdejong */ namespace JLANG {} namespace JPP { using namespace JLANG; } namespace JLANG { /** * Template class test for polymorphism. */ template class JConversion { /** * Test convertibility of two classes. * * Source code is taken from reference: * A. Alexandrescu, Modern C++ Design, Addison Wesley. */ template class JLocal : public JTest { using JTest::test; static JTrue test(const base_type&); static derived_type getReference(); public: static const bool is_derived = JTEST(test(getReference())); static const bool is_same = false; }; public: static const bool is_derived = JLocal::is_derived; //!< true, if JDerived_t derives from JBase_t static const bool is_same = JLocal::is_same; //!< true, if JDerived_t is equal to JBase_t }; /** * Specialisation of JConversion for identical types. */ template struct JConversion { static const bool is_derived = true; static const bool is_same = true; }; /** * Auxialiary class to assert type conversion. */ template::is_derived> class JAssertConversion; /** * Implementation of a valid type conversion. */ template class JAssertConversion {}; } #endif