2 * This program checks if the compiler / platform supports the
3 * standard cast operators template parameters. The motivation for
4 * this test was a discussion on the development mailing list, and the
5 * documentation was captured in:
7 * http://bugzilla.dre.vanderbilt.edu/show_bug.cgi?id=3715
10 #include "test_config.h"
18 * Helper class for test
27 * Helper class for test
29 struct Derived
: public Base
35 * Helper class for test
37 struct Another
: public Base
45 run_main (int, ACE_TCHAR
*[])
47 ACE_START_TEST (ACE_TEXT("Compiler_Features_13_Test"));
49 // As usual, the exit status from the test is 0 on success, 1 on
54 // Make sure const cast works. Compilation is interesting, the
55 // functionality test here is just to make sure the compiler does
56 // not optimize things away ...
59 const_cast<int&>(y
) = 3;
65 ACE_TEXT("Wrong value after const_cast,")
66 ACE_TEXT(" expected %d, got %d\n"),
71 // Make sure dynamic cast through pointers work ...
75 Derived
* d1
= dynamic_cast<Derived
*>(b1
);
80 ACE_TEXT("dynamic_cast returns null, expected value\n")));
88 ACE_TEXT("Wrong value after dynamic_cast, expected %d, got %d\n"),
93 // Make sure dynamic cast detects invalid casts
96 Derived
* d2
= dynamic_cast<Derived
*>(b2
);
101 ACE_TEXT("dynamic_cast should return null\n")));
104 // Make sure dynamic cast raises a bad_cast exception
108 (void) dynamic_cast<Derived
&>(b3
);
112 ACE_TEXT("dynamic_cast should have raised std::bad_cast\n")));
114 catch(std::bad_cast
const &)
121 ACE_TEXT("dynamic_cast should have raised std::bad_cast\n")));
125 // Just test these compile ...
127 int y
= static_cast<int>(x
);
128 void * z
= reinterpret_cast<void*>(y
);
133 ACE_TEXT("My hack to make sure the code is not ")
134 ACE_TEXT("optimized away backfired!\n")));