草庐IT

bad_cast

全部标签

android - 为什么 eglMakeCurrent() 因 EGL_BAD_MATCH 而失败?

我正在使用opengl/egl为Android开发。我的应用需要第二个上下文来从第二个线程加载纹理。我的代码在android2.3上运行良好,但是当我在4.0.3android设备或模拟器上尝试该代码时,eglMakeCurrent()失败并显示EGL_BAD_MATCH。第二个上下文的初始化和它的像素缓冲区也都工作正常,所以我不确定从哪里开始寻找这个错误。这是初始化代码:ANativeWindow*window=(ANativeWindow*)displaySurface;EGLintdummy,format;display=eglGetDisplay(EGL_DEFAULT_DIS

android - 为什么 eglMakeCurrent() 因 EGL_BAD_MATCH 而失败?

我正在使用opengl/egl为Android开发。我的应用需要第二个上下文来从第二个线程加载纹理。我的代码在android2.3上运行良好,但是当我在4.0.3android设备或模拟器上尝试该代码时,eglMakeCurrent()失败并显示EGL_BAD_MATCH。第二个上下文的初始化和它的像素缓冲区也都工作正常,所以我不确定从哪里开始寻找这个错误。这是初始化代码:ANativeWindow*window=(ANativeWindow*)displaySurface;EGLintdummy,format;display=eglGetDisplay(EGL_DEFAULT_DIS

c++ - std::to_string、boost::to_string 和 boost::lexical_cast<std::string> 之间有什么区别?

boost::to_string的目的是什么?(在boost/exception/to_string.hpp中找到)以及它与boost::lexical_cast有何不同和std::to_string? 最佳答案 std::to_string,自C++11起可用,专门用于基本数字类型。它还有一个std::to_wstring变种。它旨在产生与sprintf相同的结果。会的。您可以选择这种形式来避免对外部库/头文件的依赖。抛出失败函数boost::lexical_cast和它不会throw的表亲boost::conversion::t

c++ - std::to_string、boost::to_string 和 boost::lexical_cast<std::string> 之间有什么区别?

boost::to_string的目的是什么?(在boost/exception/to_string.hpp中找到)以及它与boost::lexical_cast有何不同和std::to_string? 最佳答案 std::to_string,自C++11起可用,专门用于基本数字类型。它还有一个std::to_wstring变种。它旨在产生与sprintf相同的结果。会的。您可以选择这种形式来避免对外部库/头文件的依赖。抛出失败函数boost::lexical_cast和它不会throw的表亲boost::conversion::t

c++ - 如何避免 const cast 进行 map 访问?

我有以下问题:std::mapmap;voidgetColor(Aconst*obj){doubled=map[obj];//doesnotcompilewihtoutconst_cast(obj)//dosomething}我有一个mapstd::map(某处),它存储指向对象A的指针。我有一个getColor函数,它不操作对象A,因此将指向constA的指针作为输入.如果不使用const_cast,函数getColor将无法编译。constcast是一个设计问题,但如果我不想在map中制作键,我不知道如何规避它常量。任何帮助表示赞赏。 最佳答案

c++ - 如何避免 const cast 进行 map 访问?

我有以下问题:std::mapmap;voidgetColor(Aconst*obj){doubled=map[obj];//doesnotcompilewihtoutconst_cast(obj)//dosomething}我有一个mapstd::map(某处),它存储指向对象A的指针。我有一个getColor函数,它不操作对象A,因此将指向constA的指针作为输入.如果不使用const_cast,函数getColor将无法编译。constcast是一个设计问题,但如果我不想在map中制作键,我不知道如何规避它常量。任何帮助表示赞赏。 最佳答案

c++ - 在 C++ 中,static_cast<double>(a) 和 double(a) 有什么区别?

两者有什么区别inta;//agetssomevaluedoublepi=static_cast(a)/3;和inta;//agetssomevaluedoublepi=double(a)/3;你见过后者吗?在我看来,我在Stroustrup编写的一些片段中看到了它,但我找不到引用。 最佳答案 可能有人认为他们是在构建而不是在类型转换。考虑:some_fun(std::string("Hello"));许多人认为他们在那里调用了构造函数,而实际上他们正在执行C风格的转换。碰巧的是,强制转换会在它查看的一长串其他东西中查看目标类型的构

c++ - 在 C++ 中,static_cast<double>(a) 和 double(a) 有什么区别?

两者有什么区别inta;//agetssomevaluedoublepi=static_cast(a)/3;和inta;//agetssomevaluedoublepi=double(a)/3;你见过后者吗?在我看来,我在Stroustrup编写的一些片段中看到了它,但我找不到引用。 最佳答案 可能有人认为他们是在构建而不是在类型转换。考虑:some_fun(std::string("Hello"));许多人认为他们在那里调用了构造函数,而实际上他们正在执行C风格的转换。碰巧的是,强制转换会在它查看的一长串其他东西中查看目标类型的构

C++ 错误 : terminate called after throwing an instance of 'std::bad_alloc'

我在eclipse上使用下面的代码,我得到一个错误终止“在抛出'std::bad_alloc'what():std::bad_alloc的实例后调用”。我有RectInvoice类和Invoice类。classInvoice{public://......otherfunctions.....private:stringname;Matim;intwidth;intheight;vectorrectInvoiceVector;};我在Invoice的方法中使用下面的代码。//vect:vector*vect;RectInvoicerect(vect,im,x,y,w,h);this->

C++ 错误 : terminate called after throwing an instance of 'std::bad_alloc'

我在eclipse上使用下面的代码,我得到一个错误终止“在抛出'std::bad_alloc'what():std::bad_alloc的实例后调用”。我有RectInvoice类和Invoice类。classInvoice{public://......otherfunctions.....private:stringname;Matim;intwidth;intheight;vectorrectInvoiceVector;};我在Invoice的方法中使用下面的代码。//vect:vector*vect;RectInvoicerect(vect,im,x,y,w,h);this->