File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -261,7 +261,10 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
261261 }
262262
263263 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t <_Tp> operator *() const
264- _NOEXCEPT_ (_NOEXCEPT_(*std::declval<pointer>())) {
264+ _NOEXCEPT_ (_NOEXCEPT_(*std::declval<pointer>()))
265+ // TODO: use reference_converts_from_temporary_v once implemented.
266+ requires (!__reference_converts_from_temporary(__add_lvalue_reference_t <_Tp>, decltype (*declval<pointer>())))
267+ {
265268 return *__ptr_;
266269 }
267270 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator ->() const _NOEXCEPT { return __ptr_; }
Original file line number Diff line number Diff line change 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-exception
6+ //
7+ // ===----------------------------------------------------------------------===//
8+
9+ // <memory>
10+
11+ #include < iostream>
12+ #include < memory>
13+
14+ using namespace std ;
15+
16+ struct deleter {
17+ using pointer = long *;
18+ void operator ()(pointer) const {}
19+ };
20+
21+ int main (int argc, char const *argv[]) {
22+ long l = 0 ;
23+ std::unique_ptr<const int , deleter> p (&l);
24+ // Error: indirection requires pointer operand ('std::unique_ptr<const int, deleter>' invalid)
25+ int i = *p;
26+ cout << i << endl;
27+ return 0 ;
28+ }
You can’t perform that action at this time.
0 commit comments