OSDN Git Service

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