Topic: Type lists
Author: morwenn29@gmail.com
Date: Wed, 3 Jul 2013 02:10:30 -0700 (PDT)
Raw View
------=_Part_21_10835906.1372842630990
Content-Type: text/plain; charset=ISO-8859-1
Just another thought: now that we have some pretty amazing variadic
templates and alias templates, we could
have some nice type lists in the standard. They could be modeled on
Boost.MPL containers, but at little less boilerplates.
Consider the following usage example:
using types = std::type_list<int, float, std::vector<double>, char*>;
using first = types::first; // int
using second = types::at<1>; // float
using rest = types::pop_front; // std::type_list<float,
std::vector<double>, char*>
using types2 = std::type_list<bool, int*>;
using all_types = types::cat<types2>; // std::type_list<int, float,
std::vector<double>, char*, bool, int*>
constexpr size_t s = all_types::size; // 6
I find it pretty straightforward to use and it's not hard to implement.
This example does not cover the case of an empty type list, but the problem
should be easy to fix.
--
---
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 http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_21_10835906.1372842630990
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Just another thought: now that we have some pretty amazing variadic templat=
es and alias templates, we could<br>have some nice type lists in the standa=
rd. They could be modeled on Boost.MPL containers, but at little less boile=
rplates.<br><br>Consider the following usage example:<br><br><br>using type=
s =3D std::type_list<int, float, std::vector<double>, char*>;<b=
r><br>using first =3D types::first; &nbs=
p; // int<br>using second =3D types::at<1>;&n=
bsp; // float<br>using rest =3D types::pop_front; // std:=
:type_list<float, std::vector<double>, char*><br><br>using type=
s2 =3D std::type_list<bool, int*>;<br>using all_types =3D types::cat&=
lt;types2>; // std::type_list<int, float, std::vect=
or<double>, char*, bool, int*><br><br>constexpr size_t s =3D all_t=
ypes::size; // 6<br><br><br>I find it pretty straightforward to use and it'=
s not hard to implement.<br>This example does not cover the case of an empt=
y type list, but the problem should be easy to fix.<br>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
<br />
<br />
------=_Part_21_10835906.1372842630990--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 3 Jul 2013 13:51:18 +0300
Raw View
--001a11c2c0eccd520504e0993d87
Content-Type: text/plain; charset=ISO-8859-1
On 3 July 2013 12:10, <morwenn29@gmail.com> wrote:
> Just another thought: now that we have some pretty amazing variadic
> templates and alias templates, we could
> have some nice type lists in the standard. They could be modeled on
> Boost.MPL containers, but at little less boilerplates.
>
> Consider the following usage example:
>
>
> using types = std::type_list<int, float, std::vector<double>, char*>;
>
> using first = types::first; // int
> using second = types::at<1>; // float
> using rest = types::pop_front; // std::type_list<float,
> std::vector<double>, char*>
>
> using types2 = std::type_list<bool, int*>;
> using all_types = types::cat<types2>; // std::type_list<int, float,
> std::vector<double>, char*, bool, int*>
>
> constexpr size_t s = all_types::size; // 6
>
>
> I find it pretty straightforward to use and it's not hard to implement.
> This example does not cover the case of an empty type list, but the
> problem should be easy to fix.
>
>
>
Seems like we could almost already do that..
using types = tuple<int, float, std::vector<double>, char*>;
using first = decltype(get<0>(types()));
and so forth.
--
---
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 http://groups.google.com/a/isocpp.org/group/std-proposals/.
--001a11c2c0eccd520504e0993d87
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 3 July 2013 12:10, <span dir=3D"ltr"><<a href=3D"mailto:morw=
enn29@gmail.com" target=3D"_blank">morwenn29@gmail.com</a>></span> wrote=
:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bo=
rder-left:1px solid rgb(204,204,204);padding-left:1ex">
Just another thought: now that we have some pretty amazing variadic templat=
es and alias templates, we could<br>have some nice type lists in the standa=
rd. They could be modeled on Boost.MPL containers, but at little less boile=
rplates.<br>
<br>Consider the following usage example:<br><br><br>using types =3D std::t=
ype_list<int, float, std::vector<double>, char*>;<br><br>using =
first =3D types::first;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 // int<br>using se=
cond =3D types::at<1>;=A0=A0 // float<br>
using rest =3D types::pop_front;=A0=A0 // std::type_list<float, std::vec=
tor<double>, char*><br><br>using types2 =3D std::type_list<bool=
, int*>;<br>using all_types =3D types::cat<types2>;=A0=A0=A0 // st=
d::type_list<int, float, std::vector<double>, char*, bool, int*>=
;<br>
<br>constexpr size_t s =3D all_types::size; // 6<br><br><br>I find it prett=
y straightforward to use and it's not hard to implement.<br>This exampl=
e does not cover the case of an empty type list, but the problem should be =
easy to fix.<span class=3D""><font color=3D"#888888"><br>
<p></p>
<br></font></span></blockquote><div><br></div><div>Seems like we could almo=
st already do that..<br><br>using types =3D tuple<int, float, std::vecto=
r<double>, char*>; <br>using first =3D decltype(get<0>(types=
())); <br>
<br></div><div>and so forth. <br></div></div><br></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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
<br />
<br />
--001a11c2c0eccd520504e0993d87--
.
Author: Felipe Magno de Almeida <felipe.m.almeida@gmail.com>
Date: Wed, 3 Jul 2013 16:39:21 -0300
Raw View
--089e01183d1610ed2e04e0a0a0a6
Content-Type: text/plain; charset=ISO-8859-1
On Wed, Jul 3, 2013 at 6:10 AM, <morwenn29@gmail.com> wrote:
> Just another thought: now that we have some pretty amazing variadic
> templates and alias templates, we could
> have some nice type lists in the standard. They could be modeled on
> Boost.MPL containers, but at little less boilerplates.
>
> Consider the following usage example:
>
>
> using types = std::type_list<int, float, std::vector<double>, char*>;
>
> using first = types::first; // int
> using second = types::at<1>; // float
> using rest = types::pop_front; // std::type_list<float,
> std::vector<double>, char*>
>
> using types2 = std::type_list<bool, int*>;
> using all_types = types::cat<types2>; // std::type_list<int, float,
> std::vector<double>, char*, bool, int*>
>
> constexpr size_t s = all_types::size; // 6
>
>
> I find it pretty straightforward to use and it's not hard to implement.
> This example does not cover the case of an empty type list, but the
> problem should be easy to fix.
>
Being a heavy user of boost.mpl, I would find it very good for this to be
in the standard. Probably some algorithms as well.
> ---
--
Felipe Magno de Almeida
--
---
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 http://groups.google.com/a/isocpp.org/group/std-proposals/.
--089e01183d1610ed2e04e0a0a0a6
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On W=
ed, Jul 3, 2013 at 6:10 AM, <span dir=3D"ltr"><<a href=3D"mailto:morwen=
n29@gmail.com" target=3D"_blank">morwenn29@gmail.com</a>></span> wrote:<=
br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex">
Just another thought: now that we have some pretty amazing variadic templat=
es and alias templates, we could<br>have some nice type lists in the standa=
rd. They could be modeled on Boost.MPL containers, but at little less boile=
rplates.<br>
<br>Consider the following usage example:<br><br><br>using types =3D std::t=
ype_list<int, float, std::vector<double>, char*>;<br><br>using =
first =3D types::first;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 // int<br>using se=
cond =3D types::at<1>;=A0=A0 // float<br>
using rest =3D types::pop_front;=A0=A0 // std::type_list<float, std::vec=
tor<double>, char*><br><br>using types2 =3D std::type_list<bool=
, int*>;<br>using all_types =3D types::cat<types2>;=A0=A0=A0 // st=
d::type_list<int, float, std::vector<double>, char*, bool, int*>=
;<br>
<br>constexpr size_t s =3D all_types::size; // 6<br><br><br>I find it prett=
y straightforward to use and it's not hard to implement.<br>This exampl=
e does not cover the case of an empty type list, but the problem should be =
easy to fix.<span class=3D"HOEnZb"><font color=3D"#888888"><br>
</font></span></blockquote><div><br></div><div>Being a heavy user of boost.=
mpl, I would find it very good for this to be in the standard. Probably som=
e algorithms as well.<br></div><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=3D"HOEnZb"><font color=3D"#888888">
<p></p>
--- </font></span></blockquote><div>=A0</div></div>-- <br>Felipe Magno de A=
lmeida
</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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
<br />
<br />
--089e01183d1610ed2e04e0a0a0a6--
.
Author: morwenn29@gmail.com
Date: Sat, 5 Oct 2013 14:39:07 -0700 (PDT)
Raw View
------=_Part_1447_25474838.1381009148029
Content-Type: text/plain; charset=ISO-8859-1
It has been a while, and I have seen several people saying they needed type
lists during the last months (std::tuple is often used as a type list but
it feels kind of hackish and having proper type lists would be better). So,
it would probably be a good idea to discuss this problem again.
I like the Boost.MPL approach to solve this problem, but I find it somehow
too verbose. So, instead of foo::<type_list<...>>::type, I think that using
alias templates such as type_list<...>::foo would be less verbose and
somehow easier to read (it gives an "method" feeling instead of a "free
function" feeling.
Also, Boost.MPL provides many classes but the most common request is for a
simple type list, not a full API containing compile-time
list/vector/deque/map/etc... I tried to implement a brief type list and to
provide some examples of how it works, you can find them online here:
http://coliru.stacked-crooked.com/a/0bcc23952bbc221b
For now type_list only contains the following "methods" as proof of concept:
* size
* empty
* front
* back
* push_front
* push_back
* pop_front
* pop_back
* cat
My question would be: would you use such a type list or does it have some
defaults that would prevent you from using it?
If the design is ok, we could go ahead and have a proper proposal which
would add several other "functions", mainly taken from the type list
classes in Boost.MPL.
--
---
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 http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_1447_25474838.1381009148029
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">It has been a while, and I have seen several people saying=
they needed type lists during the last months (std::tuple is often used as=
a type list but it feels kind of hackish and having proper type lists woul=
d be better). So, it would probably be a good idea to discuss this problem =
again.<br><br>I like the Boost.MPL approach to solve this problem, but I fi=
nd it somehow too verbose. So, instead of foo::<type_list<...>>=
::type, I think that using alias templates such as type_list<...>::fo=
o would be less verbose and somehow easier to read (it gives an "method" fe=
eling instead of a "free function" feeling.<br><br>Also, Boost.MPL provides=
many classes but the most common request is for a simple type list, not a =
full API containing compile-time list/vector/deque/map/etc... I tried to im=
plement a brief type list and to provide some examples of how it works, you=
can find them online here:<br><br>http://coliru.stacked-crooked.com/a/0bcc=
23952bbc221b<br><br>For now type_list only contains the following "methods"=
as proof of concept:<br>* size<br>* empty<br>* front<br>* back<br>* push_f=
ront<br>* push_back<br>* pop_front<br>* pop_back<br>* cat<br><br>My questio=
n would be: would you use such a type list or does it have some defaults th=
at would prevent you from using it?<br>If the design is ok, we could go ahe=
ad and have a proper proposal which would add several other "functions", ma=
inly taken from the type list classes in Boost.MPL.<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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1447_25474838.1381009148029--
.
Author: Jeffrey Yasskin <jyasskin@google.com>
Date: Sat, 5 Oct 2013 14:56:34 -0700
Raw View
Have you seen http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3728.html?
On Sat, Oct 5, 2013 at 2:39 PM, <morwenn29@gmail.com> wrote:
> It has been a while, and I have seen several people saying they needed type
> lists during the last months (std::tuple is often used as a type list but it
> feels kind of hackish and having proper type lists would be better). So, it
> would probably be a good idea to discuss this problem again.
>
> I like the Boost.MPL approach to solve this problem, but I find it somehow
> too verbose. So, instead of foo::<type_list<...>>::type, I think that using
> alias templates such as type_list<...>::foo would be less verbose and
> somehow easier to read (it gives an "method" feeling instead of a "free
> function" feeling.
>
> Also, Boost.MPL provides many classes but the most common request is for a
> simple type list, not a full API containing compile-time
> list/vector/deque/map/etc... I tried to implement a brief type list and to
> provide some examples of how it works, you can find them online here:
>
> http://coliru.stacked-crooked.com/a/0bcc23952bbc221b
>
> For now type_list only contains the following "methods" as proof of concept:
> * size
> * empty
> * front
> * back
> * push_front
> * push_back
> * pop_front
> * pop_back
> * cat
>
> My question would be: would you use such a type list or does it have some
> defaults that would prevent you from using it?
> If the design is ok, we could go ahead and have a proper proposal which
> would add several other "functions", mainly taken from the type list classes
> in Boost.MPL.
>
> --
>
> ---
> 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
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
--
---
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 http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: morwenn29@gmail.com
Date: Sat, 5 Oct 2013 15:15:24 -0700 (PDT)
Raw View
------=_Part_1818_19217481.1381011324773
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Le samedi 5 octobre 2013 23:56:34 UTC+2, Jeffrey Yasskin a =E9crit :
>
> Have you seen=20
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3728.html?
>
To tell the truth, no. I searched corresponding library papers. I didn't=20
think this would be in reflection papers.
Well, the paper is interesting is many ways but requires some/many=20
modifications to the language, while what I propose would only be a library=
=20
addition. Ok, the said proposal is much more poweful than my proposal and=
=20
also solves more problems.
However, it does not solve the problems that my proposal is trying to=20
address (manipulating type lists like "regular" lists). It would be=20
possible with the aforementioned parameter packs proposal, but, unless=20
adding built-in at/size/pop_back etc... to the core language (with would=20
probably be poor design), the parameter packs would still need a library=20
solution to provide such features, and it would probably no less verbose=20
the than Boost.MPL vectors/lists.
// Parameter packs proposal
using types =3D <int, float, char>;
auto sz =3D size<types>::value;
using bck =3D typename back<size>::type;
// type_list proposal
using types =3D type_list<int, float, char>;
auto sz =3D types::size;
using bck =3D types::back;
I do not think these proposals overlap. They are here to address different=
=20
problems actually. Well, I also like the parameter packs one anyway :)
--=20
---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_1818_19217481.1381011324773
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Le samedi 5 octobre 2013 23:56:34 UTC+2, Jeffrey Yasskin a=
=E9crit :<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Have you seen <=
a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3728.htm=
l" target=3D"_blank">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/paper=
s/2013/<wbr>n3728.html</a>?<br></blockquote><div><br>To tell the truth, no.=
I searched corresponding library papers. I didn't think this would be in r=
eflection papers.<br>Well, the paper is interesting is many ways but requir=
es some/many modifications to the language, while what I propose would only=
be a library addition. Ok, the said proposal is much more poweful than my =
proposal and also solves more problems.<br><br>However, it does not solve t=
he problems that my proposal is trying to address (manipulating type lists =
like "regular" lists). It would be possible with the aforementioned paramet=
er packs proposal, but, unless adding built-in at/size/pop_back etc... to t=
he core language (with would probably be poor design), the parameter packs =
would still need a library solution to provide such features, and it would =
probably no less verbose the than Boost.MPL vectors/lists.<br><br>// Parame=
ter packs proposal<br>using types =3D <int, float, char>;<br>auto sz =
=3D size<types>::value;<br>using bck =3D typename back<size>::t=
ype;<br><br>// type_list proposal<br>using types =3D type_list<int, floa=
t, char>;<br>auto sz =3D types::size;<br>using bck =3D types::back;<br><=
br>I do not think these proposals overlap. They are here to address differe=
nt problems actually. Well, I also like the parameter packs one anyway :)<b=
r></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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1818_19217481.1381011324773--
.