Why can't I specialize in std :: tuple_element?

The following program tries to provide specialization for std::tuple_elementfor a custom type foo. Unfortunately, it clang-3.5rejects it using lib ++, but uses other compilers or uses other standard libraries with clang-3.5to accept the program. Is it correct? If not, why not?

#include <utility>

struct foo {};

namespace std
{
    template<size_t, class> struct tuple_element;
    template<size_t i>
    struct tuple_element<i, foo> {};
}

int main()
{
    return 0;
}

Compiler Output:

$ clang-3.5 -std=c++11 -stdlib=libc++ -lc++ test.cpp
test.cpp:11:8: error: explicit specialization of non-template struct 'tuple_element'
struct tuple_element<i, foo> {};
       ^            ~~~~~~~~
1 error generated.

$ clang-3.5 -std=c++11 -lstdc++ test.cpp
(no error)

$ g++-4.9 -std=c++11 test.cpp
(no error)
+4
source share
1 answer

libc++ std::__1::, std. , template<size_t, class> struct tuple_element; , - ( ).

.

+6

Source: https://habr.com/ru/post/1599394/


All Articles