Topic: C++0x: Combining enum's


Author: Michiel Salters<Michiel.Salters@cmg.nl>
Date: Fri, 15 Jun 2001 16:31:17 GMT
Raw View
In article <MPG.15913726c7419cc4989684@news.t-online.de>, Michael Bruschkewitz
says...
>
>In article <oKPR6.760$v4.29236@www.newsranger.com>,
>Michiel.Salters@cmg.nl says...
>> In article <MPG.157f527824c5758d989681@news.t-online.de>, Michael Bruschkewitz
>> says...
>> >enum A { a1, a2 };
>> >enum B { b1, b2 };
>> >enum C : A, B { c1, c2 };
>> >Where C should be finally enum{ a1, a2, b1, b2, c1, c2 };
>>
>> This won't work, because (int) a1 = (int) b1.
>This was not my idea. My intention was (int)C::a1 == 0,
>(int)C::b1 == 2.
>The idea was to easily combine different interfaces into one.
>> "Single inheritance" could work, though. And if you accept
>> C equalling enum { a1, a2, b1=a1, b2=a2, c1, c2 } that too
>> is possible. I think this is one of those features which
>> might make it if somebody wrote a good proposal. You ?

>I would really _like_ to do this, but I have some doubts
>about my use of the english language. Where could I find an
>example for a proposal?
>
>Regards,
>Michael Bruschkewitz

If you are interested in contributing to the future of C++, great!
We can use people who are willing to write out their ideas. You
should contact DIN, I think (.de mail address) for the details of
contributing. That would give you access to the committee archives,
which contain many if not all of the formal proposals for new
language features.

BTW, proposals won't be rejected for imprecise use of the english
language, one of the common activities before & during the meetings is
wordsmithing. We only need to have to wording correct by 2005 or so,
enough time for that.

Regards,
Michiel Salters

--
Michiel Salters
Consultant Technical Software Engineering
CMG Trade, Transport & Industry
Michiel.Salters@cmg.nl

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: Michael Bruschkewitz <brusch2@gmx.net>
Date: Wed, 13 Jun 2001 16:22:46 GMT
Raw View
In article <oKPR6.760$v4.29236@www.newsranger.com>,
Michiel.Salters@cmg.nl says...
> In article <MPG.157f527824c5758d989681@news.t-online.de>, Michael Bruschkewitz
> says...
> >enum A { a1, a2 };
> >enum B { b1, b2 };
> >enum C : A, B { c1, c2 };
> >Where C should be finally enum{ a1, a2, b1, b2, c1, c2 };
>
> This won't work, because (int) a1 = (int) b1.
This was not my idea. My intention was (int)C::a1 == 0,
(int)C::b1 == 2.
The idea was to easily combine different interfaces into one.
> "Single inheritance" could work, though. And if you accept
> C equalling enum { a1, a2, b1=a1, b2=a2, c1, c2 } that too
> is possible. I think this is one of those features which
> might make it if somebody wrote a good proposal. You ?
I would really _like_ to do this, but I have some doubts
about my use of the english language. Where could I find an
example for a proposal?

Regards,
Michael Bruschkewitz

--
Given e-Mail address is a spam-trap. Use 1 for 2 to reach me fast.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: Michael Bruschkewitz <brusch2@gmx.net>
Date: Wed, 6 Jun 2001 16:18:56 GMT
Raw View
In article <9f7fvr$2n220$1@ID-49767.news.dfncis.de>,
anthwil@nortelnetworks.com says...
> Surely one word longer isn't going to kill you:
> class X { public: static int const x = 3; enum { e1 = x }; };
> is permitted by the current standard
Because it is so simple, I haven't cross-checked this with
another compiler (for example, gc++). I've trusted in MS here,
which was wrong.
Michael

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: Michael Bruschkewitz <brusch2@gmx.net>
Date: Thu, 31 May 2001 15:55:23 GMT
Raw View
Hello,
maybe this is a _really_ stupid idea, but I would like
something like this:

enum A { a1, a2 };
enum B { b1, b2 };
enum C : A, B { c1, c2 };

Where C should be finally enum{ a1, a2, b1, b2, c1, c2 };
To make this possible, it would be necessary to allow
this notation...
B b; b = B::b1;
... to avoid ambiguities.

Also, I would appreciate to define constants in the
class-declaration itself:
class X { public: int const x = 3; };

and similar:
class X { public: int const x = 3; enum { e1 = x }; };

I know there are already ways to do such things, but not
so compact.

Regards,
Michael Bruschkewitz

--
Given e-Mail address is a spam-trap. Use 1 for 2 to reach me fast.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "Anthony Williams" <anthwil@nortelnetworks.com>
Date: Fri, 1 Jun 2001 19:13:31 GMT
Raw View
"Michael Bruschkewitz" <brusch2@gmx.net> wrote in message
news:MPG.157f527824c5758d989681@news.t-online.de...
> Hello,
> maybe this is a _really_ stupid idea, but I would like
> something like this:
>
> enum A { a1, a2 };
> enum B { b1, b2 };
> enum C : A, B { c1, c2 };
>
> Where C should be finally enum{ a1, a2, b1, b2, c1, c2 };
> To make this possible, it would be necessary to allow
> this notation...
> B b; b = B::b1;
> ... to avoid ambiguities.
>
> Also, I would appreciate to define constants in the
> class-declaration itself:
> class X { public: int const x = 3; };
>
> and similar:
> class X { public: int const x = 3; enum { e1 = x }; };
>
> I know there are already ways to do such things, but not
> so compact.

Surely one word longer isn't going to kill you:

class X { public: static int const x = 3; enum { e1 = x }; };

is permitted by the current standard

Anthony
--
Anthony Williams
Software Engineer, Nortel Networks Optoelectronics
The opinions expressed in this message are not necessarily those of my
employer



---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: Michiel Salters<Michiel.Salters@cmg.nl>
Date: Sat, 2 Jun 2001 02:28:11 GMT
Raw View
In article <MPG.157f527824c5758d989681@news.t-online.de>, Michael Bruschkewitz
says...
>
>Hello,
>maybe this is a _really_ stupid idea, but I would like
>something like this:
>
>enum A { a1, a2 };
>enum B { b1, b2 };
>enum C : A, B { c1, c2 };
>
>Where C should be finally enum{ a1, a2, b1, b2, c1, c2 };

This won't work, because (int) a1 = (int) b1.
"Single inheritance" could work, though. And if you accept
C equalling enum { a1, a2, b1=a1, b2=a2, c1, c2 } that too
is possible. I think this is one of those features which
might make it if somebody wrote a good proposal. You ?

>To make this possible, it would be necessary to allow
>this notation...
>B b; b = B::b1;
>... to avoid ambiguities.

No, since b1 would mean the same everywhere. You'd basically
have a B::operator C, which can convert b1 to a C object.

>Also, I would appreciate to define constants in the
>class-declaration itself:
>class X { public: int const x = 3; };
>
>and similar:
>class X { public: int const x = 3; enum { e1 = x }; };
>
>I know there are already ways to do such things, but not
>so compact.

?
What you propse is the current way to do these things. No all
compilers do support this yet, but we all know there are
obsolete compilers which refuse to die. But I agree this is a
good thing to keep for the next standard :)

HTH,
Michiel Salters

--
Michiel Salters
Consultant Technical Software Engineering
CMG Trade, Transport & Industry
Michiel.Salters@cmg.nl

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]