Re: How to define operator =?UTF-8?B?ImNvbnN0?= char
=?UTF-8?B?KiI=?= of enumerated type defined inside a class
This is a MIME GnuPG-signed message. If you see this text, it means that
your E-mail or Usenet software does not support MIME signed messages.
The Internet standard for MIME PGP messages, RFC 2015, was published in 1996.
To open this message correctly you will need to install E-mail or Usenet
software that supports modern Internet standards.
--=_mimegpg-commodore.email-scan.com-7466-1222254608-0001
Content-Type: text/plain; format=flowed; charset="US-ASCII"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
Bill Davy writes:
I want to be able to write (const char*)v where v is an item of type
Class::ToolTypeT where ToolTypeT is an enumeration and I've tried
everything that looks sensible. There's an ugly solution, but surely this is
possible?
You can't really do this with merely an enum. You can, however, define a
class that, essentially, acts like an enum.
class Class {
public:
static const int a=0;
static const int b=1;
static const int c=2;
class ToolTypeT {
int v;
public:
ToolTypeT(int i): v(i) {}
ToolType &operator=(int i) { v=i; return *this; }
operator int() const { return v; }
operator const char *();
};
};
You can use this Class::ToolTypeT pretty much like an enumeration. Class::a,
Class::b, Class::c, etc. are your enumerator values. And, you can supply a
meaningful operator const char *().
And, with a few more tweaks, you can add additional type-safety to the whole
schema.
--=_mimegpg-commodore.email-scan.com-7466-1222254608-0001
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEABECAAYFAkjaIBAACgkQx9p3GYHlUOLREwCfX8LZDy9kK8bIs12xIIWX3545
VLUAn0D0x/KLAbnmDYFCcDYC/KCsfQvY
=5Qvo
-----END PGP SIGNATURE-----
--=_mimegpg-commodore.email-scan.com-7466-1222254608-0001--