#include using namespace std; /* -------------------- Namespaces -------------------- */ namespace test { typedef const int type; static constexpr type n = 0; //Template functions template constexpr LType coalesce(const LType &left, const RType &right); #if __cplusplus >= 201103L template constexpr LType coalesce(const LType &left, const RType &right, const Args &...args); #endif template constexpr test::type compare(const LType &left, const RType &right); template constexpr Type divide(const Type &left, const Type &right); template constexpr bool equals(const LType &left, const RType &right); template constexpr Return cast(const Type &val); template constexpr Type minus(const Type &left, const Type &right); template constexpr Type modulus(const Type &left, const Type &right); template constexpr Type multiply(const Type &left, const Type &right); template constexpr Type negate(const Type &val); template constexpr bool isnot(const Type &val); template constexpr bool isnull(const Type &val); template constexpr Type plus(const Type &left, const Type &right); template void print(const Type &val); //Classes class TestA2; class TestA12; template struct TestB3; struct TestD3; class TestH3; } using test::coalesce; /* -------------------- Template functions -------------------- */ template constexpr LType test::coalesce(const LType &left, const RType &right){ return (left)? left : right; } #if __cplusplus >= 201103L template constexpr LType test::coalesce(const LType &left, const RType &right, const Args &...args){ return (left)? left : coalesce(right,args...); } #endif template constexpr test::type test::compare(const LType &left, const RType &right){ return (left constexpr Type test::divide(const Type &left, const Type &right){ return left/right; } template constexpr bool test::equals(const LType &left, const RType &right){ return (left==right); } template constexpr Return test::cast(const Type &val){ return (Return)val; } template constexpr Type test::minus(const Type &left, const Type &right){ return left-right; } template constexpr Type test::modulus(const Type &left, const Type &right){ return left%right; } template constexpr Type test::multiply(const Type &left, const Type &right){ return left*right; } template constexpr Type test::negate(const Type &val){ return -val; } template constexpr bool test::isnot(const Type &val){ return !val; } template constexpr bool test::isnull(const Type &val){ return (val==NULL); } template constexpr Type test::plus(const Type &left, const Type &right){ return left+right; } template void test::print(const Type &val){ std::cout << val << std::endl; } template constexpr Type test42() noexcept { return coalesce(N,42); } /* -------------------- Classes -------------------- */ struct TestA1 { int test(){ return 42; } }; class test::TestA2 { int test(){ return 42; } }; struct TestA3 : TestA1 { int test(){ return 42; } }; class TestA4 : private TestA1 { int test(){ return 42; } }; struct TestA5 : protected TestA1 { int test(){ return 42; } }; class TestA6 : public TestA1 { int test(){ return 42; } }; struct TestA7 final : virtual TestA1 { int test(){ return 42; } }; class TestA8 : public virtual TestA1 { int test(){ return 42; } }; struct TestA9 final : virtual public TestA1 { int test(){ return 42; } }; class TestA10 : TestA1, test::TestA2, TestA3 { int test(){ return 42; } }; struct TestA11 : private TestA1, protected test::TestA2, public TestA3 { int test(){ return 42; } }; class test::TestA12 : TestA1, protected test::TestA2, public virtual TestA3 { int test(){ return 42; } }; struct TestA13 final : public virtual TestA1, protected test::TestA2, TestA3 { int test(){ return 42; } }; /* -------------------- Template classes -------------------- */ template struct TestB1 { int test(){ return 42; } }; template class TestB2 { int test(){ return 42; } }; template struct test::TestB3 { int test(){ return 42; } }; template class TestB4 { int test(){ return 42; } }; template struct TestB5 { int test(){ return 42; } }; template struct TestB6 { int test(){ return 42; } }; template > struct TestB7 { int test(){ return 42; } }; template class TestB8 { int test(){ return 42; } }; template struct TestB9 { int test(){ return 42; } }; template