草庐IT

使用 clang/llvm 的 C++ 精确垃圾收集器?

好的,所以我想用C++编写一个精确的“标记和清除”垃圾收集器。我希望做出一些可以帮助我的决定,因为我的所有指针都将包装在“RelocObject”中,并且我将有一个内存块用于堆。这看起来像这样://Thisclassactsasanindirectiontotheactualobjectinmemorysothatitcanbe//relocatedinthesweepphaseofgarbagecollectorclassMemBlock{public:void*Get(void){returnm_ptr;}private:MemBlock(void):m_ptr(NULL){}vo

c++ - Clang++ 不理解 mac 终端中的 c++11

我正在尝试获取一些c++代码(使用c++11)在mac终端中编译。我试过了clang++-std=c++11main.cpp但是我得到了错误error:invalidvalue'c++11'in'-std=c++11'我的xcode完全是最新的,我假设我在终端做错了什么?代码在xcode本身运行良好,我只是无法让它在终端中运行。任何提示都会很棒! 最佳答案 正如Andy已经说过的,您的编译器只接受-std=c++0x。它可能很旧。[仅回答以将问题从未回答的问题队列中删除] 关于c++-C

c++ - GCC 声明友元函数重载,调用不明确,clang 编译

templateclassrp{};templateclassP>structb{templateclassFriendP>friendvoidf(bfrom);};templateclassP>voidf(bfrom){}intmain(){bv;f(v);return0;}Clang3.3(svn)编译良好,而GCC4.8拒绝它:main.cpp:Infunction'intmain()':main.cpp:17:10:error:callofoverloaded'f(b&)'isambiguousf(v);^main.cpp:17:10:note:candidatesare:ma

c++ - Gcc 失败并显示 "call of overload is ambignuous"而 clang 没有

我有以下代码:#includestructb_symbol{templateexplicitb_symbol(T&&symbol):symbol(std::forward(symbol)){}std::experimental::string_viewsymbol;};structb_utf8{templateexplicitb_utf8(T&&value):value(std::forward(value)){}std::experimental::string_viewvalue;};structvalue{explicitvalue(b_utf8){}explicitvalue(

c++ - 与 static_assert 和 boost::hana 相关的 Clang 编译错误

考虑以下使用-std=c++14在Clang3.8上成功编译的问题。#includenamespacehana=boost::hana;intmain(){constexprautoindices=hana::range();hana::for_each(indices,[&](autoi){hana::for_each(indices,[&](autoj){constexprbooltest=(i==(j==i?j:i));static_assert(test,"error");});});}这个测试非常荒谬,但这不是重点。现在考虑一个替代版本,其中测试直接放在static_asse

c++ - CMake、VTK8 和 Embarcaderos Clang 编译器

C++Builder(10.2.3)的当前Embarcadero版本附带Clang32和64位C/C++编译器。Clang版本号称是3.3,(http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Win32_Clang-enhanced_Compilers)。我正在研究使用这些编译器和CMake编译VTK8.0和其他库。但是,CMake附带的“系统”CMake文件(Windows-Embarcadero.cmake)并未针对Clang配置,而是针对较旧的bcc32编译器配置。Embarcadero建议将其分发的“Windows-Embarc

c++ - 关于静态全局 lambda 变量的错误 clang-tidy 警告?

提供以下代码,在全局范围内,clang-tidy不给出警告:autotest=[]{};但是,当执行以下操作时,它会:#includeautotest=[]{std::tuplet{1,2,3};};:3:6:warning:initializationof'test'withstaticstoragedurationmaythrowanexceptionthatcannotbecaught[cert-err58-cpp]autotest=[]{^/opt/compiler-explorer/gcc-8.2.0/lib/gcc/x86_64-linux-gnu/8.2.0/../../

c++ - 为什么我使用 XCode 的 llvm 与来自 MacPorts 的 clang++ 获得更快的二进制文件?

我已经编写了一个基准测试方法来测试我的C++程序(搜索游戏树),并且我注意到使用XCode4.0.2中的“LLVM编译器2.0”选项进行编译可以使我的二进制文件速度明显快于我使用来自MacPorts的最新版本的clang++进行编译。如果我理解正确的话,我在这两种情况下都使用了clang前端和llvm后端。Apple是否改进了他们的clang/llvm发行版以生成更快的MacOS二进制文件?我找不到有关该项目的太多信息。以下是我的程序为各种编译器生成的基准,全部使用-O3优化(越高越好):(Xcode)"gcc4.2":38.7(Xcode)"llvmgcc4.2":51.2(Xcod

c++ - clang 3.3/Xcode & libc++:std::getline 在调用 ifstream::clear() 后不读取数据

以下程序演示了libc++和libstdc++(使用clang3.3)之间std::getline行为的不一致。程序打开文件testfile,读取它直到eof,然后使用ifstream::clear清除错误位并尝试再次从同一文件句柄读取以查看是否有新数据附加到文件。#include#include#includeusingnamespacestd;intmain(){ifstream*file=newifstream("testfile");if(!file->is_open()){coutclear();//removeendoffileevilbitsstringline;//wo

c++ - Clang 在模板上下文中找不到函数定义后实例化的函数

我一直在尝试使用SeanParent的“C++Seasoning”演示文稿派生的代码,并将我的问题归结为以下代码:#includestructcontainer{structconcept{virtual~concept(){}virtualvoidfoo_()=0;};templatestructmodel:concept{model(Tx):data_(x){}voidfoo_(){foo(data_);//Line13}Tdata_;};templatecontainer(Tx):self_(newmodel(x)){}//Line20std::unique_ptrself_;f