Topic: Comments on N3584 Wording for Addressing Tuples by Type
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Wed, 15 May 2013 07:40:51 +0200
Raw View
This is a multi-part message in MIME format.
--------------090903020207030408080404
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hi,
I was wondering if instead of using the get<type>(tpl) form
|tuple<string, string, int> t("foo", "bar", 7);
int i = get<int>(t);// i == 7
int j = get<2>(t); // Equivalent to the above: j == 7
string s = get<string>(t);
we can not use the conversion operator type(tpl)
| |tuple<string, string, int> t("foo", "bar", 7);
|||int i = int(t);// i == 7
|||||int i(t);// i == 7
||int j = get<2>(t); // Equivalent to the above: j == 7
||string s = string(t);|
|string s(t);|
I'm using this kind of conversion on a year_month_day tuple like class
to access the year, month and day members, and I find it much more
intuitive than the get<type>() syntax.
I would reserve the get<type>() syntax for named tuples
struct f1{};
struct f2{};
struct f3{};
|||tuple<tagged<string, f1>, tagged<string, f2>, tagged<int, f3>>
t("foo", "bar", 7); |
|int i = get<f2>(t);// i == 7
|
Best,
Vicente
--
---
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/?hl=en.
--------------090903020207030408080404
Content-Type: text/html; charset=ISO-8859-1
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi,<br>
<br>
I was wondering if instead of using the get<type>(tpl) form<br>
<br>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<code>tuple<string, string, int> t("foo", "bar", 7);
<br>
int i = get<int>(t);<span class="comment"> // i == 7</span>
<br>
int j = get<2>(t); <span class="comment"> // Equivalent to
the above: j == 7</span>
<br>
string s = get<string>(t);<span class="comment"> <br>
<br>
we can not use the conversion operator type(tpl)<br>
<br>
</span></code>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<code>tuple<string, string, int> t("foo", "bar", 7);
<br>
</code><code><code>int i = int(t);<span class="comment"> // i == 7</span>
<br>
</code></code><code><code><code>int i(t);<span class="comment"> //
i == 7</span> <br>
</code></code>int j = get<2>(t); <span class="comment">
// Equivalent to the above: j == 7</span>
<br>
</code><code>string s = string(t);<span class="comment"> </span></code><br>
<code>string s(t);<span class="comment"> </span></code><br>
<br>
I'm using this kind of conversion on a year_month_day tuple like
class to access the year, month and day members, and I find it much
more intuitive than the get<type>() syntax.<br>
<br>
I would reserve the get<type>() syntax for named tuples<br>
<br>
struct f1{};<br>
struct f2{};<br>
struct f3{};<br>
<code></code><code>tuple<tagged<string, f1>,
tagged<string, f2>, tagged<int, f3>> t("foo",
"bar", 7);
</code><br>
<code>int i = get<f2>(t);<span class="comment"> // i == 7</span>
<br>
</code><br>
Best,<br>
Vicente<br>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email 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="http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en">http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en</a>.<br />
<br />
<br />
--------------090903020207030408080404--
.