使用带有单个参数的元组进行clang编译错误

时间:2016-08-09 17:59:11

标签: c++11 clang++

我不明白为什么clang不会编译以下代码但gcc会这样做。没有args或多个arg到元组工作,单个arg没有。

   #include <tuple>

   int main(int , char *[])
   {
       // fails
       std::tuple<int> a;

       // works
       std::tuple<> b;
       std::tuple<int,int> c;
       return 0;
   } 

铿锵错误

$ clang++ -std=c++14 tuple.cpp 
In file included from tuple.cpp:1:
/usr/lib/gcc/x86_64-redhat-linux/6.1.1/../../../../include/c++/6.1.1/tuple:483:62: error: pack
      expansion contains parameter packs '_Elements' and '_UElements' that have different lengths
      (1 vs. 0)
      return __and_<is_constructible<_Elements, _UElements&&>...>::value;
                                     ~~~~~~~~~  ~~~~~~~~~~   ^
/usr/lib/gcc/x86_64-redhat-linux/6.1.1/../../../../include/c++/6.1.1/tuple:631:21: note: in
      instantiation of function template specialization 'std::_TC<true,
      int>::_MoveConstructibleTuple<>' requested here
                    _MoveConstructibleTuple<_UElements...>()
                    ^
/usr/lib/gcc/x86_64-redhat-linux/6.1.1/../../../../include/c++/6.1.1/tuple:636:19: note: while
      substituting prior template arguments into non-type template parameter [with _UElements = <>]
        constexpr tuple(_UElements&&... __elements)
                  ^~~~~
tuple.cpp:5:21: note: while substituting deduced template arguments into function template 'tuple'
      [with _UElements = <>, $1 = (no value)]
    std::tuple<int> a;
                    ^
In file included from tuple.cpp:1:
/usr/lib/gcc/x86_64-redhat-linux/6.1.1/../../../../include/c++/6.1.1/tuple:489:60: error: pack
      expansion contains parameter packs '_UElements' and '_Elements' that have different lengths
      (0 vs. 1)
      return __and_<is_convertible<_UElements&&, _Elements>...>::value;
                                   ~~~~~~~~~~    ~~~~~~~~~ ^
/usr/lib/gcc/x86_64-redhat-linux/6.1.1/../../../../include/c++/6.1.1/tuple:633:21: note: in
      instantiation of function template specialization 'std::_TC<true,
      int>::_ImplicitlyMoveConvertibleTuple<>' requested here
                    _ImplicitlyMoveConvertibleTuple<_UElements...>()
                    ^
/usr/lib/gcc/x86_64-redhat-linux/6.1.1/../../../../include/c++/6.1.1/tuple:636:19: note: while
      substituting prior template arguments into non-type template parameter [with _UElements = <>]
        constexpr tuple(_UElements&&... __elements)
                  ^~~~~
tuple.cpp:5:21: note: while substituting deduced template arguments into function template 'tuple'
      [with _UElements = <>, $1 = (no value)]
    std::tuple<int> a;
                    ^
2 errors generated.

0 个答案:

没有答案