Use =default for skeleton copy constructor
[ACE_TAO.git] / ACE / tests / STL_algorithm_Test_T.cpp
blob50c830ed1ec6b97d9959bf5576f11ae9fdebd153
1 #ifndef ACE_TESTS_STL_ALGORITHM_TEST_T_CPP
2 #define ACE_TESTS_STL_ALGORITHM_TEST_T_CPP
4 #include "test_config.h"
5 #include <algorithm>
6 #include <typeinfo>
8 template <typename T>
9 class Element_Counter
11 public:
12 Element_Counter ()
13 : count_ (0)
17 void operator () (typename T::value_type & item)
19 ++ this->count_;
20 ACE_UNUSED_ARG (item);
23 Element_Counter & operator = (const Element_Counter & ec)
25 this->count_ = ec.count_;
26 return *this;
29 typename T::difference_type get_count () const
31 return this->count_;
34 private:
35 // Number of elements iterated over.
36 typename T::difference_type count_;
39 template <typename T>
40 int test_STL_algorithm (T & container)
42 // We are only validating that the container's iterators
43 // compile with the <algorithm> header.
44 ACE_DEBUG ((LM_DEBUG,
45 ACE_TEXT ("running STL algorithm test for `%s'\n"),
46 typeid (T).name ()));
48 // Test the forward iterator using std::for_each.
49 ACE_DEBUG ((LM_DEBUG,
50 "testing forward iterator\n"));
52 typename T::difference_type count =
53 std::for_each (container.begin (),
54 container.end (),
55 Element_Counter <T> ()).get_count ();
57 ACE_DEBUG ((LM_DEBUG,
58 "std::for_each handled %d elements\n",
59 count));
61 // Test the reverse iterator using std::for_each.
62 ACE_DEBUG ((LM_DEBUG,
63 "testing reverse iterator\n"));
65 count =
66 std::for_each (container.rbegin (),
67 container.rend (),
68 Element_Counter <T> ()).get_count ();
70 ACE_DEBUG ((LM_DEBUG,
71 "std::for_each handled %d elements\n",
72 count));
74 return 0;
77 #endif /* ACE_TESTS_STL_ALGORITHM_TEST_T_CPP */