1 #ifndef ACE_TESTS_STL_ALGORITHM_TEST_T_CPP
2 #define ACE_TESTS_STL_ALGORITHM_TEST_T_CPP
4 #include "test_config.h"
12 Element_Counter (void)
18 void operator () (typename
T::value_type
& item
)
21 ACE_UNUSED_ARG (item
);
24 Element_Counter
& operator = (const Element_Counter
& ec
)
26 this->count_
= ec
.count_
;
30 typename
T::difference_type
get_count () const
36 // Number of elements iterated over.
37 typename
T::difference_type count_
;
41 int test_STL_algorithm (T
& container
)
43 // We are only validating that the container's iterators
44 // compile with the <algorithm> header.
46 ACE_TEXT ("running STL algorithm test for `%s'\n"),
49 // Test the forward iterator using std::for_each.
51 "testing forward iterator\n"));
53 typename
T::difference_type count
=
54 std::for_each (container
.begin (),
56 Element_Counter
<T
> ()).get_count ();
59 "std::for_each handled %d elements\n",
62 // Test the reverse iterator using std::for_each.
64 "testing reverse iterator\n"));
67 std::for_each (container
.rbegin (),
69 Element_Counter
<T
> ()).get_count ();
72 "std::for_each handled %d elements\n",
78 #endif /* ACE_TESTS_STL_ALGORITHM_TEST_T_CPP */