From 2c271f44e2835fcefac65df1869eeb920b0b0dc9 Mon Sep 17 00:00:00 2001 From: Ian Petersen Date: Mon, 30 Oct 2023 10:45:41 -0700 Subject: [PATCH 001/157] Format adapt_stream.hpp --- include/unifex/adapt_stream.hpp | 53 +++++++++++++++++---------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/include/unifex/adapt_stream.hpp b/include/unifex/adapt_stream.hpp index 5791ade06..5af8e7623 100644 --- a/include/unifex/adapt_stream.hpp +++ b/include/unifex/adapt_stream.hpp @@ -28,7 +28,10 @@ template struct _adapted { struct type; }; -template +template < + typename Stream, + typename NextAdaptFunc, + typename CleanupAdaptFunc = void> using adapted = typename _adapted< remove_cvref_t, std::decay_t, @@ -70,33 +73,33 @@ struct _adapted::type { return std::invoke(s.adapter_, cleanup(s.innerStream_)); } }; -} // namespace _adapt_stream +} // namespace _adapt_stream namespace _adapt_stream_cpo { - inline const struct _fn { - template - auto operator()(Stream&& stream, AdapterFunc&& adapt) const - -> _adapt_stream::adapted { - return {(Stream &&) stream, (AdapterFunc &&) adapt}; - } +inline const struct _fn { + template + auto operator()(Stream&& stream, AdapterFunc&& adapt) const + -> _adapt_stream::adapted { + return {(Stream &&) stream, (AdapterFunc &&) adapt}; + } - template < - typename Stream, - typename NextAdapterFunc, - typename CleanupAdapterFunc> - auto operator()( - Stream&& stream, - NextAdapterFunc&& adaptNext, - CleanupAdapterFunc&& adaptCleanup) const - -> _adapt_stream::adapted { - return { - (Stream &&) stream, - (NextAdapterFunc &&) adaptNext, - (CleanupAdapterFunc &&) adaptCleanup}; - } - } adapt_stream {}; -} // namespace _adapt_stream_cpo + template < + typename Stream, + typename NextAdapterFunc, + typename CleanupAdapterFunc> + auto operator()( + Stream&& stream, + NextAdapterFunc&& adaptNext, + CleanupAdapterFunc&& adaptCleanup) const + -> _adapt_stream::adapted { + return { + (Stream &&) stream, + (NextAdapterFunc &&) adaptNext, + (CleanupAdapterFunc &&) adaptCleanup}; + } +} adapt_stream{}; +} // namespace _adapt_stream_cpo using _adapt_stream_cpo::adapt_stream; -} // namespace unifex +} // namespace unifex #include From d5250e952c9645a58559eef6ffc691f36fe934b2 Mon Sep 17 00:00:00 2001 From: Ian Petersen Date: Mon, 30 Oct 2023 10:54:16 -0700 Subject: [PATCH 002/157] Format allocate.hpp --- include/unifex/allocate.hpp | 244 ++++++++++++++++++------------------ 1 file changed, 123 insertions(+), 121 deletions(-) diff --git a/include/unifex/allocate.hpp b/include/unifex/allocate.hpp index b657b73ad..77901c3d2 100644 --- a/include/unifex/allocate.hpp +++ b/include/unifex/allocate.hpp @@ -16,13 +16,13 @@ #pragma once #include +#include +#include #include #include #include #include #include -#include -#include #include #include @@ -31,128 +31,130 @@ namespace unifex { namespace _alloc { - template - struct _op { - class type; - }; - template - using operation = typename _op::type; - - template - class _op::type { - using operation = type; - using allocator_t = typename std::allocator_traits< - Allocator>::template rebind_alloc; - - public: - template - explicit type(Sender&& s, Receiver&& r) - : allocator_(get_allocator(r)) { - using allocator_traits = std::allocator_traits; - Operation* op = allocator_traits::allocate(allocator_, 1); - scope_guard freeOnError = [&]() noexcept { - allocator_traits::deallocate(allocator_, op, 1); - }; - op_ = ::new (static_cast(op)) - Operation(connect((Sender &&) s, (Receiver &&) r)); - freeOnError.release(); - } - - ~type() { - op_->~Operation(); - std::allocator_traits::deallocate(allocator_, op_, 1); - } - - friend void tag_invoke(tag_t, operation& op) noexcept { - start(*op.op_); - } - - private: - Operation* op_; - UNIFEX_NO_UNIQUE_ADDRESS allocator_t allocator_; - }; - - template - struct _sender { - class type; - }; - template - using sender = typename _sender>::type; - - template - class _sender::type { - using sender = type; - public: - template < - template class Variant, - template class Tuple> - using value_types = sender_value_types_t; - - template