Topic: Are there any existing enum.method() extension


Author: Nick Pelling <nickpelling@nickpelling.com>
Date: Sat, 26 Dec 2015 07:30:48 -0800 (PST)
Raw View
------=_Part_2875_1288480405.1451143848396
Content-Type: multipart/alternative;
 boundary="----=_Part_2876_1082200857.1451143848396"

------=_Part_2876_1082200857.1451143848396
Content-Type: text/plain; charset=UTF-8

Hi everyone,

I'm thinking of putting together a proposal to give enums (a feature that
C++ inherited from C, but hasn't really developed) the ability to have
their own static methods and static data, but would prefer to build on or
develop previous proposals rather than merely recapitulate them.

This won't be a proposal about reflection or type-safety, but rather about
giving C++ a way to give enums directly mapped properties, i.e.

enum Jeans
{
    Classic,
    Skinny,
    BootCut

private:
    static const char * name_array[];

public:
    inline static const char * Name()
    {
        return name_array[this];   // I'm guessing 'this' would be: enum
Jeans this
    }
};

const char * Jeans::name_array[] =
{
     "Classic",
     "Skinny"
     "Boot Cut"
};

At which point, a routine with an enum Jeans variable called j can start
using j.Name() etc.

I know that you can achieve the same kind of effect (sort of) by wrapping
an enum in a class, but - as an embedded engineer - the absence of enum
methods is a hole in the language spec I often find myself having to work
around in a number of different ugly ways.

Would this kind of thing be overlapping with existing proposals?

Cheers, Nick

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_2876_1082200857.1451143848396
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi everyone,<br><br>I&#39;m thinking of putting together a=
 proposal to give enums (a feature that C++ inherited from C, but hasn&#39;=
t really developed) the ability to have their own static methods and static=
 data, but would prefer to build on or develop previous proposals rather th=
an merely recapitulate them.<br><br>This won&#39;t be a proposal about refl=
ection or type-safety, but rather about giving C++ a way to give enums dire=
ctly mapped properties, i.e. <br><br>enum Jeans<br>{<br>=C2=A0=C2=A0=C2=A0 =
Classic,<br>=C2=A0=C2=A0=C2=A0 Skinny,<br>=C2=A0=C2=A0=C2=A0 BootCut<br><br=
>private:<br>=C2=A0=C2=A0=C2=A0 static const char * name_array[];<br><br>pu=
blic:<br>=C2=A0=C2=A0=C2=A0 inline static const char * Name()<br>=C2=A0=C2=
=A0=C2=A0 {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return name_array=
[this];=C2=A0=C2=A0 // I&#39;m guessing &#39;this&#39; would be: enum Jeans=
 this <br>=C2=A0=C2=A0=C2=A0 }<br>};<br><br>const char * Jeans::name_array[=
] =3D<br>{<br>=C2=A0=C2=A0=C2=A0=C2=A0 &quot;Classic&quot;,<br>=C2=A0=C2=A0=
=C2=A0=C2=A0 &quot;Skinny&quot;<br>=C2=A0=C2=A0 =C2=A0 &quot;Boot Cut&quot;=
<br>};<br><br>At which point, a routine with an enum Jeans variable called =
j can start using j.Name() etc.<br><br>I know that you can achieve the same=
 kind of effect (sort of) by wrapping an enum in a class, but - as an embed=
ded engineer - the absence of enum methods is a hole in the language spec I=
 often find myself having to work around in a number of different ugly ways=
..<br><br>Would this kind of thing be overlapping with existing proposals?<b=
r><br>Cheers, Nick<br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

------=_Part_2876_1082200857.1451143848396--
------=_Part_2875_1288480405.1451143848396--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sat, 26 Dec 2015 08:32:30 -0800 (PST)
Raw View
------=_Part_3597_1139432265.1451147550951
Content-Type: multipart/alternative;
 boundary="----=_Part_3598_2117574468.1451147550952"

