- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the following example, the return type of a friend function cannot be deduced:
struct B {}; template <class T> struct A { friend auto bar(A const&) { return B{}; } }; int main() { using L = decltype(bar(A<int>{})); }
When defining bar outside of A it can be deduced, but requires to specify the template parameters for A again. Putting B instead of auto in the return type, the code also compiles fine.
This is related to an old stackoverflow question: https://stackoverflow.com/questions/18931993/return-type-deduction-for-in-class-friend-functions
In the answers it is referred to the standard document N3638. Both, GCC and Clang compile the code without complains. Intel icc 18 results inthe error "cannot deduce return type of function bar"
See also, the compiler explorer output using intel c++ 18: https://godbolt.org/g/69KQTt
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Praetorius,
This seems to be a known issue and has been addressed. You will not encounter this issue in the next 18.0 update.
Regards,
Viet

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page