草庐IT

用不完

全部标签

类型不完整的 C++ 静态 constexpr 字段

我正在尝试编译此代码,但g++提示ZERO的类型不完整。这是否意味着在C++中,结构不能包含自身的staticconstexpr实例?如果有,为什么?structCursor{size_trow,column;staticconstexprCursorZERO{0,0};//error:constexprconstCursorCursor::ZEROhasincompletetype};编辑:我知道当我声明ZERO时Cursor不能有完整的类型。我想知道的是:有什么方法可以让ZERO属于Cursor并且仍然是constexpr? 最佳答案

c++ - Pimpl - 为什么可以在不完整的类型上调用 make_unique

为什么make_unique调用会编译?make_unqiue不要求它的模板参数是一个完整的类型吗?structF;intmain(){std::make_unique();}structF{};问题源于我的PIMPL实现的“问题”:我确实理解为什么必须在实现类(PIMPL)的cpp文件中由用户声明和定义析构函数。但是移动包含pimpl-的类的构造函数仍然可以编译。classObject{};classCachedObjectFactory{public:CachedObjectFactory();~CachedObjectFactory();std::shared_ptrcreate

c++ - 不完整类型上的 std::is_constructible

我有以下代码:#includeclassA;intmain(){std::cout::value当我使用GCC8.3时,此代码编译。但是,当我使用Clang8.0,我得到一个编译错误,不完整的类型不能用于类型特征。哪一个是正确的?我是否可以在不完整的类型上使用is_constructible(预期值为false),还是不允许? 最佳答案 行为未定义。[meta.unary.prop]templatestructis_constructible;TandalltypesintheparameterpackArgsshallbecomp

c++ - 嵌套名称说明符中的类型不完整

我尝试在嵌套名称说明符中使用不完整类型,如下所示:classA;intb=A::c;//error:incompletetype‘A’usedinnestednamespecifierclassA{staticconstintc=5;};在N3797工作草案的3.4.3/1中没有任何说明:Thenameofaclassornamespacememberorenumeratorcanbereferredtoafterthe::scoperesolutionoperator(5.1)appliedtoanested-name-specifierthatdenotesitsclass,nam

c++ - 为什么类 { int i; };不完全符合标准?

这是一个后续问题。在previousquestion,@JohannesSchaub-litb说以下代码不完全符合标准:class{inti;};//unnamed-classdefinition.§9/1allowsthis!然后他补充说,whileitisgrammaticallyvalid,itbreakstherulethatsuchaclassmustdeclareatleastonenameintoitsenclosingscope.我真的无法理解这一点。他在说什么名字?谁能进一步详细说明(最好引用标准)? 最佳答案 标

C++变量具有初始化程序但类型不完整?

我正在尝试使用以下命令在C++中编译2个类:g++Cat.cppCat_main.cpp-oCat但我收到以下错误:Cat.cpp:10:10:错误:变量“CatJoey”具有初始化程序但类型不完整谁能给我解释一下这是什么意思?我的文件基本上做的是创建一个类(Cat.cpp)并创建一个实例(Cat_main.cpp)。这是我的源代码:Cat.cpp:#include#includeclassCat;usingnamespacestd;intmain(){CatJoey("Joey");Joey.Meow();return0;}Cat_main.cpp:#include#includeu

c++ - 不允许指向不完整类类型的指针

由于某种原因,我不能使用附加到我想使用的对象的函数。我在不起作用的行中添加了注释。作为一个错误,我得到“错误;不允许指向不完整类类型的指针”请帮助这是dokter.ccp中的代码intcounter=0;for(list::iteratorit=wielrenners.begin();it!=wielrenners.end();it++){Wielrenner*wielrennerOB=*it;coutprint();//Thisisnotworkingcounter++;}这是wielrenner.h中的代码#ifndefWIELRENNER_H_#defineWIELRENNER_

c++ - 不完整类型的无效使用

我正在尝试在我的项目中使用来自子类的typedef,我在下面的示例中隔离了我的问题。有人知道我哪里出错了吗?templateclassA{public://Whydoesn'titlikethis?voidaction(typenameSubclass::mytypevar){(static_cast(this))->do_action(var);}};classB:publicA{public:typedefintmytype;B(){}voiddo_action(mytypevar){//Dostuff}};intmain(intargc,char**argv){BmyInstan

c++ - Qt c++ 聚合 'std::stringstream ss' 类型不完整,无法定义

我的程序中有这个函数可以将整数转换为字符串:QStringStats_Manager::convertInt(intnum){stringstreamss;ss但是当我运行它时,我得到了错误:aggregate'std::stringstreamss'hasincompletetypeandcannotbedefined我不太确定这意味着什么。但是,如果您知道如何修复它或需要更多代码,请发表评论。谢谢。 最佳答案 你可能有一个类的前向声明,但没有包含标题:#include//...QStringStats_Manager::conv

c++ - 不允许不完整的类型 : stringstream

为什么这行会报错Error:Completetypeisnotallowed?stringstreamss; 最佳答案 #include并使用完全限定名称,即std::stringstreamss; 关于c++-不允许不完整的类型:stringstream,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/5781597/