Topic: strongly typed enums - can you overload on them
Author: undertoad@btinternet.com ("Joe Borkoles")
Date: Mon, 15 Mar 2004 19:12:46 +0000 (UTC) Raw View
I know this is probably implied by the document SC22/WG21/N1579 (I hope this
is the latest one!) but could you overload based on this new strongly typed
enum type? You can't with the current enum, of course.
example:
enum class Foo { red, green, blue };
enum class Bar { chicken, egg };
class MyClass
{
public:
void afunc( Foo );
void afunc( Bar );
};
It might be nice to work this in as an explicit example to the proposal as
it is such an important consideration!
----------------------------------------------------------------------------
------------------
Just how do you expect the US to test its new weapons anyway?
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: jdennett@acm.org (James Dennett)
Date: Tue, 16 Mar 2004 16:43:58 +0000 (UTC) Raw View
Joe Borkoles wrote:
> I know this is probably implied by the document SC22/WG21/N1579 (I hope this
> is the latest one!) but could you overload based on this new strongly typed
> enum type? You can't with the current enum, of course.
You can with the current one, and I would assume with the
new one too. It's common to do so, for example, to allow
bitwise operators on enums, or to allow stream I/O for
them.
-- James
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: do-not-spam-benh@bwsint.com (Ben Hutchings)
Date: Wed, 17 Mar 2004 00:50:33 +0000 (UTC) Raw View
"Joe Borkoles" wrote:
> I know this is probably implied by the document SC22/WG21/N1579 (I hope this
> is the latest one!) but could you overload based on this new strongly typed
> enum type? You can't with the current enum, of course.
<snip>
Yes you can.
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]