File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed
test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 15
15
#include < __type_traits/datasizeof.h>
16
16
#include < __type_traits/is_empty.h>
17
17
#include < __type_traits/is_final.h>
18
- #include < __type_traits/is_reference.h>
19
18
20
19
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21
20
# pragma GCC system_header
@@ -63,9 +62,17 @@ inline const size_t __compressed_pair_alignment = _LIBCPP_ALIGNOF(_Tp);
63
62
template <class _Tp >
64
63
inline const size_t __compressed_pair_alignment<_Tp&> = _LIBCPP_ALIGNOF(void *);
65
64
66
- template <class _ToPad ,
67
- bool _Empty = ((is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) ||
68
- is_reference<_ToPad>::value || sizeof (_ToPad) == __datasizeof_v<_ToPad>)>
65
+ template <class _ToPad >
66
+ inline const bool __is_reference_or_unpadded_object =
67
+ (is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) || sizeof (_ToPad) == __datasizeof_v<_ToPad>;
68
+
69
+ template <class _Tp >
70
+ inline const bool __is_reference_or_unpadded_object<_Tp&> = true ;
71
+
72
+ template <class _Tp >
73
+ inline const bool __is_reference_or_unpadded_object<_Tp&&> = true ;
74
+
75
+ template <class _ToPad , bool _Empty = __is_reference_or_unpadded_object<_ToPad> >
69
76
class __compressed_pair_padding {
70
77
char __padding_[sizeof (_ToPad) - __datasizeof_v<_ToPad>] = {};
71
78
};
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ bool my_free_called = false;
32
32
33
33
void my_free (void *) { my_free_called = true ; }
34
34
35
+ TEST_CONSTEXPR_CXX23 void deleter_function (A*) {}
36
+
35
37
#if TEST_STD_VER >= 11
36
38
struct DeleterBase {
37
39
TEST_CONSTEXPR_CXX23 void operator ()(void *) const {}
@@ -325,20 +327,37 @@ TEST_CONSTEXPR_CXX23 void test_nullptr() {
325
327
#endif
326
328
}
327
329
330
+ template <bool IsArray>
331
+ TEST_CONSTEXPR_CXX23 void test_function_reference () {
332
+ typedef typename std::conditional<!IsArray, A, A[]>::type VT;
333
+ {
334
+ std::unique_ptr<VT, void (&)(A*)> u (nullptr , deleter_function);
335
+ assert (u.get () == nullptr );
336
+ assert (u.get_deleter () == deleter_function);
337
+ }
338
+ {
339
+ std::unique_ptr<VT, void (&)(A*)> u (nullptr , deleter_function);
340
+ assert (u.get () == nullptr );
341
+ assert (u.get_deleter () == deleter_function);
342
+ }
343
+ }
344
+
328
345
TEST_CONSTEXPR_CXX23 bool test () {
329
346
{
330
347
test_basic</* IsArray*/ false >();
331
348
test_nullptr<false >();
332
349
test_basic_single ();
333
350
test_sfinae<false >();
334
351
test_noexcept<false >();
352
+ test_function_reference<false >();
335
353
}
336
354
{
337
355
test_basic</* IsArray*/ true >();
338
356
test_nullptr<true >();
339
357
test_sfinae<true >();
340
358
test_sfinae_runtime ();
341
359
test_noexcept<true >();
360
+ test_function_reference<true >();
342
361
}
343
362
344
363
return true ;
You can’t perform that action at this time.
0 commit comments