草庐IT

make_XYZ

全部标签

c++ - Qt 需要 C++11 支持"make error

我尝试按照README.md中的说明从源代码编译最新的平铺。我的工作环境:平铺源代码:tiled-0.16.1Mac操作系统:10.11.1Xcode:7.1Q制作:3.0Qt:5.7.0苹果LLVM:7.0.0但是make失败并出现以下错误:Infileincludedfrompythonplugin.cpp:21:Infileincludedfrom./pythonplugin.h:30:Infileincludedfrom../../libtiled/logginginterface.h:33:Infileincludedfrom../../libtiled/tiled_glob

c++ - std::make_unique(以及 emplace、emplace_back)对 initializer_list 参数的笨拙推导

假设我有这个结构:structposition{intx,y;};和另一个将this作为构造函数参数的类:classpositioned{public:positioned(positionp):pos(p){}private:positionpos;};我怎样才能得到简单的autobla=std::make_unique({1,2});上类?目前,编译器试图通过initializer_list匹配并调用make_unique的数组变体,这很愚蠢,因为positioned只有一个构造函数。emplace出现同样的问题和emplace_back功能。几乎所有将其可变模板参数转发给类的构造

c++ - 使用 make_shared 和 make_unique 时需要检查 nullptr 吗?

如果我使用make_shared或make_unique创建指针,我是否必须检查它是否为nullptr,例如:std::unique_ptrp=std::make_unique();if(p==nullptr){........}如果您真的内存不足,std::make_unique将通过预期。所以你永远不会从std::make_unique得到空指针。这是正确的吗?所以在执行make_shared和make_unique时不需要检查nullptr吗? 最佳答案 来自std::make_unique上的cppreference(类似于

c++ - 更改时 Make 不会重建 header

我有一个项目,我定期修改header,当我这样做时,忘记了makeclean然后make,我得到了各种奇怪的行为。我目前正在使用QtCreator作为我的IDE,但我已经在独立于Qt的项目中看到过这种情况。我的项目变得相当大,每次更改header时都必须重建,这变得效率低下。有什么想法吗?供将来引用:如果使用QMake系统:DEPENDPATH+=.\HeaderLocation1/\HeaderLocation2/\HeaderLocation2/HeaderSubLocation1/\HeaderLocation2/HeaderSubLocation2/\HeaderLocatio

c++ - 使用 MinGW 时 NetBeans Make 命令

我正在尝试使用NetBean来编写C++程序,我已经遵循了每个在这里找到的命令:https://netbeans.org/community/releases/68/cpp-setup-instructions.html#compilers_windows但是,我在使用netbeans中的make命令选项时遇到了问题。我已经将基本目录设置为M:\c++\bin,我在其中安装了MinGW,并将make命令设置为M:\MinSYS\bin\make.exe,但是在尝试构建一个简单程序时,netbeans会生成以下错误:"/M/c++/MinSYS/bin/make.exe"-fnbproj

c++ - 是否可以强制 `std::make_shared` 使用类的新运算符?

是否可以强制std::make_shared使用类的new运算符?这涉及另一个SOquestion.根据那个问题,std::make_shared使用自定义分配器:Fromthestandard(§20.7.2.2.6shared_ptrcreation):Effects:AllocatesmemorysuitableforanobjectoftypeTandconstructsanobjectinthatmemoryviatheplacementnewexpression::new(pv)T(std::forward(args)...).因此,我认为我可以使用自定义放置新运算符,但这

c++ - Qt 造物主 : “XYZ does not name a type”

这是QtCreator中非常令人沮丧的错误消息:'XYZ'doesnotnameatype。这通常意味着XYZ类中存在阻止编译器生成该类型的错误,但没有关于出错原因的其他提示。有什么建议吗? 最佳答案 我刚遇到这个问题,正如Arckaroph所说:问题是,当我们在源代码文件中包含一个头文件,并在其中使用指令#ifndef时,我们不能将它再次包含在头文件中,以将其包含类的类型赋予源代码中的变量代码文件例子:class1.h包含Class1class2.h包含Class2class2有一个class1类型的私有(private)变量V如

c++ - 带有大括号初始化的 make_unique

https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique写道std::make_unique可以实现为templatestd::unique_ptrmake_unique(Args&&...args){returnstd::unique_ptr(newT(std::forward(args)...));}这不适用于没有构造函数的普通结构。这些可以用大括号初始化,但没有非默认构造函数。示例:#includestructpoint{intx,z;};intmain(){std::make_unique(1,2);}Com

c++ - 为什么 make_unique 不能与 unique_ptr::reset 一起使用?

我尝试用VS2013编译一些C++代码,unique_ptr::reset()似乎不适用于make_unique();一个小的可编译重现代码片段如下:#includeusingnamespacestd;intmain(){unique_ptrp=make_unique(3);p.reset(make_unique(10));}从命令行编译:C:\Temp\CppTests>cl/EHsc/W4/nologotest.cpp这些是来自MSVC编译器的错误:test.cpp(6):errorC2280:'voidstd::unique_ptr>::reset>>(_Ptr2)':attem

c++ - 为什么 allocate_shared 和 make_shared 这么慢

我刚刚编写了一个测试程序来找到分配和释放许多由shared_ptr管理的对象的最快方法。我尝试了shared_ptr和new,shared_ptr和pool,make_shared,allocate_shared。让我惊讶的是allocate_shared比shared_ptr和pool慢。我使用发布版本测试vs2017+win10中的代码。发布build设置为默认(/O2)。我还在gcc4.8.5+centos6.2中使用g++-std=c++11-O3对其进行了测试。代码是:#include#include#include#include#include#includeusingn