Skip to content

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

@lhprojects

Description

@lhprojects

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions