llvm::make_unique 的目的是什么?

What is the purpose of llvm::make_unique?

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

TL;DR;

LLVM 是使用符合 C++11 的代码编写的,而 std::make_unique 是 C++14 的特性。因此,如果他们想要 make_unique,他们就需要实施它。

详情

如果我们去 LLVM Coding Standards the 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 那么他们就不能使用标准版本。

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