java vector push_back_无法将gl_ :: mat4元素push_back转换为头文件中声明的向量(Can't push_back a glm::mat4 element into...

无法将gl_ :: mat4元素push_back转换为头文件中声明的向量(Can't push_back a glm::mat4 element into a vector declared in a header file)

我在头文件中有一个矢量delared ah :

// in a.h

class A {

public:

...

std::vector<:mat4> transforms;

}

我试着在我的a.cpp文件a.cpp一个对象push_back() :

// in a.cpp

glm::mat4 transform;

transforms.push_back(transform); // errors here

但我收到这些错误:

没有重载函数的实例“std :: vector <_ty> :: push_back [with _Ty = glm :: mat4,_Alloc = std :: allocator]”匹配参数列表和对象(该对象具有阻止a的类型限定符比赛)

'std :: vector> :: push_back':2个重载没有'this'指针的合法转换

如果我尝试直接在a.cpp文件中声明向量,那么它可以工作:

// in a.cpp

std::vector<:mat4> foo;

foo.push_back(transform); // this works

到底是怎么回事? 当我在头文件中声明向量时,我做错了什么?

I have a vector delared in a header file a.h:

// in a.h

class A {

public:

...

std::vector<:mat4> transforms;

}

I tried to push_back() an object into it in my a.cpp file:

// in a.cpp

glm::mat4 transform;

transforms.push_back(transform); // errors here

but I'm getting these errors:

no instance of overloaded function "std::vector<_ty _alloc>::push_back [with _Ty=glm::mat4, _Alloc=std::allocator]" matches the argument list and object (the object has type qualifiers that prevent a match)

and

'std::vector>::push_back': 2 overloads have no legal conversion for 'this' pointer

If I try to declare the vector directly inside the a.cpp file then it works:

// in a.cpp

std::vector<:mat4> foo;

foo.push_back(transform); // this works

What is going on? What did I do wrong when I declared the vector in the header file?

原文:https://stackoverflow.com/questions/35882686

2019-07-11 11:00

满意答案

该对象具有阻止匹配的类型限定符

专注于此,因为这似乎是问题所在。 这意味着您可能已经在向量中创建了一些内容,或者已经在A类中应用了常量类型限定符。 这是我能说的最好的,没有更多的信息,因为很明显它不是矢量本身有问题。

为了获得更清晰明确的答案,您可能需要发布您正在使用的确切代码。

the object has type qualifiers that prevent a match

Focus on this, as this seems to be the problem. It means that you may have made something to do with the vector being or having applied to it a constant type qualifier in your A class. That is the best I can say without more information, as it is obvious that it is not the vector itself that has the problem.

For a clearer and more definite answer you might have to post the exact code you are using.

2016-03-09

相关问答

虽然没有构造函数,但GLM在glm / gtc / type_ptr.hpp中包含make_ *函数: #include

float aaa[16];

glm::mat4 bbb = glm::make_mat4(aaa);

Although there isn't a constructor, GLM includes make_* functions in glm/gtc/type_ptr.hpp: #include

看起来像http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#526解决了这个问题(或与之非常相似的问题)作为标准的潜在缺陷: 1)在执行函数时可以更改由const引用的参数 例子: 给定std :: vector v: v.insert(v.begin(),v [2]); v [2]可以通过向量的移动元素来改变 提出的决议是这不是一个缺点: vector :: insert(iter,value)是必需的,因为标准没有给它的权限不...

你为什么分配新的矢量? 你为什么用新的分配你的临时DEMData对象? 一个vector存储你传递给它的副本 ,而不是数据本身,所以除非你删除了你用新分配的DEMData对象,否则在你将一个项目推送到向量上时你会漏出内存。 同样,你也可以通过动态分配向量来设置自己的内存泄漏问题。 至于为什么向量中的对象似乎都包含相同的数据,很可能你有更多相同的东西 - 可能使用指针与不正确的拷贝结合起来,最终在浅层拷贝上做一些应用' - 但由于您没有向我们显示该代码,这只是一个猜测。 编辑:现在你已经添加了DEM...

使用OpenGL时,坚持使用齐次坐标是非常明智的。 对于3D空间,这些是4D向量,通常第四个元素等于1.当您执行此操作时,所有计算都在4维空间中,因此不需要任何转换。 另请注意,在您的示例中,您实际上将丢失可能已在转换矩阵中记录的任何转换。 如果你想保留它,你需要使用1作为第4个元素,而不是0。 红皮书的附录F描述了在OpenGL中如何以及为何使用齐次坐标。 When working with OpenGL it is very wise to stick with homogeneous coo...

该对象具有阻止匹配的类型限定符 专注于此,因为这似乎是问题所在。 这意味着您可能已经在向量中创建了一些内容,或者已经在A类中应用了常量类型限定符。 这是我能说的最好的,没有更多的信息,因为很明显它不是矢量本身有问题。 为了获得更清晰明确的答案,您可能需要发布您正在使用的确切代码。 the object has type qualifiers that prevent a match Focus on this, as this seems to be the problem. It means t...

你的代码有未定义的行为,因为这里 ppt p = v.at(i);

cout << p->x << " " << p->y << endl;

您正尝试访问已经被破坏的对象: {

Point p;

ppt pp = &p;

cin >> pp->x;

cin >> pp->y;

v.push_back(pp);

} // p is destructed here, so you have a dangling pointer in the vector

...

矢量按值存储而不是通过引用 。 当你重新添加相同的元素时,副本将被存储在最后。 如果你不想复制你插入到vector中的值,那么你应该使用指针。 例: std::vector<:string> v;

string s = "";

v.push_back(s);

s = "hi";

v.push_back(s);

v现在包含2个不同的元素,其中一个具有空字符串,另一个具有包含"hi"的字符串。 矢量中的两个字符串都与s保持独立。 注意:STL容器的内部实现细节可能会有所不同,但不能保证它将以...

这个: ReduceArg* plhold;

reduce_args_.push_back(plhold);

除非你隐藏了一些重要的代码,否则你会推动一个未初始化的指针,所以下一行会引起混乱。 可能你的意思是这个? ReduceArg* plhold(new ReduceArg);

..但我怀疑你没有正确考虑对象的生命周期和对象的所有权,你的地址存储在向量中。 一般情况下,除非您确切知道自己在做什么,以及为什么要这样做,否则请避免指针。 发布的代码不需要它们,我建议你只使用这样的东西: typ...

相关文章

Data Week: Becoming a data scientist Data Pointed,

...

pro-du-cer n. 1. Someone from a game publisher who

...

As you know, I've been playing with Solr lately, tr

...

With an executive staffing venture about to open, a

...

http://spark-project.org/ 项目首页 http://shark.cs.berk

...

5th Jan, 10 Drupal drupal advanced forum drupa

...

Open [Tomcat install dir]\tomcat-users.xmlfor editi

...

Part Three of Seven Easy Principles to Becoming a M

...

Windowsis an extremely effective and a an efficient

...

http://gumstix.org/create-a-bootable-microsd-card.h

...

最新问答

如果启用了复制处理程序,请确保将其置于其中一个安全角色之后。 我见过人们做的另一件事是在不同的端口上运行admin。 最好在需要auth的页面上使用SSL,这样你就不会发送明确的密码,因此管理和复制将发生在8443上,而常规查询将在8080上发生。 如果您要签署自己的证书,请查看此有用的SO页面: 如何在特定连接上使用不同的证书? I didn't know that /admin was the context for SOLR admin because /admin does not re

第一:在您的样本中,您有: 但是你在询问 //td[@class=‘CarMiniProfile-TableHeader’] (注意TableHeader中的大写'T')。 xpath区分大小写。 第二:通过查询// td [@ class ='CarMiniProfile-TableHeader'] / td,你暗示你在外部td中有一个'td'元素,而它们是兄弟姐妹。 有很多方法可以在这里获得制作和模型

这是你的答案: http://jsfiddle.net/gPsdk/40/ .preloader-container { position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; background: #FFFFFF; z-index: 5; opacity: 1; -webkit-transition: all 500ms ease-out;

问题是,在启用Outlook库引用的情况下, olMailItem是一个保留常量,我认为当您将Dim olMailItem as Outlook.MailItem ,这不是问题,但是尝试设置变量会导致问题。 以下是完整的解释: 您已将olMailItem声明为对象变量。 在赋值语句的右侧,在将其值设置为对象的实例之前,您将引用此Object 。 这基本上是一个递归错误,因为你有对象试图自己分配自己。 还有另一个潜在的错误,如果之前已经分配了olMailItem ,这个语句会引发另一个错误(可能是

我建议使用wireshark http://www.wireshark.org/通过记录(“捕获”)设备可以看到的网络流量副本来“监听”网络上发生的对话。 当您开始捕获时,数据量似乎过大,但如果您能够发现任何看起来像您的SOAP消息的片段(应该很容易发现),那么您可以通过右键单击并选择来快速过滤到该对话'关注TCP Stream'。 然后,您可以在弹出窗口中查看您编写的SOAP服务与Silverlight客户端之间的整个对话。 如果一切正常,请关闭弹出窗口。 作为一个额外的好处,wireshar

Android默认情况下不提供TextView的合理结果。 您可以使用以下库并实现适当的aligntment。 https://github.com/navabi/JustifiedTextView Android Does not provide Justified aligntment of TextView By default. You can use following library and achieve proper aligntment. https://github.com/

你的代码适合我: class apples { public static void main(String args[]) { System.out.println("Hello World!"); } } 我将它下载到c:\ temp \ apples.java。 以下是我编译和运行的方式: C:\temp>javac -cp . apples.java C:\temp>dir apples Volume in drive C is HP_PAV

12个十六进制数字(带前导0x)表示48位。 那是256 TB的虚拟地址空间。 在AMD64上阅读wiki(我假设你在上面,对吗?)架构http://en.wikipedia.org/wiki/X86-64 12 hex digits (with leading 0x) mean 48 bits. That is 256 TB of virtual address space. Read wiki on AMD64 (I assume that you are on it, right?) ar

这将取决于你想要的。 对象有两种属性:类属性和实例属性。 类属性 类属性对于类的每个实例都是相同的对象。 class MyClass: class_attribute = [] 这里已经为类定义了MyClass.class_attribute ,您可以使用它。 如果您创建MyClass实例,则每个实例都可以访问相同的class_attribute 。 实例属性 instance属性仅在创建实例时可用,并且对于类的每个实例都是唯一的。 您只能在实例上使用它们。 在方法__init__中定

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值