简体   繁体   English

调试断言失败的映射/集合迭代器不可取消

[英]Debug Assertion Failed map/set iterator not dereferencable

I have My Map std::map<const char*, int> uniforms; 我有我的地图std::map<const char*, int> uniforms; and when i try to find the data using uniforms.find(name)->second I get the error stated. 当我尝试使用uniforms.find(name)->second查找数据时,出现错误提示。 I have checked the data stored in debug mode and it is all there correctly as I expected and i can access most of it using the find function but when I try and access directionalLight.base.color I get the error. 我已经检查了存储在调试模式下的数据,并且所有数据都正确地存在,并且可以使用find函数访问其中的大多数数据,但是当我尝试访问directionalLight.base.color我得到了错误。 Like I said they are spelled correctly and there in debug mode but I get the error. 就像我说的那样,它们的拼写正确并且处于调试模式,但是我得到了错误。 Is it the dots in the string? 它是字符串中的点吗?

You might be running past the end of map, so before dereferencing you should check if its valid 您可能正在通过地图的结尾,因此在取消引用之前,应检查其是否有效

auto it = uniforms.find(name) ; // or std::map<const char*, int>::iterator it ;

if ( it != uniforms.end() )
{
   // Now use  it->second 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM