Empty nested tuples error

前端 未结 2 1330
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-12 21:46
#include 
#include 
int main(){

auto bt=std::make_tuple(std::tuple<>(),std::tuple>()); //Line 1
auto bt2         


        
2条回答
  •  青春惊慌失措
    2021-01-12 22:03

    By the way, for those who have to use gcc, let me give you a quick and dirty fix (for 4.8.0, already submitted a bug report) :

    The solution is a small modification of __empty_not_final in the tuple implementation, to prevent empty base optimisation for tuple<> type :

    template
        using __empty_not_final
          = typename conditional<__is_final(_Tp)||is_same<_Tp,tuple<>>::value,
    false_type, is_empty<_Tp>>::type;
    

    instead of

    template
        using __empty_not_final
          = typename conditional<__is_final(_Tp), false_type, is_empty<_Tp>>::type;
    

    (Note that, this is only an adhoc solution for tuple<> type, it does not solve the real problem described by KennyTM, i.e. struct A{}; auto d = std::tuple, A>, A>{}; still does not compile)

提交回复
热议问题