Re: Rvalue references

2018-01-13 Thread Tony via Digitalmars-d-learn
On Sunday, 14 January 2018 at 00:55:27 UTC, Jonathan M Davis wrote: [...] It the simplest case, it means that the compiler does a bitwise copy rather than a deep copy, but in other cases, it means that the compiler is able to use the object in-place rather than creating a deep copy that it

Re: Rvalue references

2018-01-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 12, 2018 01:59:49 Tony via Digitalmars-d-learn wrote: > On Monday, 8 January 2018 at 23:31:27 UTC, Jonathan M Davis wrote: > > auto foo(T)(auto ref T t) > > { > > > > return t; > > > > } > > > > foo(42); > > > > will result in foo being instantiated as > > > > int foo(int t)

Re: Rvalue references

2018-01-11 Thread Tony via Digitalmars-d-learn
On Monday, 8 January 2018 at 23:31:27 UTC, Jonathan M Davis wrote: auto foo(T)(auto ref T t) { return t; } foo(42); will result in foo being instantiated as int foo(int t) { return t; } whereas int i; foo(i); will result in foo being instantiated as int foo(ref int t) { retur

Re: Rvalue references

2018-01-10 Thread Steven Schveighoffer via Digitalmars-d-learn
would recommend to ignore auto ref for rvalue references. It generates 2^N functions where N is the amount of auto ref parameters. That the most awful template bloat I've ever seen. It only generates 2^N functions if you call it 2^N different ways. Most of the time you call it the same way.

Re: Rvalue references

2018-01-10 Thread Dgame via Digitalmars-d-learn
rvalue references. It generates 2^N functions where N is the amount of auto ref parameters. That the most awful template bloat I've ever seen. It only generates 2^N functions if you call it 2^N different ways. Most of the time you call it the same way. -Steve If that would be tr

Re: Rvalue references

2018-01-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/10/18 3:08 AM, Dgame wrote: On Wednesday, 10 January 2018 at 01:56:02 UTC, Steven Schveighoffer wrote: But current auto ref is what we have, so I would recommend using it. I would recommend to ignore auto ref for rvalue references. It generates 2^N functions where N is the amount of

Re: Rvalue references

2018-01-10 Thread Dgame via Digitalmars-d-learn
On Wednesday, 10 January 2018 at 01:56:02 UTC, Steven Schveighoffer wrote: But current auto ref is what we have, so I would recommend using it. I would recommend to ignore auto ref for rvalue references. It generates 2^N functions where N is the amount of auto ref parameters. That the most

Re: Rvalue references

2018-01-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/8/18 6:07 PM, Jiyan wrote: Sry i know i asked it already in IRC: Are rvalue references already solved with auto ref? https://p0nce.github.io/d-idioms/#Rvalue-references:-Understanding-auto-ref-and-then-not-using-it Says rvalues are moved! But an rvalue move is cheaper. You construct

Re: Rvalue references

2018-01-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 08, 2018 23:07:52 Jiyan via Digitalmars-d-learn wrote: > Sry i know i asked it already in IRC: > Are rvalue references already solved with auto ref? > > https://p0nce.github.io/d-idioms/#Rvalue-references:-Understanding-auto-re > f-and-then-not-using-it >

Rvalue references

2018-01-08 Thread Jiyan via Digitalmars-d-learn
Sry i know i asked it already in IRC: Are rvalue references already solved with auto ref? https://p0nce.github.io/d-idioms/#Rvalue-references:-Understanding-auto-ref-and-then-not-using-it Says rvalues are moved! The other solution seems not so practical. Is any solution to them intended, or

Re: difference between C++11 rvalue references && and D's proposed rvalue reference?

2013-04-16 Thread Namespace
On Monday, 15 April 2013 at 23:16:57 UTC, Timothee Cour wrote: What would be the difference between C++11's rvalue reference && (see for example http://thbecker.net/articles/rvalue_references/section_03.html) and D's proposed rvalue references (eg http://wiki.dlang.org/DIP36)

difference between C++11 rvalue references && and D's proposed rvalue reference?

2013-04-15 Thread Timothee Cour
What would be the difference between C++11's rvalue reference && (see for example http://thbecker.net/articles/rvalue_references/section_03.html) and D's proposed rvalue references (eg http://wiki.dlang.org/DIP36) ? So far I only saw C++'s const & mentioned, but C+

Re: rvalue references template ?

2012-01-02 Thread Joshua Reusch
Am 02.01.2012 22:13, schrieb Simen Kjærås: On Mon, 02 Jan 2012 15:02:30 +0100, Joshua Reusch wrote: Is it possible to create a template turning any value into a lvalue? This would be helpful if a function expects a reference but you dont need the result of the change: ///decode(S)(in S str, r

Re: rvalue references template ?

2012-01-02 Thread Simen Kjærås
On Mon, 02 Jan 2012 15:02:30 +0100, Joshua Reusch wrote: Is it possible to create a template turning any value into a lvalue? This would be helpful if a function expects a reference but you dont need the result of the change: ///decode(S)(in S str, ref size_t index); auto c = std.utf.deco

Re: rvalue references template ?

2012-01-02 Thread Simen Kjærås
On Mon, 02 Jan 2012 15:02:30 +0100, Joshua Reusch wrote: Is it possible to create a template turning any value into a lvalue? This would be helpful if a function expects a reference but you dont need the result of the change: ///decode(S)(in S str, ref size_t index); auto c = std.utf.deco

Re: rvalue references template ?

2012-01-02 Thread Timon Gehr
On 01/02/2012 03:02 PM, Joshua Reusch wrote: Is it possible to create a template turning any value into a lvalue? This would be helpful if a function expects a reference but you dont need the result of the change: ///decode(S)(in S str, ref size_t index); auto c = std.utf.decode(some_string, lva

rvalue references template ?

2012-01-02 Thread Joshua Reusch
Is it possible to create a template turning any value into a lvalue? This would be helpful if a function expects a reference but you dont need the result of the change: ///decode(S)(in S str, ref size_t index); auto c = std.utf.decode(some_string, lval!0);