libc++ 相关问题

libc ++是一个开放的C ++标准库实现,是LLVM.org的子项目。它专为C ++ 11设计。

为什么 libc++ 的 std::string 实现比 libstdc++ 占用 3 倍内存?

考虑以下测试程序: #包括 #包括 #包括 int main() { std::cout << sizeof(std::string("hi")) << " "; std::

回答 4 投票 0

lunch 和 m 命令因 AOSP 中未定义的符号而失败

我正在尝试在 AOSP 中运行午餐和 m 命令。详细来说,命令是 . ./build/envsetup.sh ,午餐 aosp_cf_x86_64_phone-trunk_staging-userdebug 和 m smp-fuzzer。然而,午餐命令

回答 1 投票 0

标准库实现中双下划线的原因

标准库(C 或 C++)实现是否有任何技术原因,IMO 滥用,强调它们的做法(=用两个下划线作为所有内容的前缀+添加一个尾部下划线来表示...

回答 1 投票 0

无法使用 conan-center 配方中的 libc++ 从源代码构建 QT。 (qglobal.h:45:12:致命错误:找不到“type_traits”文件)

我正在尝试使用该配置文件从 conan-center 构建 qt/5.15.2@ 包: [设置] build_type=调试 拱门=x86_64 arch_build=x86_64 操作系统=Linux os_build=Linux 编译器=clang 编译器版本=9 比较...

回答 1 投票 0

conda 中的 c++ 中的uncaught_exceptions 不可用?

我在 conda 环境中使用 Rstudio 安装 recount 包,在安装 tzdb 依赖项时,出现以下错误: * 安装 *source* 包 ‘tzdb’ ... ** 包‘tzdb’

回答 1 投票 0

clang++ -stdlib=libc++ 导致未定义的引用

为什么在使用 clang 和 libc++ 时出现以下链接器错误: $ clang++ -stdlib=libc++ po.cxx -lpoppler /tmp/po-QqlXGY.o:在函数“main”中: po.cxx:(.text+0x33): 未定义的引用...

回答 3 投票 0

当 `-stdlib=libc++` 时,Clang 找不到标头

我的 Clang 安装在使用 -stdlib=libstdc++ 时按预期工作,这是默认值: $ clang++ -v -stdlib=libc++ helloworld.cpp Ubuntu clang 版本 14.0.0-1ubuntu1.1 目标:x86_64-pc-linux...

回答 1 投票 0

为什么 std::println(std::vector) 编译失败?

我有以下代码: #包括 #包括 int main() { std::vector v{1, 2, 3}; std::println("{}", v); } 在众多错误中,这个

回答 1 投票 0

用clang16.0.2编译tensorflow 2.14,无法链接标准C++库

我正在尝试基于docker和ubuntu 22.04使用clang 16.0.2(来自官方仓库)构建最简单的tensorflow 2.14(仅CPU)。 我已经成功构建了tensorflow r2.12和r2.13但是n...

回答 1 投票 0

什么是libc++和libstdc++

我有几个问题。 1)什么是 libc++ 和 libstdc++ ? 2)它们之间有什么区别? 3)它们可以互换吗? 4)这是编译器应该实现的东西吗? 5) 当...

回答 2 投票 0

这是 std::quote bug 的行为吗?

我想用自定义类型做与 std::quote 相同的事情,但我想错过使用这种具有临时右值的 API。经过一番使用 std::quoted 后,我发现了以下内容......

回答 2 投票 0

标准中提到了std::copy_n源增量计数吗?

