That would be great! that ides evaluates to:
--boilerplate;
On Thu, Oct 20, 2011 at 7:02 PM, Andrei Alexandrescu
seewebsiteforem...@erdani.org wrote:
On 10/20/11 6:53 AM, kenji hara wrote:
I think std.conv.to should provide the *safe natural conversion*.
Field-to-field conversion seems not
Robert Jacques wrote:
On Wed, 19 Oct 2011 14:16:31 -0400, Piotr Szturmaj
bncr...@jadamspam.pl wrote:
bearophile wrote:
Piotr Szturmaj:
I have written a simple conversion template for tuples, structs and
classes:
Do you have some use case to show me?
class C
{
int i;
string s;
}
struct S
bearophile wrote:
Piotr Szturmaj:
Do you have some use case to show me?
class C
{
int i;
string s;
}
struct S
{
string s;
float f;
}
auto c = to!C(S(5, 2.5f));
assert(c.i == 5 c.s == 2.5);
This is an usage example, it isn't an use case.
And it looks a bit messy.
Piotr Szturmaj:
-- for CSV:
alias Tuple!(int, string, int) IdNameAge;
foreach (csvLine; csvFile.byCSVLine)
{
auto line = to!IdNameAge(splitter(csvLine, ';'));
// line here is a tuple converted from runtime csv fields
}
See here the answer 23 by Andrei Alexandrescu to a
bearophile wrote:
Piotr Szturmaj:
-- for CSV:
alias Tuple!(int, string, int) IdNameAge;
foreach (csvLine; csvFile.byCSVLine)
{
auto line = to!IdNameAge(splitter(csvLine, ';'));
// line here is a tuple converted from runtime csv fields
}
See here the answer 23 by Andrei
2011/10/20 Piotr Szturmaj bncr...@jadamspam.pl:
Robert Jacques wrote:
On Wed, 19 Oct 2011 14:16:31 -0400, Piotr Szturmaj
bncr...@jadamspam.pl wrote:
bearophile wrote:
Piotr Szturmaj:
I have written a simple conversion template for tuples, structs and
classes:
Do you have some use case
On 10/20/11 6:53 AM, kenji hara wrote:
I think std.conv.to should provide the *safe natural conversion*.
Field-to-field conversion seems not natural, and it is called
'Structural conversion'.
I agree. We could, however, add std.conv.structuralCast.
Andrei
I have written a simple conversion template for tuples, structs and classes:
https://gist.github.com/1299046
The problem is that it may conflict with to!Class1(Class2) template.
This template does dynamic cast and throw exception when the target is
null and source is non null. Why implement
Piotr Szturmaj:
I have written a simple conversion template for tuples, structs and classes:
Do you have some use case to show me?
Bye,
bearophile
bearophile wrote:
Piotr Szturmaj:
I have written a simple conversion template for tuples, structs and classes:
Do you have some use case to show me?
class C
{
int i;
string s;
}
struct S
{
string s;
float f;
}
auto c = to!C(S(5, 2.5f));
assert(c.i == 5 c.s == 2.5);
Piotr Szturmaj:
I have written a simple conversion template for tuples, structs and classes:
This is only the part to complement universal range/array to
tuple/struct/class conversion. It may be useful in mapping runtime
fields like database rows or CSV lines onto objects. I think Phobos
On Wednesday, October 19, 2011 19:47:55 Piotr Szturmaj wrote:
I have written a simple conversion template for tuples, structs and classes:
https://gist.github.com/1299046
The problem is that it may conflict with to!Class1(Class2) template.
This template does dynamic cast and throw
On Wed, 19 Oct 2011 14:31:20 -0400, Piotr Szturmaj bncr...@jadamspam.pl wrote:
Piotr Szturmaj:
I have written a simple conversion template for tuples, structs and classes:
This is only the part to complement universal range/array to
tuple/struct/class conversion. It may be useful in mapping
On Wed, 19 Oct 2011 14:16:31 -0400, Piotr Szturmaj bncr...@jadamspam.pl wrote:
bearophile wrote:
Piotr Szturmaj:
I have written a simple conversion template for tuples, structs and classes:
Do you have some use case to show me?
class C
{
int i;
string s;
}
struct S
{
Piotr Szturmaj:
Do you have some use case to show me?
class C
{
int i;
string s;
}
struct S
{
string s;
float f;
}
auto c = to!C(S(5, 2.5f));
assert(c.i == 5 c.s == 2.5);
This is an usage example, it isn't an use case.
And it looks a bit messy.
Bye,
15 matches
Mail list logo