草庐IT

create_default_context

全部标签

c++ - 最烦人的解析 : why doesn't `g( ( f() ) );` call `f` 's default constructor and pass the result to `g` 's ctor that takes a `f` ?

这不是Mostvexingparse:whydoesn'tAa(());work?的拷贝,它基于Aa());形式的解析,其OP认为可以使用额外的集合默认构造一个A对象括号。相比之下,我的问题是关于2个类,f和g,其中f具有默认构造函数,而g的构造函数采用f。我想用一个临时的f参数调用g的构造函数,而不使用统一的初始化语法。g的构造函数中有一个std::cout语句,因此缺少输出表示函数声明而不是g对象实例化。我在注释中用3个数字注释了示例代码。#1和#2编译时#3被注释掉,反之亦然:#includestructf{};structg{g(f){std::cout#1:我认为#1声明了一

C++/QML : How to define and handle multiple contexts for dynamically created components?

基本上我的情况是这样的:我有一个扩展QQuickView的类,它通过设置上下文属性将某些对象从C++公开到QML。显示的View是从QML创建的,并且都是同一定制组件的不同实例;当某些事件发生时会创建新View,当这种情况发生时,现有View应显示最初在C++端分配给它们的对象,而新View应显示分配给它们的对象。所以,在C++方面,我有这样的东西:WindowManager::WindowManager(QQuickView*parent):QQuickView(parent){//Settingthesourcefiletousethis->setSource(QUrl("qrc:

c++ - 有类似 "default comparator"的东西吗?

我写了一个模板,它包装了一个std::vector以确保vector总是排序:templateclassSortedVector{public:SortedVector(bool(*comparator)(T,T)=DefaultComparator){this->comparator=comparator;}voidinsertValue(TnewElement){vect.insert(std::lower_bound(vect.begin(),vect.end(),newElement,comparator),newElement);}private:std::vectorvec

c++ - 'default_random_engine' 不是 std 的成员

我发现了很多关于这个主题的问题,但所有问题似乎都与不使用C++11编译有关。我的代码是#includeintmain(intargc,char*argv[]){std::default_random_enginegenerator;return0;}即使我用编译gcc-std=c++0xtestmain.cpp给出default_random_engine不是std成员的错误。该程序是在远程机器上编译的,我自己不维护,但gcc-v生成4.4.7版本。有什么想法吗? 最佳答案 对于其他人:检查您是否真的在#include中包含了随机数

c++ - 在 ubuntu 中找不到 pthread_create

我正在尝试在Ubuntu上运行cocos2d-x。它显示此错误:--LookingforIceConnectionNumberinICE--LookingforIceConnectionNumberinICE-found--FoundX11:/usr/lib/x86_64-linux-gnu/libX11.so--FoundOpenGL:/usr/lib/x86_64-linux-gnu/libGL.so--Lookingforincludefilepthread.h--Lookingforincludefilepthread.h-found--Lookingforpthread_cr

C++ "No appropriate default constructor available"

我想在不使用STL的情况下创建一个数组链表。但是,我在将数组传递到我的链接列表时遇到困难...编译时出现上面列出的错误。我需要如何将数组传递给链表?谢谢!(有问题的代码有**标记,如果测试请去掉)单链表.h#pragmaonce#ifndefSinglyLinkedList_h#defineSinglyLinkedList_h#includetemplatestructnode{Typevalue;node*next;};templateclassSinglyLinkedList{private:node*head;public:SinglyLinkedList();~SinglyLi

C++ WIN API : When creating a child process using CreateProcess, 是否需要使输入参数具有全局生命周期?

我对C++和WindowsAPI都很陌生。今天突然想到是不是需要把CreateProcess的入参保持一个长生命周期。根据MSDN:BOOLWINAPICreateProcess(_In_opt_LPCTSTRlpApplicationName,_Inout_opt_LPTSTRlpCommandLine,_In_opt_LPSECURITY_ATTRIBUTESlpProcessAttributes,_In_opt_LPSECURITY_ATTRIBUTESlpThreadAttributes,_In_BOOLbInheritHandles,_In_DWORDdwCreationFl

c++ - "except that a default constructed array is not empty"是什么意思?

在N3337中,我正在阅读§23.3.2.1/3,它指出:Anarraysatisfiesalloftherequirementsofacontainerandofareversiblecontainer(23.2),exceptthatadefaultconstructedarrayobjectisnotemptyandthatswapdoesnothaveconstantcomplexity.在§23.2.1,表96容器要求中,它显示了一个默认构造的对象Xu;,其中后置条件是u.empty()。据推测,以下内容:std::arraya;应该导致a.empty()输出1,它确实如此。

c++ - 类 std::array of objects without default constructors

所以让我们假设我有以下类(class)classNoDefaultConstructor{NoDefaultConstructor()=delete;...};我还有另一个类,它有一个类型为NoDefaultConstructor和其他成员的数组classWrapper{std::arrayarr;...};如何在Wrapper的构造函数中初始化数组(可能在使用std::intializer_list的初始化列表中)?更具体地说,是我可以将参数传递给Wrapper的初始化列表中的数组构造函数以具有类似于以下的构造的唯一方法吗?我正在考虑这样做,因为将来数组的大小可能会发生变化。temp

c++ - 错误 C4430 缺少类型说明符 - 假定为 int。注意 : C++ does not support default-intGenerator

我对以下代码有疑问:生成器.h:#pragmaonceclassGenerator{public:friendclassBagObject;Generator(void);~Generator(void);...voidgenerator(int);private:BagObject*object;vectordata;//Errorc4430};这是一个错误:errorC4430:missingtypespecifier-intassumed.Note:C++doesnotsupportdefault-int还有6个错误,但我相信在解决这个问题后它们应该会消失。这是cpp文件。第一次