Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22310

Clang doesn't compile code but gcc and msvc compiled it

$
0
0

I don't understand what's the problem: either in my code or in the compiler (less possible). There is a piece of code like this:

#include <iostream>
#include <type_traits>
#include <set>


template<typename T, typename = void>
struct TestA: std::false_type {};

template<typename T>
struct TestA<T, std::void_t<typename T::reverse_iterator>> : std::true_type {};

template<typename T>
struct TestA<T, std::void_t<typename T::dummy_iterator>> : std::true_type {};

int main()
{
    std::cout << TestA<std::set<int>>::value;
}

Both GCC and MSVC compile it. I tested it on godbolt with different version of GCC and MSVC 17(local) and 19. Here is a link: https://godbolt.org/z/Enfm6L.

But Clang doesn't compile it and emits an error:

redefinition of `'TestA<T, std::void_t<typename T::dummy_iterator> >'`

And I'm interested - maybe there is some part of the standard where this piece of code is incorrect or maybe something else.


Viewing all articles
Browse latest Browse all 22310

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>