加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

错误是xmemory – c 0x支持丢失?

发布时间:2020-12-16 09:38:42 所属栏目:百科 来源:网络整理
导读:我已经制作了一个winform应用程序,其中我使用了array [n] [n]类型的向量 typedef char myarray[9][9]; typedef vectormyarray array3d; 据我所知,此功能在c 0x中提供.我使用visual studio 2010终极版是xmemory中的错误,因为这个? ide显示没有其他错误(甚至
我已经制作了一个winform应用程序,其中我使用了array [n] [n]类型的向量

typedef char myarray[9][9];  
typedef vector<myarray> array3d;

据我所知,此功能在c 0x中提供.我使用visual studio 2010终极版是xmemory中的错误,因为这个? ide显示没有其他错误(甚至没有上面的代码)

'Target of operator new()' : array initialization needs curly braces

在xmemory中指向此代码

void construct(pointer _Ptr,_Ty&& _Val)
    {   // construct object at _Ptr with value _Val
    ::new ((void _FARQ *)_Ptr) _Ty(_STD forward<_Ty>(_Val));
    }

在超过2.5 k线的代码中,我如何找到问题所在?

编辑:

因为这里的问题似乎是我用向量做的所有操作

#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef char myarray[9][9];
typedef string string_array[9][9];

void function2(vector<string_array>*my_3d_string_array,int d)
{
    string::iterator it;
    int j,cl;
    it=find((*my_3d_string_array)[d][j][cl].begin(),(*my_3d_string_array)[d][j][cl].end(),3);
    (*my_3d_string_array)[d][2][3].erase(it);
}

void function(vector<string_array>*my_3d_string_array,int d)
{
    (*my_3d_string_array)[d][3][4] = 2;
    function2(my_3d_string_array,d);
}

int main()
{
    myarray matrix;
    string_array string_matrix;

    std::vector<myarray>      my_3d_array;
    std::vector<string_array> my_3d_string_array;

    // fill_matrix(matrix);
    // fill_string_matrix(string_matrix)

    int d;
    function(&my_3d_string_array,d); // passing pointer to vector to a function d is the 3rd dimention

    my_3d_array.push_back(matrix);
    my_3d_string_array.push_back(string_matrix);
}

我在这里犯了一个愚蠢的错误吗?

解决方法

数据类型不支持作为容器中的元素.

解决方法可能是使用std :: array<>而不是char []

#include <vector>
#include <array>

typedef std::array<std::array<char,4>,6> array;
typedef std::vector<array> _3darray; 

int main()
{
    _3darray a,b;
    a = b;
}

> g 4.6喜欢它> MSVC 2010也不喜欢它:)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读