4 * This program checks if the compiler / platform supports the
5 * std::unique_ptr<> correctly. The motivation for this test was a discussion
6 * on the development mailing list, and the documentation was captured
9 * http://bugzilla.dre.vanderbilt.edu/show_bug.cgi?id=3715
12 #include "test_config.h"
14 // The first part of the test is to compile this line. If the program
15 // does not compile the platform is just too broken.
19 // For extra challenge, we use the anonymous namespace
41 static int constructors
;
42 static int destructors
;
45 int Base::constructors
= 0;
46 int Base::destructors
= 0;
48 class Derived
: public Base
58 run_main (int, ACE_TCHAR
*[])
60 ACE_START_TEST (ACE_TEXT("Compiler_Features_09_Test"));
62 // As usual, the exit status from the test is 0 on success, 1 on
66 // ... this works with the ACE version of unique_ptr (well, the
67 // namespace is broken, but you get the idea) ...
68 std::unique_ptr
<Base
> x(new Base
);
69 std::unique_ptr
<Derived
> y(new Derived
);
71 // ... with a compliant implementation of std::unique_ptr<> you should be
76 // ... there should be just one destruction so far ...
77 if (Base::destructors
!= 1)
81 ACE_TEXT("Destructor count off, expected 1, found %d\n"),
85 std::unique_ptr
<Base
> z
;
87 if (Base::destructors
!= 1)
91 ACE_TEXT("Destructor count off, expected 1, found %d\n"),
98 ACE_TEXT("x contents should have been transferred\n")