c++ - llvm::make_unique 的目的是什么?

标签 c++ llvm

在 llvm 的编译器实现教程(例如 here )中使用了 llvm::make_unique。他们不使用 std::make_unique 的原因是什么?我找不到任何明确的文档。

最佳答案

TL;DR;

LLVM 是使用符合 C++11 的代码编写的,而 std::make_unique是一个 C++14 特性。所以如果他们想要 make_unique 他们需要实现它。

详情

如果我们转到 LLVM Coding Standards C++ Standard Versions section说:

LLVM, Clang, and LLD are currently written using C++11 conforming code, although we restrict ourselves to features which are available in the major toolchains supported as host compilers. The LLDB project is even more aggressive in the set of host compilers supported and thus uses still more features. Regardless of the supported features, code is expected to (when reasonable) be standard, portable, and modern C++11 code. We avoid unnecessary vendor-specific extensions, etc.

我们可以从 cppreference 看到std::make_unique 是一个 C++14 特性。如果他们想使用 make_unique 那么他们就不能使用 std 版本。

我们可以从最近的 llvm-dev discussion 中看到迁移到 C++14 仍然是一个开放的主题。

关于c++ - llvm::make_unique 的目的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35900866/

相关文章:

javascript - 如何将 LLVM IR br 转换回 while 循环

llvm - centos 上最新的 clang 格式

c++ - 在 llvm/clang 中不按设计使用 C++ 异常

architecture - NVPTX 通用内存空间在架构中的位置

c++ - C++ 类中的线程

c++ - std::ofstream 打开的 klocwork 问题

c++ - 一些基于二叉树的操作

gcc - LLVM 与 InitializeNativeTarget 的问题

c++ - PPL - 如何配置 native 线程数?

c++ - _mm256_extractf32x4_ps 和 _mm256_extractf128_ps 之间的区别