gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 23:20:53 26 4
gpt4 key购买 nike

在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com