brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · c6fef01 Raw
46 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++1410 11// <memory>12 13// unique_ptr14 15// The following constructors should not be selected by class template argument16// deduction:17//18// constexpr explicit unique_ptr(pointer p) // constexpr since C++2319// constexpr unique_ptr(pointer p, const D& d) noexcept // constexpr since C++2320// constexpr unique_ptr(pointer p, remove_reference_t<D>&& d) noexcept // constexpr since C++2321 22#include <memory>23 24#include "deduction_guides_sfinae_checks.h"25 26struct Deleter {27  void operator()(int* p) const { delete p; }28};29 30int main(int, char**) {31  // Cannot deduce from (ptr).32  static_assert(SFINAEs_away<std::unique_ptr, int*>);33  // Cannot deduce from (array).34  static_assert(SFINAEs_away<std::unique_ptr, int[]>);35  // Cannot deduce from (ptr, Deleter&&).36  static_assert(SFINAEs_away<std::unique_ptr, int*, Deleter&&>);37  // Cannot deduce from (array, Deleter&&).38  static_assert(SFINAEs_away<std::unique_ptr, int[], Deleter&&>);39  // Cannot deduce from (ptr, const Deleter&).40  static_assert(SFINAEs_away<std::unique_ptr, int*, const Deleter&>);41  // Cannot deduce from (array, const Deleter&).42  static_assert(SFINAEs_away<std::unique_ptr, int[], const Deleter&>);43 44  return 0;45}46