mpreal
mpreal copied to clipboard
Can math functions return by value without const type qualifier?
Simple program failed to compile with VS2019 (It should be the same with the other compilers).
void foo(mpreal &&);
mpreal a,b;
foo(a+b); // a+b has a type of const mpreal
Note the signature of operator+: inline const mpreal operator+(const mpreal& a, const mpreal& b). It seems quite unnormal that returning value with a const qualifier. I don't know if there is any benefit by return value with const qualifier. However, there is clearly a drawback.
Thank you for reporting this. I added const qualifier in 2008, have no idea why. It didn't cause any issues back then.
Clearly we need to change this to support move semantic. Will consider doing this in future.
Thank you for reporting this. I added
constqualifier in 2008, have no idea why. It didn't cause any issues back then. Clearly we need to change this to support move semantic. Will consider doing this in future.
+1, THANKS. It works well now!