Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can math functions return by value without const type qualifier? #12

Open
lhprojects opened this issue Sep 4, 2021 · 2 comments
Open

Comments

@lhprojects
Copy link

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.

@advanpix
Copy link
Owner

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.

@bashanbro
Copy link

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.

+1, THANKS. It works well now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants