Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

decltype(auto) does not work for template functions

kovalJun 11 2018 — edited Jun 18 2018

Studio 12.6 fails to compile the following code:

int fun1(int x);

template<typename T>

decltype(auto) fun2(int x, T)

{

    return fun1(x);

}

decltype(auto) fun3(int x, short s)

{

    return fun2(x, s);

}

CC -c -std=c++14 decltype.cpp

"decltype.cpp", line 11: Error: Could not find a match for fun2<T>(int, short) needed in fun3(int, short).

1 Error(s) detected.

When fun2's return type is changed to explicit int (or decltype(fun1(x))) the error disappears, even though fun3 still uses decltype(auto)

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 16 2018
Added on Jun 11 2018
1 comment
275 views