使用从`std :: tuple`派生的元素在`std :: tuple`上调用`std :: get` - 形成错误?

Vit*_*meo 6 c++ libstdc++ language-lawyer c++11 stdtuple

struct Y { };
struct X : std::tuple<Y> { };

int main()
{
    std::get<0>(std::make_tuple(X{}));
}
Run Code Online (Sandbox Code Playgroud)

在wandbox上


clang++当使用libc ++时,上面的代码编译并按预期工作.

上面的代码失败,都编译clang++g++使用时的libstdc ++,错误如下:

include/c++/7.0.1/tuple:1302:36: 
error: no matching function for call to ‘__get_helper<0>(std::tuple<X>&)’
    { return std::__get_helper<__i>(__t); }
            ~~~~~~~~~~~~~~~~~~~~~~^~~~~

include/c++/7.0.1/tuple:1290:5: 
note: candidate: template<long unsigned int __i, class _Head, class ... _Tail> 
                constexpr _Head& std::__get_helper(std::_Tuple_impl<_Idx, _Head, _Tail ...>&)
    __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
    ^~~~~~~~~~~~

include/c++/7.0.1/tuple:1290:5: 
note:   template argument deduction/substitution failed:
include/c++/7.0.1/tuple:1302:36: 
note:   ‘std::_Tuple_impl<0, _Head, _Tail ...>’ is an ambiguous base class of ‘std::tuple<X>’
    { return std::__get_helper<__i>(__t); }
            ~~~~~~~~~~~~~~~~~~~~~~^~~~~

include/c++/7.0.1/tuple:1295:5: 
note: candidate: template<long unsigned int __i, class _Head, class ... _Tail> 
                constexpr const _Head& std::__get_helper(const std::_Tuple_impl<_Idx, _Head, _Tail ...>&)
    __get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
    ^~~~~~~~~~~~

include/c++/7.0.1/tuple:1295:5: 
note:   template argument deduction/substitution failed:
include/c++/7.0.1/tuple:1302:36: 
note:   ‘const std::_Tuple_impl<0, _Head, _Tail ...>’ is an ambiguous base class of ‘std::tuple<X>’
    { return std::__get_helper<__i>(__t); }
            ~~~~~~~~~~~~~~~~~~~~~~^~~~~
Run Code Online (Sandbox Code Playgroud)

似乎libstdc ++的基于继承的实现std::tuple在元组元素从std::tuple调用派生时导致歧义std::get.我倾向于认为这是libstdc ++中的实现缺陷- 是这样的吗?或者标准中是否存在使代码片段格式错误的内容?

Vit*_*meo 2

正如TC在评论中提到的,这是由已知错误 #71096引起的。