GCC Bug 96976 (Resolved; implemented in GCC 10.2, GCC 11)
This looks like GCC resolved bug
which was recently marked as resolved
Jonathan Wakely 2020-09-08 11:56:59 UTC
Fixed on trunk by r11-1571
It's also fixed on the gcc-10 branch by r10-8343
where the solution has been implemented for GCC 10.2 and 11.
Known to work: 10.2.0, 11.0
Workaround?
The anonymous typename is for some SFINAE stuff, and I want a workaround to make it compile on older version of GCC.
As is similarly asked and answered in the comments to the bug report:
Igor Chorazewicz 2020-09-08 12:17:32 UTC
[...] Also, do you by any chance, have any ideas how to workaround it for now?
**Vorfeed Canal 2020-09-09 13:32:20 UTC **
Why couldn't you use std::enable_if in it's usual (for functions) place?
Like this:
template <typename K, typename... Args> auto f(K&& k, Args&&... args) -> std::enable_if_t<true, void> { }
you can remove the SFINAE-intended defaulted type template argument and apply SFINAE for the return type of the function instead, using trailing return type syntax.
Relevance to rvalue references?
Note that albeit the author of the bug report mentions problems with rvalue references in the title of the bug report, the failing example (fixed in GCC trunk) given in the report
#include <type_traits> template <typename... Args> void f(int &&a, Args&&... args) { } template <typename K, typename... Args, typename = typename std::enable_if<true, K>::type> void f(K&& k, Args&&... args) { } int main() { f(1, 2); return 0; }
likewise fails(/is fixed) if we remove the rvalue references for the arguments of the f overloads, and these were likely not the root cause for this issue.