------=_Part_3598_2117574468.1451147550952
Content-Type: text/plain; charset=UTF-8

On Saturday, December 26, 2015 at 10:30:48 AM UTC-5, Nick Pelling wrote:
>
> Hi everyone,
>
> I'm thinking of putting together a proposal to give enums (a feature that
> C++ inherited from C, but hasn't really developed) the ability to have
> their own static methods and static data, but would prefer to build on or
> develop previous proposals rather than merely recapitulate them.
>
> This won't be a proposal about reflection or type-safety, but rather about
> giving C++ a way to give enums directly mapped properties, i.e.
>
> enum Jeans
> {
>     Classic,
>     Skinny,
>     BootCut
>
> private:
>     static const char * name_array[];
>
> public:
>     inline static const char * Name()
>     {
>         return name_array[this];   // I'm guessing 'this' would be: enum
> Jeans this
>     }
> };
>

`Name` is static; it doesn't get a `this` pointer.

I know that you can achieve the same kind of effect (sort of) by wrapping
> an enum in a class, but - as an embedded engineer - the absence of enum
> methods is a hole in the language spec I often find myself having to work
> around in a number of different ugly ways.
>

Is there some reason why such a method specifically *needs* to be a member
function? Given unified function call syntax, you're going to be seeing a
lot more `f(x)` than `x.f()` in the future.

Would this kind of thing be overlapping with existing proposals?
>

Not that I'm aware of. You can push for it if you like, but I wouldn't
expect the committee to look too favorably on it. Not unless you can come
up with a clear motivating example, something you can't reasonably do some
other way.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_3598_2117574468.1451147550952
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Saturday, December 26, 2015 at 10:30:48 AM UTC-5, Nick Pelling wrote:<bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border=
-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Hi everyone,<br>=
<br>I&#39;m thinking of putting together a proposal to give enums (a featur=
e that C++ inherited from C, but hasn&#39;t really developed) the ability t=
o have their own static methods and static data, but would prefer to build =
on or develop previous proposals rather than merely recapitulate them.<br><=
br>This won&#39;t be a proposal about reflection or type-safety, but rather=
 about giving C++ a way to give enums directly mapped properties, i.e. <br>=
