Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
23.associative.stdcxx-16.cpp
Go to the documentation of this file.
1
28#include <set>
29#include <map>
30#include <cassert>
31
32template <class T>
34{
36
38
40
41 bool operator() (const T& t1, const T& t2) const {
42 return mode == normal ? t1 < t2 : t2 < t1;
43 }
44};
45
46template <class T>
47bool operator== (const RuntimeCmp <T>& lc, const RuntimeCmp <T>& rc) {
48 return lc.mode == rc.mode;
49}
50
51typedef std::set <int, RuntimeCmp <int> > IntSet;
52typedef std::map <int, int, RuntimeCmp <int> > IntMap;
53
54int main ()
55{
56 RuntimeCmp <int> reverse_order (RuntimeCmp<int>::reverse);
57
58 IntSet set1;
59 IntSet set2 (reverse_order);
60 set1 = set2;
61 assert (set1.key_comp () == set2.key_comp ());
62 assert (set1.value_comp () == set2.value_comp ());
63
64 IntMap map1;
65 IntMap map2 (reverse_order);
66 map1 = map2;
67 assert (map1.key_comp () == map2.key_comp ());
68
69 return 0;
70}
#define m
Definition 17.names.cpp:129
#define T
Definition 17.names.cpp:163
#define t1
Definition 17.names.cpp:243
#define t2
Definition 17.names.cpp:269
bool operator==(const RuntimeCmp< T > &lc, const RuntimeCmp< T > &rc)
std::set< int, RuntimeCmp< int > > IntSet
std::map< int, int, RuntimeCmp< int > > IntMap
#define assert(expr)
Definition _cassert.h:40
std::multiset< int, std::less< int >, std::allocator< int > > IntSet
Definition multiset.cpp:38
RuntimeCmp(cmp_mode m=normal)
bool operator()(const T &t1, const T &t2) const