草庐IT

base_convert

全部标签

c++ - 错误 X8000 : D3D11 Internal Compiler error : Invalid Bytecode: Invalid operand type for operand #1 of opcode #86 (counts are 1-based)

我和我的讲师/实验室助理都被难住了。出于某种原因,以下HLSL代码在输出窗口中返回:errorX8000:D3D11InternalCompilererror:InvalidBytecode:Invalidoperandtypeforoperand#1ofopcode#86(countsare1-based).这是HLSL中导致问题的函数://ProjectsaspherediameterlargeinscreenspacetocalculatedesiredtesselationfactorfloatSphereToScreenSpaceTessellation(float3p0,f

c++ - 我需要类似 "using Base::*;"的东西

如果我的基类有一个函数func(int)而我的派生类有一个函数func(double),派生的func(double)隐藏base::func(int)。我可以使用using将基础版本引入派生的重载列表中:structbase{voidfunc(int);};structderived:base{usingbase::func;voidfunc(double);}好的,很好。但是,如果我不确定base是否有func()怎么办?也就是说,因为我正在进行模板元编程,所以我实际上并不确定base是什么,但我想将它的功能提升到相同的水平——如果它们存在的话。即把上面的例子改成:structba

具有私有(private)复制构造函数的 C++11 std::is_convertible 行为

我正在努力理解std::is_convertible在C++11中。根据cppreference.com,std::is_convertible::value当且仅当“如果类型为T的虚数右值可用于返回U的函数的返回语句中”,则应计算为1。不过,措辞并未说明该函数可能在何处声明。当U的复制构造函数时,人们应该期待什么?是私有(private)的?当T时应该期待什么是左值引用吗?例如,考虑这段代码:#include#includestructFact_A;structA{friendstructFact_A;A()=default;A(A&&)=delete;private:A(const

c++ - 从模板类 Base<A> 派生类 A 以便 Base<A> 可以使用 A::B?

templateclassBase{private:typenameT::Bc;};classA:publicBase{public:classB;};这样的事情有可能吗?VC++2013说B不是A的成员。 最佳答案 故事正如在直接针对您的问题的评论中所述,您试图完成的事情根本不可能,因为引用不完整类型是非法的(T=A在Base中).解决方法CRTP情况下的常见解决方法是使用trait表示应该在Derived中可用的成员和Base,但不打算在Base中声明/定义.尽管这并不真正等同于您要完成的目标,但它非常接近它,并且遵循某种等同的

C++:我可以在函数调用期间将 vector <derived_class> 转换为 vector <base_class> 吗?

我有一个现有的类和函数,如下所示:Classbase_class{...}voidFunc(...,vector&vec_b,...){//insidethefunction,thevectorvec_bisbeingre-organizedandre-sized}我定义了一个派生类,如下所示:Classderived_class:publicbase_class{...}现在,不改变函数Func,我可以传递一个vector吗?进入Func,例如:voidmain(){vectord;Func(...,d,...);}派生类d经历同样的重组和重新调整规模?我知道我可以在函数调用中毫无问

c++ - 从 Derived* 到 void* 到 Base* 的 static_cast

我想将指向派生类成员的指针转换为void*,然后从那里转换为基类的指针,如下例所示:#includeclassBase{public:voidfunction1(){std::cout(&d);Base*baseptr=static_cast(ptr);baseptr->function1();baseptr->function2();}这会编译并给出所需的结果(分别打印1和2),但它能保证工作吗?我在这里找到的static_cast的描述:http://en.cppreference.com/w/cpp/language/static_cast只提到转换为void*并返回到指向相同类

c++ - 将私有(private)部分保留在 c++ header 之外 : pure virtual base class vs pimpl

我最近从Java和Ruby切换回C++,令我惊讶的是,当我更改私有(private)方法的方法签名时,我不得不重新编译使用公共(public)接口(interface)的文件,因为私有(private)部分也在.h中文件。我很快想出了一个解决方案,我想这对Java程序员来说是典型的:接口(interface)(=纯虚拟基类)。例如:香蕉树.h:classBanana;classBananaTree{public:virtualBanana*getBanana(std::stringconst&name)=0;staticBananaTree*create(std::stringcons

c++ - OpenCV 2.3 : Convert Mat to RGBA pixel array

我正在尝试使用OpenCV从网络摄像头抓取帧并使用SFML在窗口中显示它们。VideoCapture以OpenCV的Mat格式返回帧。要显示帧,SFML需要uint8格式的一维像素数组,(据我所知)可以与uchar互换。该数组预计每像素RGBA表示32位。所以,我有一个uchar数组,我正在遍历Mat数据并复制每个像素:VideoCapturecap(0);Matframe;cap>>frame;uchar*camData=newuchar[640*480*4];uchar*pixelPtr=frame.data;for(inti=0;i不幸的是,这不太行得通。该循环中的某些地方是错误

c++ - make 失败,返回错误 "cannot convert ‘std::istream {aka std::basic_istream<char>}’ 到 ‘bool’”

我正在尝试从源代码编译libgtextutils(fastxtoolkit需要)。“./configure”命令运行良好,但随后的“make”命令产生了一个我无法解决的错误。text_line_reader.cpp:Inmemberfunction‘boolTextLineReader::next_line()’:text_line_reader.cpp:47:9:error:cannotconvert‘std::istream{akastd::basic_istream}’to‘bool’inreturnreturninput_stream;^~~~~~~~~~~~make[3]:*

c++ - 为什么 'is_convertible' 在 <utility> std::pair (STL) 中?

template::value&&is_constructible::value>,enable_if_t::value&&is_convertible::value,int>=0>constexprpair(pair&&_Right)_NOEXCEPT_OP((is_nothrow_constructible::value&&is_nothrow_constructible::value)):first(_STDforward(_Right.first)),second(_STDforward(_Right.second)){//constructfrommovedcompatibl