Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C

raw
1 // { dg-do assemble }
2 // { dg-skip-if "requires hosted libstdc++ for iostream" { ! hostedlib } }
3 // GROUPS passed conversions
4 #include <iostream>
5
6 class Thing
7 {
8 public:
9 typedef enum { GOOD_THING, BAD_THING, } ThingType ; // { dg-error "" "comma" { target { ! c++11 } } }
10 Thing (ThingType type) : thingType (type) { }
11 ~Thing () { }
12 private:
13 ThingType thingType ;
14 } ;
15
16 class Group
17 {
18 public:
19 typedef enum { THIS_GROUP, THAT_GROUP, } GroupType ; // { dg-error "" "comma" { target { ! c++11 } } }
20 Group (GroupType type) : groupType (type), groupCount (0) { }
21 ~Group () { }
22 void append (Thing* const &entry) { groupCount ++ ; }
23 operator GroupType () const { return groupType ; }
24 operator int () const { return groupCount ; } // remove this and problem gone
25
26 private:
27 int groupCount ;
28 GroupType groupType ;
29 } ;
30
31 inline Group& operator += (Group& g, Thing* const t)
32 {
33 g.append (t) ;
34 return g ; // complaint is here
35 }
36
37 int
38 main (int argc, char** argv)
39 {
40 Group g (Group::THIS_GROUP) ;
41
42 g += new Thing (Thing::GOOD_THING) ;
43 std::cout << "Group type is " << (Group::GroupType) g << std::endl ;
44 return 0 ;
45 }