<br>enum Jeans<br>{<br>=C2=A0=C2=A0=C2=A0 Classic,<br>=C2=A0=C2=A0=C2=A0 Sk=
inny,<br>=C2=A0=C2=A0=C2=A0 BootCut<br><br>private:<br>=C2=A0=C2=A0=C2=A0 s=
tatic const char * name_array[];<br><br>public:<br>=C2=A0=C2=A0=C2=A0 inlin=
e static const char * Name()<br>=C2=A0=C2=A0=C2=A0 {<br>=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 return name_array[this];=C2=A0=C2=A0 // I&#39;m gu=
essing &#39;this&#39; would be: enum Jeans this <br>=C2=A0=C2=A0=C2=A0 }<br=
>};<br></div></blockquote><div><br>`Name` is static; it doesn&#39;t get a `=
this` pointer.<br><br></div><blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><d=
iv dir=3D"ltr">I know that you can achieve the same kind of effect (sort of=
) by wrapping an enum in a class, but - as an embedded engineer - the absen=
ce of enum methods is a hole in the language spec I often find myself havin=
g to work around in a number of different ugly ways.<br></div></blockquote>=
<div><br>Is there some reason why such a method specifically <i>needs</i> t=
o be a member function? Given unified function call syntax, you&#39;re goin=
g to be seeing a lot more `f(x)` than `x.f()` in the future.<br><br></div><=
blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bord=
er-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Would this kin=
d of thing be overlapping with existing proposals?<br></div></blockquote><d=
iv><br>Not that I&#39;m aware of. You can push for it if you like, but I wo=
uldn&#39;t expect the committee to look too favorably on it. Not unless you=
 can come up with a clear motivating example, something you can&#39;t reaso=
nably do some other way.<br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

------=_Part_3598_2117574468.1451147550952--
------=_Part_3597_1139432265.1451147550951--

.


Author: Nevin Liber <nevin@cplusplusguy.com>
Date: Sat, 26 Dec 2015 11:58:16 -0600
Raw View
--001a11478ef654ff500527d0d381
Content-Type: text/plain; charset=UTF-8

On 26 December 2015 at 09:30, Nick Pelling <nickpelling@nickpelling.com>
wrote:

>
> enum Jeans
> {
>     Classic,
>     Skinny,
>     BootCut
>
> private:
>     static const char * name_array[];
>
> public:
>     inline static const char * Name()
>     {
>         return name_array[this];   // I'm guessing 'this' would be: enum
> Jeans this
>     }
> };
>
> const char * Jeans::name_array[] =
> {
>      "Classic",
>      "Skinny"
>      "Boot Cut"
> };
>
> At which point, a routine with an enum Jeans variable called j can start
> using j.Name() etc.
>

The usual questions every time this comes up:

   - What do you do when more than one enumerator has the same value?
   - What do you do for values that don't have a corresponding enumerator?
   - What is the encoding character set (for instance, UTF8)?


--
 Nevin ":-)" Liber  <mailto:nevin@c <nevin@eviloverlord.com>plusplusguy.com>
 +1-847-691-1404

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a11478ef654ff500527d0d381
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On 26 December 2015 at 09:30, Nick Pelling <span dir=3D"lt=
r">&lt;<a href=3D"mailto:nickpelling@nickpelling.com" target=3D"_blank">nic=
kpelling@nickpelling.com</a>&gt;</span> wrote:<br><div class=3D"gmail_extra=
"><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr=
"><br>enum Jeans<br>{<br>=C2=A0=C2=A0=C2=A0 Classic,<br>=C2=A0=C2=A0=C2=A0 =
Skinny,<br>=C2=A0=C2=A0=C2=A0 BootCut<br><br>private:<br>=C2=A0=C2=A0=C2=A0=
 static const char * name_array[];<br><br>public:<br>=C2=A0=C2=A0=C2=A0 inl=
ine static const char * Name()<br>=C2=A0=C2=A0=C2=A0 {<br>=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 return name_array[this];=C2=A0=C2=A0 // I&#39;m=
 guessing &#39;this&#39; would be: enum Jeans this <br>=C2=A0=C2=A0=C2=A0 }=
<br>};<br><br>const char * Jeans::name_array[] =3D<br>{<br>=C2=A0=C2=A0=C2=
=A0=C2=A0 &quot;Classic&quot;,<br>=C2=A0=C2=A0=C2=A0=C2=A0 &quot;Skinny&quo=
t;<br>=C2=A0=C2=A0 =C2=A0 &quot;Boot Cut&quot;<br>};<br><br>At which point,=
 a routine with an enum Jeans variable called j can start using j.Name() et=
c.<br></div></blockquote><div><br></div><div>The usual questions every time=
 this comes up:</div><div><ul><li>What do you do when more than one enumera=
tor has the same value?<br></li><li>What do you do for values that don&#39;=
t have a corresponding enumerator?</li><li>What is the encoding character s=
et (for instance, UTF8)?</li></ul></div></div><div class=3D"gmail_extra"><b=
r></div>-- <br><div class=3D"gmail_signature"><div dir=3D"ltr"><div><div di=
r=3D"ltr"><div>=C2=A0Nevin &quot;:-)&quot; Liber=C2=A0 &lt;mailto:<a href=
=3D"mailto:nevin@eviloverlord.com" target=3D"_blank">nevin@c</a><a href=3D"=
http://plusplusguy.com">plusplusguy.com</a>&gt; =C2=A0+1-847-691-1404</div>=
</div></div></div></div>
</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

--001a11478ef654ff500527d0d381--

.


Author: Nick Pelling <nickpelling@nickpelling.com>
Date: Sat, 26 Dec 2015 23:01:08 +0000
Raw View
--=====================_46469468==.ALT
Content-Type: text/plain; charset=UTF-8; format=flowed

Hi Nicol,

At 08:32 26/12/2015 -0800, Nicol Bolas wrote:
>`Name` is static; it doesn't get a `this` pointer.

Actually, it's neither static nor a normal 'this' pointer: but I
don't yet have a good way of describing it. This isn't yet a
proposal, I'm just trying to gauge where this kind of thing would sit
in the landscape of proposals. :-)

>Is there some reason why such a method specifically needs to be a
>member function? Given unified function call syntax, you're going to
>be seeing a lot more `f(x)` than `x.f()` in the future.

Yes, I'm aware of Uniform Function Call Syntax: here I'm aiming for a
more straightforward C++-like way of achieving the same level of code
encapsulation (I hate code sprawl) but for enums. The ability to give
enums a set of tied methods is something that I would use in almost
all of my programmes (I currently do this with C-style macros,
because I can't find a good way of achieving it with C++ enums or templates).

Thanks, Nick

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-proposals/.

--=====================_46469468==.ALT
Content-Type: text/html; charset=UTF-8

<html>
<body>
Hi Nicol,<br><br>
At 08:32 26/12/2015 -0800, Nicol Bolas wrote:<br>
<blockquote type=cite class=cite cite="">`Name` is static; it doesn't get
a `this` pointer.</blockquote><br>
Actually, it's neither static nor a normal 'this' pointer: but I don't
yet have a good way of describing it. This isn't yet a proposal, I'm just
trying to gauge where this kind of thing would sit in the landscape of
proposals. :-) <br><br>
<blockquote type=cite class=cite cite="">Is there some reason why such a
method specifically needs</i> to be a member function? Given unified
function call syntax, you're going to be seeing a lot more `f(x)` than
`x.f()` in the future.</blockquote><br>
Yes, I'm aware of Uniform Function Call Syntax: here I'm aiming for a
more straightforward C++-like way of achieving the same level of code
encapsulation (I hate code sprawl) but for enums. The ability to give
enums a set of tied methods is something that I would use in almost all
of my programmes (I currently do this with C-style macros, because I
can't find a good way of achieving it with C++ enums or
templates).<br><br>
Thanks, Nick
<br /><br />
<hr style='border:none; color:#909090; background-color:#B0B0B0; height: 1px; width: 99%;' />
<table style='border-collapse:collapse;border:none;'>
 <tr>
  <td style='border:none;padding:0px 15px 0px 8px'>
   <a href="https://www.avast.com/antivirus">
    <img border=0 src="http://static.avast.com/emails/avast-mail-stamp.png" alt="Avast logo" />
   </a>
  </td>
  <td>
   <p style='color:#3d4d5a; font-family:"Calibri","Verdana","Arial","Helvetica"; font-size:12pt;'>
    This email has been checked for viruses by Avast antivirus software.
    <br><a href="https://www.avast.com/antivirus">www.avast.com</a>
   </p>
  </td>
 </tr>
</table>
<br />
</body>
</html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="https://groups.google.com/a/isocpp.org/group/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

--=====================_46469468==.ALT--


.


Author: Nick Pelling <nickpelling@nickpelling.com>
Date: Sat, 26 Dec 2015 23:14:20 +0000
Raw View
--=====================_47258521==.ALT
Content-Type: text/plain; charset=UTF-8; format=flowed

Hi Nevin,

At 11:58 26/12/2015 -0600, Nevin Liber wrote:
>The usual questions every time this comes up:
>    * What do you do when more than one enumerator has the same value?
>    * What do you do for values that don't have a corresponding enumerator?
>    * What is the encoding character set (for instance, UTF8)?
I agree that all of these questions are germane to how people use
enums in their real-world C++ code: but none of them seems obviously
relevant to what I'm proposing here.

That is, I'm not thinking about proposing the "usual suspects" for
extending enums (i.e. enum inheritance, enum reflection, strongly
typed enums, etc), but rather about devising some general way of
allowing enums to have limited class-like data and methods so that
they can (typically) associate useful information with each
enumerated value, while also hiding the implementation details from the caller.

Has this kind of thing been proposed before, perhaps under the aegis
of a broader proposal?

Cheers, Nick

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-proposals/.

--=====================_47258521==.ALT
Content-Type: text/html; charset=UTF-8

<html>
<body>
Hi Nevin,<br><br>
At 11:58 26/12/2015 -0600, Nevin Liber wrote:<br>
<blockquote type=cite class=cite cite="">The usual questions every time
this comes up:
<ul>
<li>What do you do when more than one enumerator has the same value?
<li>What do you do for values that don't have a corresponding
enumerator?
<li>What is the encoding character set (for instance,
UTF8)?</blockquote>
</ul>I agree that all of these questions are germane to how people use
enums in their real-world C++ code: but none of them seems obviously
relevant to what I'm proposing here.<br><br>
That is, I'm not thinking about proposing the &quot;usual suspects&quot;
for extending enums (i.e. enum inheritance, enum reflection, strongly
typed enums, etc), but rather about devising some general way of allowing
enums to have limited class-like data and methods so that they can
(typically) associate useful information with each enumerated value,
while also hiding the implementation details from the caller.<br><br>
Has this kind of thing been proposed before, perhaps under the aegis of a
broader proposal?<br><br>
Cheers, Nick
<br /><br />
<hr style='border:none; color:#909090; background-color:#B0B0B0; height: 1px; width: 99%;' />
<table style='border-collapse:collapse;border:none;'>
 <tr>
  <td style='border:none;padding:0px 15px 0px 8px'>
   <a href="https://www.avast.com/antivirus">
    <img border=0 src="http://static.avast.com/emails/avast-mail-stamp.png" alt="Avast logo" />
   </a>
  </td>
  <td>
   <p style='color:#3d4d5a; font-family:"Calibri","Verdana","Arial","Helvetica"; font-size:12pt;'>
    This email has been checked for viruses by Avast antivirus software.
    <br><a href="https://www.avast.com/antivirus">www.avast.com</a>
   </p>
  </td>
 </tr>
</table>
<br />
</body>
</html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="https://groups.google.com/a/isocpp.org/group/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

--=====================_47258521==.ALT--


.


Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Tue, 29 Dec 2015 12:24:38 -0500
Raw View
On 2015-12-26 10:30, Nick Pelling wrote:
> I'm thinking of putting together a proposal to give enums (a feature that
> C++ inherited from C, but hasn't really developed) the ability to have
> their own static methods and static data, but would prefer to build on or
> develop previous proposals rather than merely recapitulate them.

Yes, please! I've wanted that for some time but never got around to
putting together a proposal.

Why just static methods, though? (Um... well, see following comments.)

> This won't be a proposal about reflection or type-safety, but rather about
> giving C++ a way to give enums directly mapped properties, i.e.
>
> enum Jeans
> {
>     Classic,
>     Skinny,
>     BootCut
>
> private:
>     static const char * name_array[];
>
> public:
>     inline static const char * Name()
>     {
>         return name_array[this];   // I'm guessing 'this' would be: enum
> Jeans this
>     }

....but this *isn't* a static method! A static method has no 'this'.

> };

You obviously want methods that have access to an "owning" instance of
the enum. (So do I.) Thing is... those are non-static methods.

However, I don't see why there needs to be any difficulty here. Just
have non-static methods with 'this' a pointer to the "owning" instance,
same as for a class. Yes, you have to write "*this" to get the value...
big deal. It's consistent, and ensures that you can *modify* the
instance in non-const methods. (Which requires a pointer, keeping in
mind that a reference is just syntax sugar for a pointer.)

Don't overcomplicate it by trying to introduce unusual and inconsistent
rules :-).

--
Matthew

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-proposals/.

.