What does SFINAE not work correctly with following has_member function?

后端 未结 1 1594
情深已故
情深已故 2021-01-05 04:01

I\'m trying out examples from Walter Brown\'s TMP talk and I\'m trying to get his has_member implementation working.

However the implementation seems t

相关标签:
1条回答
  • 2021-01-05 04:56

    The problem is that gcc 4.8.2 (and prior to gcc 5.0) does not regard unused arguments in alias templates as suitable for SFINAE. The workaround is to forward to a voider class template:

    template <class ... T> struct voider { using type = void; };
    template <class ... T>
    using void_t = typename voider<T...>::type;
    

    From http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3911.pdf section 2.3:

    Alas, we have encountered implementation divergence (Clang vs. GCC) while working with the above very simple definition. We (continue to) conjecture that this is because of CWG issue 1558: “The treatment of unused arguments in an alias template specialization is not specified by the current wording of 14.5.7 [temp.alias].”

    0 讨论(0)
提交回复
热议问题