const return value and template instantiation

Posted by Rimo on Stack Overflow See other posts from Stack Overflow or by Rimo
Published on 2010-05-28T02:29:33Z Indexed on 2010/05/28 2:31 UTC
Read the original article Hit count: 370

Filed under:
|
|
|

From Herb Sutter's GotW #6

 Return-by-value should normally be const for non-builtin return types.
    ....
 Note: Lakos (pg. 618) argues against returning const value,
 and notes that it is redundant for builtins anyway
 (for example, returning "const int"), which he notes may 
 interfere with template instantiation.
    ....

While Sutter seems to disagree on whether to return a const value or non-const value when returning an object of a non-built type by value with Lakos, he generally agrees that returning a const value of a built-in type (e.g const int) is not a good idea.

While I understand why that is useless because the return value cannot be modified as it is an rvalue, I cannot find an example of how that might interfere with template instantiation.

Please give me an example of how having a const qualifier for a return type might interfere with template instantiation.

© Stack Overflow or respective owner

Related posts about c++

Related posts about template