912b2d45a4d40a6fcb28df04b29485a74a2ea6dd
[libcds.git] / tests / test-hdr / size_check.h
1 //$$CDS-header$$
2
3 #ifndef __CDSTEST_SIZE_CHECK_H
4 #define __CDSTEST_SIZE_CHECK_H
5
6 #include <cds/cxx11_atomic.h>
7
8 namespace misc {
9
10     template <typename ItemCounter>
11     struct size_checker {
12         template <typename Container>
13         bool operator()( Container const& c, size_t nSize ) const
14         {
15             return c.size() == nSize;
16         }
17     };
18
19     template<>
20     struct size_checker< cds::atomicity::empty_item_counter > {
21         template <typename Container>
22         bool operator()( Container const& /*c*/, size_t /*nSize*/ ) const
23         {
24             return true;
25         }
26     };
27
28     template <class Container>
29     static inline bool check_size( Container const& cont, size_t nSize )
30     {
31         return size_checker<typename Container::item_counter>()( cont, nSize );
32     }
33
34 } // namespace misc
35
36 #endif // #ifndef __CDSTEST_SIZE_CHECK_H