1// Origin: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
2// Special g++ Options: -O1
3
4#include <map>
5#include <cstdlib>
6
7using namespace std;
8
9class NAMES_ITEM
10    {
11public:
12    char *name;
13
14      NAMES_ITEM(const NAMES_ITEM& item2);
15
16      NAMES_ITEM(const char* name2);
17
18      ~NAMES_ITEM();
19
20      bool operator==(const NAMES_ITEM& n) const;
21    };
22
23
24NAMES_ITEM::NAMES_ITEM (const NAMES_ITEM& item2)
25        {
26        size_t length=std::strlen(item2.name);
27
28        name=new char[length+1];
29        std::memcpy(name,item2.name,length+1);
30        }
31
32NAMES_ITEM::NAMES_ITEM (const char* name2)
33        {
34        size_t length=std::strlen(name2);
35
36        name=new char[length+1];
37        std::memcpy(name,name2,length+1);
38        }
39
40NAMES_ITEM::~NAMES_ITEM ()
41{
42  if (std::strcmp (name, "one") != 0)
43    abort ();
44
45  name=0;
46}
47
48bool NAMES_ITEM::operator==(const NAMES_ITEM& n) const
49{
50  return (std::strcmp(name,n.name) == 0);
51}
52
53bool operator<(const NAMES_ITEM& n1, const NAMES_ITEM& n2)
54    {
55    return (std::strcmp(n1.name,n2.name) < 0);
56    }
57
58    typedef map<NAMES_ITEM,size_t,less<NAMES_ITEM> > lookup_t;
59
60    lookup_t lookup;
61
62	NAMES_ITEM item ("one");
63main()
64  {
65        lookup.insert(pair<NAMES_ITEM,size_t>(item,0));
66  }
67
68