Topic: Is there any proposals on providing tuple-like access


Author: Sam Kellett <samkellett@gmail.com>
Date: Fri, 29 Jul 2016 09:47:43 +0100
Raw View
--001a1142b692cc496f0538c24d31
Content-Type: text/plain; charset=UTF-8

I had an idea that is akin to std::tuple_element and std::tuple_size
although it would obviously require compiler magic rather than a library
implementation.

An example:

enum class foo {
  bar, baz, quux
};

static_assert(std::enum_size<foo>::value == 3);
static_assert(std::enum_element<0, foo>::value == foo::bar);
static_assert(std::enum_element<1, foo>::value == foo::baz);
static_assert(std::enum_element<2, foo>::value == foo::quux);

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHK%2B-Fu051CUsD-u%3D%3DXYA5VmEx9ubJTtVQvnNkJ9_XjVTj7qmQ%40mail.gmail.com.

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

<div dir=3D"ltr"><div><div><div>I had an idea that is akin to std::tuple_el=
ement and std::tuple_size although it would obviously require compiler magi=
c rather than a library implementation.<br><br></div>An example:<br><br></d=
iv>enum class foo {<br></div>=C2=A0 bar, baz, quux<br><div>};<br><br></div>=
<div>static_assert(std::enum_size&lt;foo&gt;::value =3D=3D 3);<br>static_as=
sert(std::enum_element&lt;0, foo&gt;::value =3D=3D foo::bar);<br>static_ass=
ert(std::enum_element&lt;1, foo&gt;::value =3D=3D foo::baz);<br>static_asse=
rt(std::enum_element&lt;2, foo&gt;::value =3D=3D foo::quux);<br><br></div><=
/div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAHK%2B-Fu051CUsD-u%3D%3DXYA5VmEx9ubJ=
TtVQvnNkJ9_XjVTj7qmQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHK%2B-Fu0=
51CUsD-u%3D%3DXYA5VmEx9ubJTtVQvnNkJ9_XjVTj7qmQ%40mail.gmail.com</a>.<br />

--001a1142b692cc496f0538c24d31--

.