Compilation error when using temporary as function argument to a template function #33
-
The following example fails to compile using the current master or develop branch, tested with gcc-10.3.0 and clang-15.0.4
with the following error message (gcc):
Returning just Is that expected behaviour or could it be a bug? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Short answer: It is expected behavior. Long answer: CoDiPack uses expression templates to reduce the memory footprint of the recorded tapes. Therefore, we return the expressions and not the computed value. Only an assignment converts the expression to a value. The automatic deduction of the template parameter for There are two ways to fix this problem:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick answer, the explanation and the suggestions! Feel free to close this then. |
Beta Was this translation helpful? Give feedback.
Short answer: It is expected behavior.
Long answer: CoDiPack uses expression templates to reduce the memory footprint of the recorded tapes. Therefore, we return the expressions and not the computed value. Only an assignment converts the expression to a value.
The automatic deduction of the template parameter for
compute
therefore deduces the expression type. C++ does not give us the means to change the deduction behavior.There are two ways to fix this problem: