可疑的std :: array C ++ 11库被打破了?我该怎么办? [英] Suspected std::array C++11 library is broken? What do I do?

查看:1225
本文介绍了可疑的std :: array C ++ 11库被打破了?我该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从google我似乎找不到清楚的答案,但我不知道该怎么办。我怀疑在一个更大的程序可能有一个问题,我使用数组C ++ 11库为g ++编写并写了一个测试程序。我使用g ++ 4.8.1。

From google I can't seem to find clear answers, But I don't know what to do. I suspected there might be a problem in a larger program I was writing with the array C++11 library for g++ and wrote a test program. I am using g++ 4.8.1.

main.cpp:

#include <iostream>
#include <array>
int main()
{
    std::array<int,5> vector;

    return 0;
}

我的测试命令行编译是:

My test command line compile is:

g++ main.cpp -std=c++11


$ b

with errors..

In file included from main.cpp:2:0:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:107:12: error: 'array' has not been declared
       swap(array& __other)
            ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array: In member function 'void std::Array<_Tp, _Nm>::swap(int&)':
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:109:50: error: request for member 'begin' in '__other', which is of non-class type 'int'
       { std::swap_ranges(begin(), end(), __other.begin()); }
                                                  ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array: At global scope:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:228:22: error: 'array' does not name a type
     operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                      ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:228:27: error: expected ',' or '...' before '<' token
     operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                           ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:228:74: error: 'bool std::operator==(int)' must have an argument of class or enumerated type
     operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                                                                          ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:233:22: error: 'array' does not name a type
     operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                      ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:233:27: error: expected ',' or '...' before '<' token
     operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                           ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:233:74: error: 'bool std::operator!=(int)' must have an argument of class or enumerated type
     operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                                                                          ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:238:21: error: 'array' does not name a type
     operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
                     ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:238:26: error: expected ',' or '...' before '<' token
     operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
                          ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:238:69: error: 'bool std::operator<(int)' must have an argument of class or enumerated type
     operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
                                                                     ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:246:21: error: 'array' does not name a type
     operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                     ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:246:26: error: expected ',' or '...' before '<' token
     operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                          ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:246:73: error: 'bool std::operator>(int)' must have an argument of class or enumerated type
     operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                                                                         ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:251:22: error: 'array' does not name a type
     operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                      ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:251:27: error: expected ',' or '...' before '<' token
     operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                           ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:251:74: error: 'bool std::operator<=(int)' must have an argument of class or enumerated type
     operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                                                                          ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:256:22: error: 'array' does not name a type
     operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                      ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:256:27: error: expected ',' or '...' before '<' token
     operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                           ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:256:74: error: 'bool std::operator>=(int)' must have an argument of class or enumerated type
     operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
                                                                          ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:10: error: variable or field 'swap' declared void
     swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
          ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:10: error: 'array' was not declared in this scope
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:19: error: expected primary-expression before ',' token
     swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
                   ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:27: error: '__one' was not declared in this scope
     swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
                           ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:34: error: 'array' was not declared in this scope
     swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
                                  ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:43: error: expected primary-expression before ',' token
     swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
                                           ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:51: error: '__two' was not declared in this scope
     swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
                                                   ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:268:9: error: template declaration of 'constexpr _Tp& std::get'
     get(array<_Tp, _Nm>& __arr) noexcept
         ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:268:9: error: 'array' was not declared in this scope
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:268:18: error: expected primary-expression before ',' token
     get(array<_Tp, _Nm>& __arr) noexcept
                  ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:268:26: error: '__arr' was not declared in this scope
     get(array<_Tp, _Nm>& __arr) noexcept
                          ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:277:9: error: template declaration of 'constexpr _Tp&& std::get'
     get(array<_Tp, _Nm>&& __arr) noexcept
         ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:277:9: error: 'array' was not declared in this scope
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:277:18: error: expected primary-expression before ',' token
     get(array<_Tp, _Nm>&& __arr) noexcept
                  ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:277:27: error: label '__arr' referenced outside of any function
     get(array<_Tp, _Nm>&& __arr) noexcept
                           ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:277:27: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:285:15: error: 'array' does not name a type
     get(const array<_Tp, _Nm>& __arr) noexcept
               ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:285:20: error: expected ',' or '...' before '<' token
     get(const array<_Tp, _Nm>& __arr) noexcept
                    ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array: In function 'constexpr const _Tp& std::get(int)':
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:289:9: error: '__arr' was not declared in this scope
  _S_ref(__arr._M_elems, _Int);
         ^
In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\iostream:38:0,
                 from main.cpp:1:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array: At global scope:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:306:23: error: 'array' is not a member of 'std'
     struct tuple_size<_GLIBCXX_STD_C::array<_Tp, _Nm>>
                       ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:306:23: error: 'array' is not a member of 'std'
In file included from main.cpp:2:0:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:306:50: error: wrong number of template arguments (2, should be 1)
     struct tuple_size<_GLIBCXX_STD_C::array<_Tp, _Nm>>
                                                  ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:303:11: error: provided for 'template<class _Tp> class std::tuple_size'
     class tuple_size;
           ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:306:53: error: expected unqualified-id before '>' token
     struct tuple_size<_GLIBCXX_STD_C::array<_Tp, _Nm>>
                                                     ^
In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\iostream:38:0,
                 from main.cpp:1:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:314:32: error: 'array' is not a member of 'std'
     struct tuple_element<_Int, _GLIBCXX_STD_C::array<_Tp, _Nm>>
                                ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:314:32: error: 'array' is not a member of 'std'
In file included from main.cpp:2:0:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:314:59: error: wrong number of template arguments (3, should be 2)
     struct tuple_element<_Int, _GLIBCXX_STD_C::array<_Tp, _Nm>>
                                                           ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:311:11: error: provided for 'template<unsigned int _Int, class _Tp> class std::tuple_element'
     class tuple_element;
           ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:314:62: error: expected unqualified-id before '>' token
     struct tuple_element<_Int, _GLIBCXX_STD_C::array<_Tp, _Nm>>
                                                              ^
main.cpp: In function 'int main()':
main.cpp:5:2: error: 'array' is not a member of 'std'
  std::array<int,5> vector;
  ^
main.cpp:5:13: error: expected primary-expression before 'int'
  std::array<int,5> vector;
             ^
main.cpp:5:13: error: expected ';' before 'int'


b $ b

很明显,从错误,有很多引用我std ::数组文件,我已经包括,似乎是错误的根源。

And clearly from the error, there is a lot of reference to the std::array file that i have included which seems to be the source of the error. What do I do?

编辑:添加编译命令和g ++版本。

Thanks in advance.


推荐答案

以某种方式出现一个拼写错误到OP的< array> 。应该有什么

Turns out somehow a typo made its way into OP's <array>. What should have been

template<typename _Tp, std::size_t _Nm>
  struct array
  {

成为

template<typename _Tp, std::size_t _Nm>
  struct Array
  {

导致一个bazillion编译器错误, < array> 的其余部分。

Causing a bazillion compiler errors as it tries to process the rest of <array>.

这篇关于可疑的std :: array C ++ 11库被打破了?我该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