[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jun 6 12:39:19 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 5367b2c862a7bfe138ee17994edfdb7938437064 7a203002b19f5a2827607e73a998dcd1ace9d135 -- libcxx/include/__functional/move_only_function.h libcxx/include/__functional/move_only_function_common.h libcxx/include/__functional/move_only_function_impl.h libcxx/include/__utility/pointer_int_pair.h libcxx/test/libcxx/private_headers.verify.cpp libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.move/assert.engaged.cpp libcxx/test/libcxx/utilities/pointer_int_pair.pass.cpp libcxx/test/libcxx/utilities/pointer_int_pair/assert.constructor.pass.cpp libcxx/test/libcxx/utilities/pointer_int_pair/constinit.verify.cpp libcxx/test/libcxx/utilities/pointer_int_pair/pointer_int_pair.pass.cpp libcxx/test/libcxx/utilities/pointer_int_pair/static_asserts.verify.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/assignment/functor.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/assignment/move.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/assignment/move_other.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/assignment/nullptr.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_const.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_const_noexcept.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_noexcept.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/normal.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/normal_const.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/normal_const_noexcept.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/normal_noexcept.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_const.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_const_noexcept.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_noexcept.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/common.h libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/default.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/functor.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/in_place.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/in_place_init_list.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/move.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/move_other.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/ctors/nullptr.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/swap.adl.pass.cpp libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/swap.member.pass.cpp libcxx/include/__configuration/abi.h libcxx/include/__std_clang_module libcxx/include/functional libcxx/include/version libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp libcxx/test/support/type_algorithms.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/test/libcxx/private_headers.verify.cpp b/libcxx/test/libcxx/private_headers.verify.cpp
index fc76655325..8debceecd2 100644
--- a/libcxx/test/libcxx/private_headers.verify.cpp
+++ b/libcxx/test/libcxx/private_headers.verify.cpp
@@ -226,11 +226,11 @@ END-SCRIPT
#include <__algorithm/unwrap_iter.h> // expected-error@*:* {{use of private header from outside its module: '__algorithm/unwrap_iter.h'}}
#include <__algorithm/unwrap_range.h> // expected-error@*:* {{use of private header from outside its module: '__algorithm/unwrap_range.h'}}
#include <__algorithm/upper_bound.h> // expected-error@*:* {{use of private header from outside its module: '__algorithm/upper_bound.h'}}
-#include <__availability> // expected-error@*:* {{use of private header from outside its module: '__availability'}}
+#include <__availability> // expected-error@*:* {{use of private header from outside its module: '__availability'}}
#include <__bit/bit_cast.h> // expected-error@*:* {{use of private header from outside its module: '__bit/bit_cast.h'}}
#include <__bit/byteswap.h> // expected-error@*:* {{use of private header from outside its module: '__bit/byteswap.h'}}
-#include <__bit_reference> // expected-error@*:* {{use of private header from outside its module: '__bit_reference'}}
-#include <__bits> // expected-error@*:* {{use of private header from outside its module: '__bits'}}
+#include <__bit_reference> // expected-error@*:* {{use of private header from outside its module: '__bit_reference'}}
+#include <__bits> // expected-error@*:* {{use of private header from outside its module: '__bits'}}
#include <__charconv/chars_format.h> // expected-error@*:* {{use of private header from outside its module: '__charconv/chars_format.h'}}
#include <__charconv/from_chars_result.h> // expected-error@*:* {{use of private header from outside its module: '__charconv/from_chars_result.h'}}
#include <__charconv/tables.h> // expected-error@*:* {{use of private header from outside its module: '__charconv/tables.h'}}
@@ -239,7 +239,7 @@ END-SCRIPT
#include <__chrono/calendar.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/calendar.h'}}
#include <__chrono/convert_to_timespec.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/convert_to_timespec.h'}}
#include <__chrono/convert_to_tm.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/convert_to_tm.h'}}
-#include <__chrono/day.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/day.h'}}
+#include <__chrono/day.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/day.h'}}
#include <__chrono/duration.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/duration.h'}}
#include <__chrono/file_clock.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/file_clock.h'}}
#include <__chrono/formatter.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/formatter.h'}}
@@ -256,7 +256,7 @@ END-SCRIPT
#include <__chrono/system_clock.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/system_clock.h'}}
#include <__chrono/time_point.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/time_point.h'}}
#include <__chrono/weekday.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/weekday.h'}}
-#include <__chrono/year.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/year.h'}}
+#include <__chrono/year.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/year.h'}}
#include <__chrono/year_month.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/year_month.h'}}
#include <__chrono/year_month_day.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/year_month_day.h'}}
#include <__chrono/year_month_weekday.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/year_month_weekday.h'}}
@@ -380,15 +380,15 @@ END-SCRIPT
#include <__functional/unwrap_ref.h> // expected-error@*:* {{use of private header from outside its module: '__functional/unwrap_ref.h'}}
#include <__functional/weak_result_type.h> // expected-error@*:* {{use of private header from outside its module: '__functional/weak_result_type.h'}}
#include <__fwd/array.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/array.h'}}
-#include <__fwd/get.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/get.h'}}
-#include <__fwd/hash.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/hash.h'}}
+#include <__fwd/get.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/get.h'}}
+#include <__fwd/hash.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/hash.h'}}
#include <__fwd/memory_resource.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/memory_resource.h'}}
-#include <__fwd/pair.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/pair.h'}}
-#include <__fwd/span.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/span.h'}}
-#include <__fwd/string.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/string.h'}}
+#include <__fwd/pair.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/pair.h'}}
+#include <__fwd/span.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/span.h'}}
+#include <__fwd/string.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/string.h'}}
#include <__fwd/string_view.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/string_view.h'}}
-#include <__fwd/tuple.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/tuple.h'}}
-#include <__ios/fpos.h> // expected-error@*:* {{use of private header from outside its module: '__ios/fpos.h'}}
+#include <__fwd/tuple.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/tuple.h'}}
+#include <__ios/fpos.h> // expected-error@*:* {{use of private header from outside its module: '__ios/fpos.h'}}
#include <__iterator/access.h> // expected-error@*:* {{use of private header from outside its module: '__iterator/access.h'}}
#include <__iterator/advance.h> // expected-error@*:* {{use of private header from outside its module: '__iterator/advance.h'}}
#include <__iterator/back_insert_iterator.h> // expected-error@*:* {{use of private header from outside its module: '__iterator/back_insert_iterator.h'}}
@@ -427,8 +427,8 @@ END-SCRIPT
#include <__iterator/sortable.h> // expected-error@*:* {{use of private header from outside its module: '__iterator/sortable.h'}}
#include <__iterator/unreachable_sentinel.h> // expected-error@*:* {{use of private header from outside its module: '__iterator/unreachable_sentinel.h'}}
#include <__iterator/wrap_iter.h> // expected-error@*:* {{use of private header from outside its module: '__iterator/wrap_iter.h'}}
-#include <__locale> // expected-error@*:* {{use of private header from outside its module: '__locale'}}
-#include <__mbstate_t.h> // expected-error@*:* {{use of private header from outside its module: '__mbstate_t.h'}}
+#include <__locale> // expected-error@*:* {{use of private header from outside its module: '__locale'}}
+#include <__mbstate_t.h> // expected-error@*:* {{use of private header from outside its module: '__mbstate_t.h'}}
#include <__memory/addressof.h> // expected-error@*:* {{use of private header from outside its module: '__memory/addressof.h'}}
#include <__memory/align.h> // expected-error@*:* {{use of private header from outside its module: '__memory/align.h'}}
#include <__memory/allocate_at_least.h> // expected-error@*:* {{use of private header from outside its module: '__memory/allocate_at_least.h'}}
@@ -463,7 +463,7 @@ END-SCRIPT
#include <__memory_resource/pool_options.h> // expected-error@*:* {{use of private header from outside its module: '__memory_resource/pool_options.h'}}
#include <__memory_resource/synchronized_pool_resource.h> // expected-error@*:* {{use of private header from outside its module: '__memory_resource/synchronized_pool_resource.h'}}
#include <__memory_resource/unsynchronized_pool_resource.h> // expected-error@*:* {{use of private header from outside its module: '__memory_resource/unsynchronized_pool_resource.h'}}
-#include <__mutex_base> // expected-error@*:* {{use of private header from outside its module: '__mutex_base'}}
+#include <__mutex_base> // expected-error@*:* {{use of private header from outside its module: '__mutex_base'}}
#include <__node_handle> // expected-error@*:* {{use of private header from outside its module: '__node_handle'}}
#include <__numeric/accumulate.h> // expected-error@*:* {{use of private header from outside its module: '__numeric/accumulate.h'}}
#include <__numeric/adjacent_difference.h> // expected-error@*:* {{use of private header from outside its module: '__numeric/adjacent_difference.h'}}
@@ -516,7 +516,7 @@ END-SCRIPT
#include <__random/uniform_real_distribution.h> // expected-error@*:* {{use of private header from outside its module: '__random/uniform_real_distribution.h'}}
#include <__random/weibull_distribution.h> // expected-error@*:* {{use of private header from outside its module: '__random/weibull_distribution.h'}}
#include <__ranges/access.h> // expected-error@*:* {{use of private header from outside its module: '__ranges/access.h'}}
-#include <__ranges/all.h> // expected-error@*:* {{use of private header from outside its module: '__ranges/all.h'}}
+#include <__ranges/all.h> // expected-error@*:* {{use of private header from outside its module: '__ranges/all.h'}}
#include <__ranges/common_view.h> // expected-error@*:* {{use of private header from outside its module: '__ranges/common_view.h'}}
#include <__ranges/concepts.h> // expected-error@*:* {{use of private header from outside its module: '__ranges/concepts.h'}}
#include <__ranges/copyable_box.h> // expected-error@*:* {{use of private header from outside its module: '__ranges/copyable_box.h'}}
@@ -550,8 +550,8 @@ END-SCRIPT
#include <__ranges/view_interface.h> // expected-error@*:* {{use of private header from outside its module: '__ranges/view_interface.h'}}
#include <__ranges/views.h> // expected-error@*:* {{use of private header from outside its module: '__ranges/views.h'}}
#include <__ranges/zip_view.h> // expected-error@*:* {{use of private header from outside its module: '__ranges/zip_view.h'}}
-#include <__split_buffer> // expected-error@*:* {{use of private header from outside its module: '__split_buffer'}}
-#include <__std_stream> // expected-error@*:* {{use of private header from outside its module: '__std_stream'}}
+#include <__split_buffer> // expected-error@*:* {{use of private header from outside its module: '__split_buffer'}}
+#include <__std_stream> // expected-error@*:* {{use of private header from outside its module: '__std_stream'}}
#include <__string/char_traits.h> // expected-error@*:* {{use of private header from outside its module: '__string/char_traits.h'}}
#include <__string/extern_template_lists.h> // expected-error@*:* {{use of private header from outside its module: '__string/extern_template_lists.h'}}
#include <__thread/poll_with_backoff.h> // expected-error@*:* {{use of private header from outside its module: '__thread/poll_with_backoff.h'}}
diff --git a/libcxx/test/libcxx/utilities/pointer_int_pair/constinit.verify.cpp b/libcxx/test/libcxx/utilities/pointer_int_pair/constinit.verify.cpp
index e06a378bf1..bca46ab362 100644
--- a/libcxx/test/libcxx/utilities/pointer_int_pair/constinit.verify.cpp
+++ b/libcxx/test/libcxx/utilities/pointer_int_pair/constinit.verify.cpp
@@ -18,4 +18,5 @@ template <class Ptr, class UnderlyingType>
using single_bit_pair = std::__pointer_int_pair<Ptr, UnderlyingType, std::__integer_width{1}>;
constinit int ptr = 0;
-constinit single_bit_pair<int*, size_t> continitiable_pointer_int_pair_values{&ptr, 0}; // expected-error {{variable does not have a constant initializer}}
+constinit single_bit_pair<int*, size_t> continitiable_pointer_int_pair_values{
+ &ptr, 0}; // expected-error {{variable does not have a constant initializer}}
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/assignment/move_other.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/assignment/move_other.pass.cpp
index b15e9337a1..c9da751102 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/assignment/move_other.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/assignment/move_other.pass.cpp
@@ -45,7 +45,7 @@ void test2() {
assert(f2() == 109);
}
{
- std::move_only_function<int() const& noexcept> f1 = [] noexcept { return 109; };
+ std::move_only_function<int() const & noexcept> f1 = [] noexcept { return 109; };
std::move_only_function<T> f2;
std::same_as<std::move_only_function<T>&> decltype(auto) ret = (f2 = std::move(f1));
assert(&ret == &f2);
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_const_noexcept.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_const_noexcept.pass.cpp
index d8129f541f..2f41506839 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_const_noexcept.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_const_noexcept.pass.cpp
@@ -29,26 +29,26 @@ static_assert(std::is_invocable_v<std::move_only_function<void() const & noexcep
void test() {
{
- called = false;
- std::move_only_function<void() const& noexcept> f = &call_func;
+ called = false;
+ std::move_only_function<void() const & noexcept> f = &call_func;
f();
assert(called);
}
{
- called = false;
- std::move_only_function<void() const& noexcept> f = TriviallyDestructible{};
+ called = false;
+ std::move_only_function<void() const & noexcept> f = TriviallyDestructible{};
f();
assert(called);
}
{
- called = false;
- std::move_only_function<void() const& noexcept> f = TriviallyDestructibleTooLarge{};
+ called = false;
+ std::move_only_function<void() const & noexcept> f = TriviallyDestructibleTooLarge{};
f();
assert(called);
}
{
- called = false;
- std::move_only_function<void() const& noexcept> f = NonTrivial{};
+ called = false;
+ std::move_only_function<void() const & noexcept> f = NonTrivial{};
f();
assert(called);
}
@@ -63,7 +63,7 @@ void test() {
}
{
CallType type;
- std::move_only_function<void() const& noexcept> f = CallTypeCheckerNoexcept{&type};
+ std::move_only_function<void() const & noexcept> f = CallTypeCheckerNoexcept{&type};
f();
assert(type == CallType::ConstLValue);
type = CallType::None;
@@ -80,26 +80,26 @@ void test() {
void test_return() {
{
- called = false;
- std::move_only_function<int(int) const& noexcept> f = &get_val;
+ called = false;
+ std::move_only_function<int(int) const & noexcept> f = &get_val;
assert(f(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int) const& noexcept> f = TriviallyDestructible{};
+ called = false;
+ std::move_only_function<int(int) const & noexcept> f = TriviallyDestructible{};
assert(f(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int) const& noexcept> f = TriviallyDestructibleTooLarge{};
+ called = false;
+ std::move_only_function<int(int) const & noexcept> f = TriviallyDestructibleTooLarge{};
assert(f(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int) const& noexcept> f = NonTrivial{};
+ called = false;
+ std::move_only_function<int(int) const & noexcept> f = NonTrivial{};
assert(f(3) == 3);
assert(!called);
}
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_noexcept.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_noexcept.pass.cpp
index d14f527f81..c3d9788b85 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_noexcept.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/lvalue_noexcept.pass.cpp
@@ -27,26 +27,26 @@ static_assert(!std::is_invocable_v<std::move_only_function<void() & noexcept> co
void test() {
{
- called = false;
- std::move_only_function<void()& noexcept> f = &call_func;
+ called = false;
+ std::move_only_function<void() & noexcept> f = &call_func;
f();
assert(called);
}
{
- called = false;
- std::move_only_function<void()& noexcept> f = TriviallyDestructible{};
+ called = false;
+ std::move_only_function<void() & noexcept> f = TriviallyDestructible{};
f();
assert(called);
}
{
- called = false;
- std::move_only_function<void()& noexcept> f = TriviallyDestructibleTooLarge{};
+ called = false;
+ std::move_only_function<void() & noexcept> f = TriviallyDestructibleTooLarge{};
f();
assert(called);
}
{
- called = false;
- std::move_only_function<void()& noexcept> f = NonTrivial{};
+ called = false;
+ std::move_only_function<void() & noexcept> f = NonTrivial{};
f();
assert(called);
}
@@ -61,7 +61,7 @@ void test() {
}
{
CallType type;
- std::move_only_function<void()& noexcept> f = CallTypeCheckerNoexcept{&type};
+ std::move_only_function<void() & noexcept> f = CallTypeCheckerNoexcept{&type};
f();
assert(type == CallType::LValue);
}
@@ -69,26 +69,26 @@ void test() {
void test_return() {
{
- called = false;
- std::move_only_function<int(int)& noexcept> f = &get_val;
+ called = false;
+ std::move_only_function<int(int) & noexcept> f = &get_val;
assert(f(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int)& noexcept> f = TriviallyDestructible{};
+ called = false;
+ std::move_only_function<int(int) & noexcept> f = TriviallyDestructible{};
assert(f(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int)& noexcept> f = TriviallyDestructibleTooLarge{};
+ called = false;
+ std::move_only_function<int(int) & noexcept> f = TriviallyDestructibleTooLarge{};
assert(f(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int)& noexcept> f = NonTrivial{};
+ called = false;
+ std::move_only_function<int(int) & noexcept> f = NonTrivial{};
assert(f(3) == 3);
assert(!called);
}
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue.pass.cpp
index f51b48564d..016914f420 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue.pass.cpp
@@ -28,42 +28,42 @@ static_assert(!std::is_invocable_v<std::move_only_function<void() &&> const&&>);
void test() {
{
- called = false;
- std::move_only_function<void()&&> f = &call_func;
+ called = false;
+ std::move_only_function<void() &&> f = &call_func;
std::move(f)();
assert(called);
}
{
- called = false;
- std::move_only_function<void()&&> f = TriviallyDestructible{};
+ called = false;
+ std::move_only_function<void() &&> f = TriviallyDestructible{};
std::move(f)();
assert(called);
}
{
- called = false;
- std::move_only_function<void()&&> f = TriviallyDestructibleTooLarge{};
+ called = false;
+ std::move_only_function<void() &&> f = TriviallyDestructibleTooLarge{};
std::move(f)();
assert(called);
}
{
- called = false;
- std::move_only_function<void()&&> f = NonTrivial{};
+ called = false;
+ std::move_only_function<void() &&> f = NonTrivial{};
std::move(f)();
assert(called);
}
{
- std::move_only_function<void(S)&&> f = &S::func;
+ std::move_only_function<void(S) &&> f = &S::func;
assert(f);
}
{
- decltype(&S::func) ptr = nullptr;
- std::move_only_function<void(S)&&> f = ptr;
+ decltype(&S::func) ptr = nullptr;
+ std::move_only_function<void(S) &&> f = ptr;
assert(!f);
}
{
CallType type;
- std::move_only_function<void()&&> f = CallTypeChecker{&type};
- type = CallType::None;
+ std::move_only_function<void() &&> f = CallTypeChecker{&type};
+ type = CallType::None;
std::move(f)();
assert(type == CallType::RValue);
}
@@ -71,26 +71,26 @@ void test() {
void test_return() {
{
- called = false;
- std::move_only_function<int(int)&&> f = &get_val;
+ called = false;
+ std::move_only_function<int(int) &&> f = &get_val;
assert(std::move(f)(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int)&&> f = TriviallyDestructible{};
+ called = false;
+ std::move_only_function<int(int) &&> f = TriviallyDestructible{};
assert(std::move(f)(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int)&&> f = TriviallyDestructibleTooLarge{};
+ called = false;
+ std::move_only_function<int(int) &&> f = TriviallyDestructibleTooLarge{};
assert(std::move(f)(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int)&&> f = NonTrivial{};
+ called = false;
+ std::move_only_function<int(int) &&> f = NonTrivial{};
assert(std::move(f)(3) == 3);
assert(!called);
}
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_const_noexcept.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_const_noexcept.pass.cpp
index 245b60eb45..e566096e03 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_const_noexcept.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_const_noexcept.pass.cpp
@@ -28,42 +28,42 @@ static_assert(std::is_invocable_v<std::move_only_function<void() const && noexce
void test() {
{
- called = false;
- std::move_only_function<void() const&& noexcept> f = &call_func;
+ called = false;
+ std::move_only_function<void() const && noexcept> f = &call_func;
std::move(f)();
assert(called);
}
{
- called = false;
- std::move_only_function<void() const&& noexcept> f = TriviallyDestructible{};
+ called = false;
+ std::move_only_function<void() const && noexcept> f = TriviallyDestructible{};
std::move(f)();
assert(called);
}
{
- called = false;
- std::move_only_function<void() const&& noexcept> f = TriviallyDestructibleTooLarge{};
+ called = false;
+ std::move_only_function<void() const && noexcept> f = TriviallyDestructibleTooLarge{};
std::move(f)();
assert(called);
}
{
- called = false;
- std::move_only_function<void() const&& noexcept> f = NonTrivial{};
+ called = false;
+ std::move_only_function<void() const && noexcept> f = NonTrivial{};
std::move(f)();
assert(called);
}
{
- std::move_only_function<void(S) const&& noexcept> f = &S::func;
+ std::move_only_function<void(S) const && noexcept> f = &S::func;
assert(f);
}
{
- decltype(&S::func) ptr = nullptr;
- std::move_only_function<void(S) const&& noexcept> f = ptr;
+ decltype(&S::func) ptr = nullptr;
+ std::move_only_function<void(S) const && noexcept> f = ptr;
assert(!f);
}
{
CallType type;
- std::move_only_function<void() const&& noexcept> f = CallTypeCheckerNoexcept{&type};
- type = CallType::None;
+ std::move_only_function<void() const && noexcept> f = CallTypeCheckerNoexcept{&type};
+ type = CallType::None;
std::move(f)();
assert(type == CallType::ConstRValue);
type = CallType::None;
@@ -74,26 +74,26 @@ void test() {
void test_return() {
{
- called = false;
- std::move_only_function<int(int) const&& noexcept> f = &get_val;
+ called = false;
+ std::move_only_function<int(int) const && noexcept> f = &get_val;
assert(std::move(f)(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int) const&& noexcept> f = TriviallyDestructible{};
+ called = false;
+ std::move_only_function<int(int) const && noexcept> f = TriviallyDestructible{};
assert(std::move(f)(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int) const&& noexcept> f = TriviallyDestructibleTooLarge{};
+ called = false;
+ std::move_only_function<int(int) const && noexcept> f = TriviallyDestructibleTooLarge{};
assert(std::move(f)(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int) const&& noexcept> f = NonTrivial{};
+ called = false;
+ std::move_only_function<int(int) const && noexcept> f = NonTrivial{};
assert(std::move(f)(3) == 3);
assert(!called);
}
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_noexcept.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_noexcept.pass.cpp
index 87201aeec8..1e9e5ee623 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_noexcept.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.move/call/rvalue_noexcept.pass.cpp
@@ -28,42 +28,42 @@ static_assert(!std::is_invocable_v<std::move_only_function<void() && noexcept> c
void test() {
{
- called = false;
- std::move_only_function<void()&& noexcept> f = &call_func;
+ called = false;
+ std::move_only_function<void() && noexcept> f = &call_func;
std::move(f)();
assert(called);
}
{
- called = false;
- std::move_only_function<void()&& noexcept> f = TriviallyDestructible{};
+ called = false;
+ std::move_only_function<void() && noexcept> f = TriviallyDestructible{};
std::move(f)();
assert(called);
}
{
- called = false;
- std::move_only_function<void()&& noexcept> f = TriviallyDestructibleTooLarge{};
+ called = false;
+ std::move_only_function<void() && noexcept> f = TriviallyDestructibleTooLarge{};
std::move(f)();
assert(called);
}
{
- called = false;
- std::move_only_function<void()&& noexcept> f = NonTrivial{};
+ called = false;
+ std::move_only_function<void() && noexcept> f = NonTrivial{};
std::move(f)();
assert(called);
}
{
- std::move_only_function<void(S)&& noexcept> f = &S::func;
+ std::move_only_function<void(S) && noexcept> f = &S::func;
assert(f);
}
{
- decltype(&S::func) ptr = nullptr;
- std::move_only_function<void(S)&& noexcept> f = ptr;
+ decltype(&S::func) ptr = nullptr;
+ std::move_only_function<void(S) && noexcept> f = ptr;
assert(!f);
}
{
CallType type;
- std::move_only_function<void()&& noexcept> f = CallTypeCheckerNoexcept{&type};
- type = CallType::None;
+ std::move_only_function<void() && noexcept> f = CallTypeCheckerNoexcept{&type};
+ type = CallType::None;
std::move(f)();
assert(type == CallType::RValue);
}
@@ -71,26 +71,26 @@ void test() {
void test_return() {
{
- called = false;
- std::move_only_function<int(int)&& noexcept> f = &get_val;
+ called = false;
+ std::move_only_function<int(int) && noexcept> f = &get_val;
assert(std::move(f)(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int)&& noexcept> f = TriviallyDestructible{};
+ called = false;
+ std::move_only_function<int(int) && noexcept> f = TriviallyDestructible{};
assert(std::move(f)(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int)&& noexcept> f = TriviallyDestructibleTooLarge{};
+ called = false;
+ std::move_only_function<int(int) && noexcept> f = TriviallyDestructibleTooLarge{};
assert(std::move(f)(3) == 3);
assert(!called);
}
{
- called = false;
- std::move_only_function<int(int)&& noexcept> f = NonTrivial{};
+ called = false;
+ std::move_only_function<int(int) && noexcept> f = NonTrivial{};
assert(std::move(f)(3) == 3);
assert(!called);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/94670
More information about the llvm-branch-commits
mailing list