llvm.org GIT mirror llvm / dc1406d
[ADT] Remove llvm::make_unique utility. All uses of llvm::make_unique should have been replaced with std::make_unique. This patch represents the last part of the migration and removes the utility from LLVM. Differential revision: https://reviews.llvm.org/D66259 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369130 91177308-0d34-0410-b5e6-96231b3b80d8 Jonas Devlieghere a month ago
2 changed file(s) with 1 addition(s) and 36 deletion(s). Raw diff Collapse all Expand all
13751375 // Extra additions to
13761376 //===----------------------------------------------------------------------===//
13771377
1378 // Implement make_unique according to N3656.
1379
1380 /// Constructs a `new T()` with the given args and returns a
1381 /// `unique_ptr` which owns the object.
1382 ///
1383 /// Example:
1384 ///
1385 /// auto p = make_unique();
1386 /// auto p = make_unique>(0, 1);
1387 template
1388 typename std::enable_if::value, std::unique_ptr>::type
1389 make_unique(Args &&... args) {
1390 return std::unique_ptr(new T(std::forward(args)...));
1391 }
1392
1393 /// Constructs a `new T[n]` with the given args and returns a
1394 /// `unique_ptr` which owns the object.
1395 ///
1396 /// \param n size of the new array.
1397 ///
1398 /// Example:
1399 ///
1400 /// auto p = make_unique(2); // value-initializes the array with 0's.
1401 template
1402 typename std::enable_if::value && std::extent::value == 0,
1403 std::unique_ptr>::type
1404 make_unique(size_t n) {
1405 return std::unique_ptr(new typename std::remove_extent::type[n]());
1406 }
1407
1408 /// This function isn't used and is only here to provide better compile errors.
1409 template
1410 typename std::enable_if::value != 0>::type
1411 make_unique(Args &&...) = delete;
1412
14131378 struct FreeDeleter {
14141379 void operator()(void* v) {
14151380 ::free(v);
208208
209209 TEST(FilterIteratorTest, Composition) {
210210 auto IsOdd = [](int N) { return N % 2 == 1; };
211 std::unique_ptr A[] = {make_unique(0), std::make_unique(1),
211 std::unique_ptr A[] = {std::make_unique(0), std::make_unique(1),
212212 std::make_unique(2), std::make_unique(3),
213213 std::make_unique(4), std::make_unique(5),
214214 std::make_unique(6)};