我实现了一个迭代器的示例,它计算每个增量: #包括 #包括 #包括 #包括 模板 我实现了一个迭代器的示例,它计算每个增量: #include <vector> #include <iostream> #include <algorithm> #include <iterator> template <class IteratorCategory = std::vector<int>::iterator::iterator_category> class DereferenceCountingIterator : public std::vector<int>::iterator { public: using iterator_category = IteratorCategory; public: static std::size_t increaseCnt; DereferenceCountingIterator( typename std::vector<int>::iterator iter) : std::vector<int>::iterator(iter) {} auto& operator++() { ++increaseCnt; return std::vector<int>::iterator::operator++(); } DereferenceCountingIterator<IteratorCategory> operator+(difference_type diff) { return static_cast<std::vector<int>::iterator&>(*this).operator+(diff); } }; 此模板类既可以用作 RandomAccess 也可以用作输入迭代器: template<class IteratorCategory> std::size_t DereferenceCountingIterator<IteratorCategory>::increaseCnt = 0; using RandomAccessDereferenceContingIterator = DereferenceCountingIterator<>; using NonRandomAccessDereferenceContingIterator = DereferenceCountingIterator<std::input_iterator_tag>; 应用程序示例: int main() { auto vec = std::vector<int>{3, 4, 5}; auto rAVecBegin = RandomAccessDereferenceContingIterator(vec.begin()); auto nonRAVecBegin = NonRandomAccessDereferenceContingIterator(vec.begin()); { const auto incBefore = RandomAccessDereferenceContingIterator::increaseCnt; auto out = std::vector<int>{}; std::copy_n(rAVecBegin, 3, std::back_inserter(out)); const auto incAfter = RandomAccessDereferenceContingIterator::increaseCnt; std::cout << incAfter - incBefore << std::endl; } { const auto incBefore = NonRandomAccessDereferenceContingIterator::increaseCnt; auto out = std::vector<int>{}; std::copy_n(nonRAVecBegin, 3, std::back_inserter(out)); const auto incAfter = NonRandomAccessDereferenceContingIterator::increaseCnt; std::cout << incAfter - incBefore << std::endl; } return 0; } 该程序的输出如下(在 libstdc++ 和 libc++ 中): 3 2 我能否确定 copy_n 在源迭代器不是 RandomAccessIterator 时准确地执行 n-1 增量,如果是的话 n 增量? 如果不是 RandomAccessIterator,我能否确定 copy_n 在源迭代器上精确执行 n-1 增量,如果是,则执行 n 增量? 不,对增量数量没有要求。 如果迭代器只是输入迭代器,而不是前向迭代器,则强制实现精确执行 n 或 n-1 递增到最后一个解引用的迭代器或之后未解引用但必须有效的迭代器。输入迭代器无法以任何其他方式迭代源序列。 如果迭代器是前向迭代器甚至随机访问迭代器,则对数字增量没有要求,并且实现也可以递减或使步长大于增量/减量。 也不要求按顺序复制序列。 唯一的复杂性要求是准确地进行 n 分配。

回答 1 投票 0

C++ random_shuffle 总是给出相同的结果

以下对随机洗牌的调用始终为向量 v 提供相同的结果 #包括 #包括 #包括 #包括 使用

回答 3 投票 0

cmake 检测哪个库 libc++ 或 libstdc++ 配置为用于 g++ 或 clang++

我编写了一个 CMakeLists.txt 来使用 g++ 或 clang++ 构建项目。 为了捕获尽可能多的错误,我使用 libc++ 和 -D_LIBCPP_DEBUG2=2 (对于 clang++)和 libstdc++ 和 -D_GLIBCXX_DEB...

回答 2 投票 0

从 g++/stdlib++ 和 clang++/libc++ 之间的流读取双精度数的差异

最小的“失败”示例: #包括 #包括 #包括 #包括 int main(int argv, char** argc) { std::string line = &quo...

回答 1 投票 0

为什么将字符串初始化为 "" 比默认构造函数更有效?

通常,默认构造函数应该是创建空容器的最快方法。 这就是为什么我惊讶地发现它比初始化为空字符串文字更糟糕: #包括<

回答 1 投票 0

使用 libc++ 和 gcc 构建:-Wmaybe-uninitalized

我正在使用 gcc 和 libc++ (llvm) 运行构建。自从更新到 Debian Bookworm 以来,我得到: /usr/lib/llvm-14/include/c++/v1/regex:1384:8:警告:'.std::__1::__state::__at_f...

回答 1 投票 0

Debian 书虫:同时使用 libunwind8 和 libunwind-14?

我将我的容器从 debian bullseye 更新为 bookworm。 我使用了 libunwind8 (和 libunwind-dev)和 libc++-dev 自 bookworm 以来,libc++-dev 依赖于 libunwind-14-dev (可能是因为它现在可以...

回答 1 投票 0

CUDA和libc++abi.dylib中对象的共享内存错误

我有以下问题(请记住,我对使用 CUDA 编程还很陌生)。 我有一个名为 vec3f 的类,它类似于 float3 数据类型,但具有重载运算符和其他

回答 1 投票 0

为什么 libc++ call_once 对所有调用使用共享互斥体?

我正在阅读 libc++ 中 call_once 的源代码,并对共享互斥锁的用法感到好奇。这是 mutex.cpp 中的实现。这不是意味着 call_once(f1) 和 call_once(f2) comp ...

回答 0 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.