OSDN Git Service

Add NIOS2 support. Code from SourceyG++.
[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 #include <cstring>
8
9 using namespace std;
10
11 class NAMES_ITEM
12     {
13 public:
14     char *name;
15
16       NAMES_ITEM(const NAMES_ITEM& item2);
17
18       NAMES_ITEM(const char* name2);
19
20       ~NAMES_ITEM();
21
22       bool operator==(const NAMES_ITEM& n) const;
23     };
24
25
26 NAMES_ITEM::NAMES_ITEM (const NAMES_ITEM& item2)
27         {
28         size_t length=std::strlen(item2.name);
29
30         name=new char[length+1];
31         std::memcpy(name,item2.name,length+1);
32         }
33
34 NAMES_ITEM::NAMES_ITEM (const char* name2)      
35         {
36         size_t length=std::strlen(name2);
37
38         name=new char[length+1];
39         std::memcpy(name,name2,length+1);
40         }
41
42 NAMES_ITEM::~NAMES_ITEM ()
43 {
44   if (std::strcmp (name, "one") != 0)
45     abort ();
46   
47   name=0;
48 }
49
50 bool NAMES_ITEM::operator==(const NAMES_ITEM& n) const
51 {
52   return (std::strcmp(name,n.name) == 0);
53 }
54
55 bool operator<(const NAMES_ITEM& n1, const NAMES_ITEM& n2)
56     {
57     return (std::strcmp(n1.name,n2.name) < 0);
58     }
59
60     typedef map<NAMES_ITEM,size_t,less<NAMES_ITEM> > lookup_t;
61
62     lookup_t lookup;
63
64         NAMES_ITEM item ("one");
65 main()
66   {
67         lookup.insert(pair<NAMES_ITEM,size_t>(item,0));
68   }
69