digitalmars.D.learn - Is this a bug or am I doing something wrong?
- drsneed (6/6) Dec 03 2014 Check out http://dpaste.dzfl.pl/a5ada78fccf5
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (11/17) Dec 03 2014 Unlike C++, rvalues cannot be bound to reference parameters even if
- drsneed (3/23) Dec 03 2014 Ahh, I'm used to the c++ style. Nice write-up on the matter, and
- Steven Schveighoffer (3/20) Dec 04 2014 All that being said, what a horrible error message!
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (3/4) Dec 04 2014 https://issues.dlang.org/show_bug.cgi?id=13818
Check out http://dpaste.dzfl.pl/a5ada78fccf5 If my function named "IWillNotCompile" is run, I get an error stating "Component!int' and 'Component!int' are not compatible." If my function named "IWillCompile" is run, there are no errors. They do the same thing, just written slightly differently. Any suggestions?
Dec 03 2014
On 12/03/2014 03:02 PM, drsneed wrote:Check out http://dpaste.dzfl.pl/a5ada78fccf5 If my function named "IWillNotCompile" is run, I get an error stating "Component!int' and 'Component!int' are not compatible." If my function named "IWillCompile" is run, there are no errors. They do the same thing, just written slightly differently. Any suggestions?Unlike C++, rvalues cannot be bound to reference parameters even if reference to const. Make the parameter 'auto ref' and it will compile: Component!(T) opBinary(string op)(auto ref Component!(T) rhs) For auto ref, the function must be a template so that the compiler can generate by-reference and by-value versions of it depending on whether the argument is lvalue versus rvalue. Here is my understanding of the issue: http://ddili.org/ders/d.en/lvalue_rvalue.html Ali
Dec 03 2014
On Wednesday, 3 December 2014 at 23:09:02 UTC, Ali Çehreli wrote:On 12/03/2014 03:02 PM, drsneed wrote:Ahh, I'm used to the c++ style. Nice write-up on the matter, and thanks for the help!Check out http://dpaste.dzfl.pl/a5ada78fccf5 If my function named "IWillNotCompile" is run, I get an error stating "Component!int' and 'Component!int' are not compatible." If my function named "IWillCompile" is run, there are no errors. They do the same thing, just written slightly differently. Any suggestions?Unlike C++, rvalues cannot be bound to reference parameters even if reference to const. Make the parameter 'auto ref' and it will compile: Component!(T) opBinary(string op)(auto ref Component!(T) rhs) For auto ref, the function must be a template so that the compiler can generate by-reference and by-value versions of it depending on whether the argument is lvalue versus rvalue. Here is my understanding of the issue: http://ddili.org/ders/d.en/lvalue_rvalue.html Ali
Dec 03 2014
On 12/3/14 6:09 PM, Ali Çehreli wrote:On 12/03/2014 03:02 PM, drsneed wrote:All that being said, what a horrible error message! -SteveCheck out http://dpaste.dzfl.pl/a5ada78fccf5 If my function named "IWillNotCompile" is run, I get an error stating "Component!int' and 'Component!int' are not compatible." If my function named "IWillCompile" is run, there are no errors. They do the same thing, just written slightly differently. Any suggestions?Unlike C++, rvalues cannot be bound to reference parameters even if reference to const. Make the parameter 'auto ref' and it will compile: Component!(T) opBinary(string op)(auto ref Component!(T) rhs) For auto ref, the function must be a template so that the compiler can generate by-reference and by-value versions of it depending on whether the argument is lvalue versus rvalue. Here is my understanding of the issue: http://ddili.org/ders/d.en/lvalue_rvalue.html
Dec 04 2014
On 12/04/2014 06:37 AM, Steven Schveighoffer wrote:All that being said, what a horrible error message!https://issues.dlang.org/show_bug.cgi?id=13818 Ali
Dec 04 2014