Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / tests / Compiler_Features_07_Test.cpp
blobbf4933326c3c9cf2f3d43cc068589ef161cd84a9
1 /**
2 * @file
4 * This program checks if the compiler / platform supports the
5 * std::set container. The motivation for this test was a discussion
6 * on the development mailing list, and the documentation was captured
7 * in:
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.
16 #include <set>
17 #include <string>
19 int
20 run_main (int, ACE_TCHAR *[])
22 ACE_START_TEST (ACE_TEXT("Compiler_Features_07_Test"));
24 // As usual, the exit status from the test is 0 on success, 1 on
25 // failure
26 int status = 0;
28 // Create a simple list ...
29 using collection = std::set<std::string>;
30 collection c;
32 // ... insert some elements ...
33 c.insert("5");
34 c.insert("4");
35 c.insert("3");
36 c.insert("2");
37 c.insert(std::string("1"));
39 // ... inserting twice returns a pair ...
40 std::pair<collection::iterator,bool> r =
41 c.insert(collection::value_type("5"));
43 // ... the iterator points to the element ...
44 if (*r.first != std::string("5"))
46 status = 1;
47 ACE_ERROR ((LM_ERROR, ACE_TEXT("Expected to find 5 already in set")));
50 // ... and the booleans says that it is already in the set ...
51 if (r.second == true)
53 status = 1;
54 ACE_ERROR ((LM_ERROR, ACE_TEXT("Expected duplicate insert to fail")));
57 // ... find an element and erase it ...
58 collection::iterator i;
60 i = c.find(std::string("4"));
61 if (i == c.end())
63 status = 1;
64 ACE_ERROR((LM_ERROR, ACE_TEXT("Element not found")));
66 else
68 // ... this demonstrates a standard STL technique, you can
69 // optimize lookups by using the iterators returned in search
70 // functions ...
71 c.erase(i);
74 ACE_END_TEST;
75 return status;