What is the purpose of llvm::make_unique?

Viewed 2919

In llvm's compiler implementation tutorial (e.g. here) llvm::make_unique is used. What is the reason they aren't using std::make_unique? I wasn't able to find any clear documentation on this.

1 Answers

TL;DR;

LLVM is written using C++11 conforming code while std::make_unique is a C++14 feature. So if they want make_unique they need to implement it.

Details

If we go to the LLVM Coding Standards the C++ Standard Versions section says:

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.

We can see from cppreference that std::make_unique is a C++14 feature. If they want to use make_unique then they can't use the std version.

We can see from a recent llvm-dev discussion that moving to C++14 is still an open subject.

Related