From 50159383787e330ea784b684da5f6dfc47b49113 Mon Sep 17 00:00:00 2001 From: Richard Peters <40753452+richardapeters@users.noreply.github.com> Date: Mon, 22 May 2023 09:53:37 +0200 Subject: [PATCH] fix: ensure forwarding constructors have constraints (#290) * fix: ensure forwarding constructors have constraints that prevent copying / moving objects of the same type * Update infra/stream/InputStream.hpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Resolve SonarCloud violations as a result of applying SonalCloud recommendations * infra/stream/InputStream: Remove duplication by extracting InputStreamWithReader and InputStreamWithErrorPolicy * infra/stream/OutputStream: Remove duplication by extracting OutputStreamWithReader and OutputStreamWithErrorPolicy * Rename TheReader/TheWriter to ReaderType/WriterType * InputStreamWithErrorPolicy, OutputStreamWithErrorPolicy: Delete assignment operators * infra/stream/InputStream, Outputstream: Disable warnings "Remove this class' copy constructor so that the class follows the rule of Zero" * infra/stream/InputStream, Outputstream: Disable warnings "Remove this class' copy constructor so that the class follows the rule of Zero" --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- infra/stream/InputStream.cpp | 38 ---- infra/stream/InputStream.hpp | 208 ++++++++---------- infra/stream/OutputStream.cpp | 38 ---- infra/stream/OutputStream.hpp | 208 ++++++++---------- infra/util/SharedPtr.hpp | 19 +- infra/util/WithStorage.hpp | 43 +++- .../WebSocketClientConnectionObserver.cpp | 2 +- services/util/WritableConfiguration.hpp | 2 +- 8 files changed, 226 insertions(+), 332 deletions(-) diff --git a/infra/stream/InputStream.cpp b/infra/stream/InputStream.cpp index 69b2dd8bc..d26bb407e 100644 --- a/infra/stream/InputStream.cpp +++ b/infra/stream/InputStream.cpp @@ -411,44 +411,6 @@ namespace infra } } - DataInputStream::WithErrorPolicy::WithErrorPolicy(StreamReader& reader) - : DataInputStream(reader, errorPolicy) - {} - - DataInputStream::WithErrorPolicy::WithErrorPolicy(StreamReader& reader, SoftFail) - : DataInputStream(reader, errorPolicy) - , errorPolicy(softFail) - {} - - DataInputStream::WithErrorPolicy::WithErrorPolicy(StreamReader& reader, NoFail) - : DataInputStream(reader, errorPolicy) - , errorPolicy(noFail) - {} - - DataInputStream::WithErrorPolicy::WithErrorPolicy(const WithErrorPolicy& other) - : DataInputStream(other.Reader(), errorPolicy) - , errorPolicy(other.ErrorPolicy()) - {} - - TextInputStream::WithErrorPolicy::WithErrorPolicy(StreamReader& reader) - : TextInputStream(reader, errorPolicy) - {} - - TextInputStream::WithErrorPolicy::WithErrorPolicy(StreamReader& reader, SoftFail) - : TextInputStream(reader, errorPolicy) - , errorPolicy(softFail) - {} - - TextInputStream::WithErrorPolicy::WithErrorPolicy(StreamReader& reader, NoFail) - : TextInputStream(reader, errorPolicy) - , errorPolicy(noFail) - {} - - TextInputStream::WithErrorPolicy::WithErrorPolicy(const WithErrorPolicy& other) - : TextInputStream(other.Reader(), errorPolicy) - , errorPolicy(other.ErrorPolicy()) - {} - namespace { uint8_t DecodeHexByte(char hex) diff --git a/infra/stream/InputStream.hpp b/infra/stream/InputStream.hpp index afb602fcc..8cf8c1bd5 100644 --- a/infra/stream/InputStream.hpp +++ b/infra/stream/InputStream.hpp @@ -63,13 +63,54 @@ namespace infra StreamErrorPolicy& errorPolicy; }; + template + class InputStreamWithReader //NOSONAR + : private detail::StorageHolder> + , public Parent + { + public: + InputStreamWithReader(); + template + explicit InputStreamWithReader(Arg&& arg, std::enable_if_t>>, std::nullptr_t> = nullptr); + template + explicit InputStreamWithReader(Arg0&& arg0, Arg1&& arg1, Args&&... args); + template + InputStreamWithReader(Storage&& storage, const SoftFail&, Args&&... args); + template + InputStreamWithReader(Storage&& storage, const NoFail&, Args&&... args); + InputStreamWithReader(const InputStreamWithReader& other); + InputStreamWithReader& operator=(const InputStreamWithReader& other) = delete; + ~InputStreamWithReader() = default; + + ReaderType& Reader(); + + private: + StreamErrorPolicy errorPolicy; + }; + + template + class InputStreamWithErrorPolicy //NOSONAR + : public Parent + { + public: + explicit InputStreamWithErrorPolicy(StreamReader& reader); + InputStreamWithErrorPolicy(StreamReader& reader, SoftFail); + InputStreamWithErrorPolicy(StreamReader& reader, NoFail); + InputStreamWithErrorPolicy(const InputStreamWithErrorPolicy& other); + InputStreamWithErrorPolicy& operator=(const InputStreamWithErrorPolicy& other) = delete; + ~InputStreamWithErrorPolicy() = default; + + private: + StreamErrorPolicy errorPolicy; + }; + class DataInputStream : public InputStream { public: template - class WithReader; - class WithErrorPolicy; + using WithReader = InputStreamWithReader; + using WithErrorPolicy = InputStreamWithErrorPolicy; using InputStream::InputStream; @@ -87,8 +128,8 @@ namespace infra { public: template - class WithReader; - class WithErrorPolicy; + using WithReader = InputStreamWithReader; + using WithErrorPolicy = InputStreamWithErrorPolicy; using InputStream::InputStream; @@ -129,78 +170,6 @@ namespace infra infra::Optional width; }; - template - class DataInputStream::WithReader - : private detail::StorageHolder> - , public DataInputStream - { - public: - template - explicit WithReader(Args&&... args); - template - WithReader(Storage&& storage, const SoftFail&, Args&&... args); - template - WithReader(Storage&& storage, const NoFail&, Args&&... args); - WithReader(const WithReader& other); - WithReader& operator=(const WithReader& other) = delete; - ~WithReader() = default; - - TheReader& Reader(); - - private: - StreamErrorPolicy errorPolicy; - }; - - class DataInputStream::WithErrorPolicy - : public DataInputStream - { - public: - explicit WithErrorPolicy(StreamReader& reader); - WithErrorPolicy(StreamReader& reader, SoftFail); - WithErrorPolicy(StreamReader& reader, NoFail); - WithErrorPolicy(const WithErrorPolicy& other); - ~WithErrorPolicy() = default; - - private: - StreamErrorPolicy errorPolicy; - }; - - template - class TextInputStream::WithReader - : private detail::StorageHolder> - , public TextInputStream - { - public: - template - explicit WithReader(Args&&... args); - template - WithReader(Storage&& storage, const SoftFail&, Args&&... args); - template - WithReader(Storage&& storage, const NoFail&, Args&&... args); - WithReader(const WithReader& other); - WithReader& operator=(const WithReader& other) = delete; - ~WithReader() = default; - - TheReader& Reader(); - - private: - StreamErrorPolicy errorPolicy; - }; - - class TextInputStream::WithErrorPolicy - : public TextInputStream - { - public: - explicit WithErrorPolicy(StreamReader& writer); - WithErrorPolicy(StreamReader& writer, SoftFail); - WithErrorPolicy(StreamReader& writer, NoFail); - WithErrorPolicy(const WithErrorPolicy& other); - ~WithErrorPolicy() = default; - - private: - StreamErrorPolicy errorPolicy; - }; - class FromHexHelper { public: @@ -248,77 +217,76 @@ namespace infra return result; } - template - template - DataInputStream::WithReader::WithReader(Args&&... args) - : detail::StorageHolder>(std::forward(args)...) - , DataInputStream(this->storage, errorPolicy) + template + InputStreamWithReader::InputStreamWithReader() + : Parent(this->storage, errorPolicy) + {} + + template + template + InputStreamWithReader::InputStreamWithReader(Arg&& arg, std::enable_if_t>>, std::nullptr_t>) + : detail::StorageHolder>(std::forward(arg)) + , Parent(this->storage, errorPolicy) {} - template + template + template + InputStreamWithReader::InputStreamWithReader(Arg0&& arg0, Arg1&& arg1, Args&&... args) + : detail::StorageHolder>(std::forward(arg0), std::forward(arg1), std::forward(args)...) + , Parent(this->storage, errorPolicy) + {} + + template template - DataInputStream::WithReader::WithReader(Storage&& storage, const SoftFail&, Args&&... args) - : detail::StorageHolder>(std::forward(storage), std::forward(args)...) - , DataInputStream(this->storage, errorPolicy) + InputStreamWithReader::InputStreamWithReader(Storage&& storage, const SoftFail&, Args&&... args) + : detail::StorageHolder>(std::forward(storage), std::forward(args)...) + , Parent(this->storage, errorPolicy) , errorPolicy(softFail) {} - template + template template - DataInputStream::WithReader::WithReader(Storage&& storage, const NoFail&, Args&&... args) - : detail::StorageHolder>(std::forward(storage), std::forward(args)...) - , DataInputStream(this->storage, errorPolicy) + InputStreamWithReader::InputStreamWithReader(Storage&& storage, const NoFail&, Args&&... args) + : detail::StorageHolder>(std::forward(storage), std::forward(args)...) + , Parent(this->storage, errorPolicy) , errorPolicy(noFail) {} - template - DataInputStream::WithReader::WithReader(const WithReader& other) - : detail::StorageHolder>(static_cast>&>(other)) - , DataInputStream(this->storage, errorPolicy) + template + InputStreamWithReader::InputStreamWithReader(const InputStreamWithReader& other) + : detail::StorageHolder>(static_cast>&>(other)) + , Parent(this->storage, errorPolicy) , errorPolicy(other.ErrorPolicy()) {} - template - TheReader& DataInputStream::WithReader::Reader() + template + ReaderType& InputStreamWithReader::InputStreamWithReader::Reader() { return this->storage; } - template - template - TextInputStream::WithReader::WithReader(Args&&... args) - : detail::StorageHolder>(std::forward(args)...) - , TextInputStream(this->storage, errorPolicy) + template + InputStreamWithErrorPolicy::InputStreamWithErrorPolicy(StreamReader& reader) + : Parent(reader, errorPolicy) {} - template - template - TextInputStream::WithReader::WithReader(Storage&& storage, const SoftFail&, Args&&... args) - : detail::StorageHolder>(std::forward(storage), std::forward(args)...) - , TextInputStream(this->storage, errorPolicy) + template + InputStreamWithErrorPolicy::InputStreamWithErrorPolicy(StreamReader& reader, SoftFail) + : Parent(reader, errorPolicy) , errorPolicy(softFail) {} - template - template - TextInputStream::WithReader::WithReader(Storage&& storage, const NoFail&, Args&&... args) - : detail::StorageHolder>(std::forward(storage), std::forward(args)...) - , TextInputStream(this->storage, errorPolicy) + template + InputStreamWithErrorPolicy::InputStreamWithErrorPolicy(StreamReader& reader, NoFail) + : Parent(reader, errorPolicy) , errorPolicy(noFail) {} - template - TextInputStream::WithReader::WithReader(const WithReader& other) - : detail::StorageHolder>(static_cast>&>(other)) - , TextInputStream(this->storage, errorPolicy) + template + InputStreamWithErrorPolicy::InputStreamWithErrorPolicy(const InputStreamWithErrorPolicy& other) + : Parent(other.Reader(), errorPolicy) , errorPolicy(other.ErrorPolicy()) {} - - template - TheReader& TextInputStream::WithReader::Reader() - { - return this->storage; - } } #endif diff --git a/infra/stream/OutputStream.cpp b/infra/stream/OutputStream.cpp index 4e854076e..2251d9631 100644 --- a/infra/stream/OutputStream.cpp +++ b/infra/stream/OutputStream.cpp @@ -342,44 +342,6 @@ namespace infra Writer().Insert(MakeByteRange(width.padding), ErrorPolicy()); } - DataOutputStream::WithErrorPolicy::WithErrorPolicy(StreamWriter& writer) - : DataOutputStream(writer, errorPolicy) - {} - - DataOutputStream::WithErrorPolicy::WithErrorPolicy(StreamWriter& writer, SoftFail) - : DataOutputStream(writer, errorPolicy) - , errorPolicy(softFail) - {} - - DataOutputStream::WithErrorPolicy::WithErrorPolicy(StreamWriter& writer, NoFail) - : DataOutputStream(writer, errorPolicy) - , errorPolicy(noFail) - {} - - DataOutputStream::WithErrorPolicy::WithErrorPolicy(const WithErrorPolicy& other) - : DataOutputStream(other.Writer(), errorPolicy) - , errorPolicy(other.ErrorPolicy()) - {} - - TextOutputStream::WithErrorPolicy::WithErrorPolicy(StreamWriter& writer) - : TextOutputStream(writer, errorPolicy) - {} - - TextOutputStream::WithErrorPolicy::WithErrorPolicy(StreamWriter& writer, SoftFail) - : TextOutputStream(writer, errorPolicy) - , errorPolicy(softFail) - {} - - TextOutputStream::WithErrorPolicy::WithErrorPolicy(StreamWriter& writer, NoFail) - : TextOutputStream(writer, errorPolicy) - , errorPolicy(noFail) - {} - - TextOutputStream::WithErrorPolicy::WithErrorPolicy(const WithErrorPolicy& other) - : TextOutputStream(other.Writer(), errorPolicy) - , errorPolicy(other.ErrorPolicy()) - {} - AsAsciiHelper::AsAsciiHelper(ConstByteRange data) : data(data) {} diff --git a/infra/stream/OutputStream.hpp b/infra/stream/OutputStream.hpp index 1418c69b8..937f35805 100644 --- a/infra/stream/OutputStream.hpp +++ b/infra/stream/OutputStream.hpp @@ -82,13 +82,54 @@ namespace infra StreamErrorPolicy& errorPolicy; }; + template + class OutputStreamWithWriter //NOSONAR + : private detail::StorageHolder> + , public Parent + { + public: + OutputStreamWithWriter(); + template + explicit OutputStreamWithWriter(Arg&& arg, std::enable_if_t>>, std::nullptr_t> = nullptr); + template + explicit OutputStreamWithWriter(Arg0&& arg0, Arg1&& arg1, Args&&... args); + template + OutputStreamWithWriter(Storage&& storage, SoftFail, Args&&... args); + template + OutputStreamWithWriter(Storage&& storage, NoFail, Args&&... args); + OutputStreamWithWriter(const OutputStreamWithWriter& other); + OutputStreamWithWriter& operator=(const OutputStreamWithWriter& other) = delete; + ~OutputStreamWithWriter() = default; + + WriterType& Writer(); + + private: + StreamErrorPolicy errorPolicy; + }; + + template + class OutputStreamWithErrorPolicy //NOSONAR + : public Parent + { + public: + explicit OutputStreamWithErrorPolicy(StreamWriter& writer); + OutputStreamWithErrorPolicy(StreamWriter& writer, SoftFail); + OutputStreamWithErrorPolicy(StreamWriter& writer, NoFail); + OutputStreamWithErrorPolicy(const OutputStreamWithErrorPolicy& other); + OutputStreamWithErrorPolicy& operator=(const OutputStreamWithErrorPolicy& other) = delete; + ~OutputStreamWithErrorPolicy() = default; + + private: + StreamErrorPolicy errorPolicy; + }; + class DataOutputStream : public OutputStream { public: template - class WithWriter; - class WithErrorPolicy; + using WithWriter = OutputStreamWithWriter; + using WithErrorPolicy = OutputStreamWithErrorPolicy; using OutputStream::OutputStream; @@ -105,8 +146,8 @@ namespace infra { public: template - class WithWriter; - class WithErrorPolicy; + using WithWriter = OutputStreamWithWriter; + using WithErrorPolicy = OutputStreamWithErrorPolicy; TextOutputStream(StreamWriter& writer, StreamErrorPolicy& errorPolicy); @@ -202,78 +243,6 @@ namespace infra Width width{ 0 }; }; - template - class DataOutputStream::WithWriter - : private detail::StorageHolder> - , public DataOutputStream - { - public: - template - explicit WithWriter(Args&&... args); - template - WithWriter(Storage&& storage, SoftFail, Args&&... args); - template - WithWriter(Storage&& storage, NoFail, Args&&... args); - WithWriter(const WithWriter& other); - WithWriter& operator=(const WithWriter& other) = delete; - ~WithWriter() = default; - - TheWriter& Writer(); - - private: - StreamErrorPolicy errorPolicy; - }; - - class DataOutputStream::WithErrorPolicy - : public DataOutputStream - { - public: - explicit WithErrorPolicy(StreamWriter& writer); - WithErrorPolicy(StreamWriter& writer, SoftFail); - WithErrorPolicy(StreamWriter& writer, NoFail); - WithErrorPolicy(const WithErrorPolicy& other); - ~WithErrorPolicy() = default; - - private: - StreamErrorPolicy errorPolicy; - }; - - template - class TextOutputStream::WithWriter - : private detail::StorageHolder> - , public TextOutputStream - { - public: - template - explicit WithWriter(Args&&... args); - template - WithWriter(Storage&& storage, SoftFail, Args&&... args); - template - WithWriter(Storage&& storage, NoFail, Args&&... args); - WithWriter(const WithWriter& other); - WithWriter& operator=(const WithWriter& other) = delete; - ~WithWriter() = default; - - TheWriter& Writer(); - - private: - StreamErrorPolicy errorPolicy; - }; - - class TextOutputStream::WithErrorPolicy - : public TextOutputStream - { - public: - explicit WithErrorPolicy(StreamWriter& writer); - WithErrorPolicy(StreamWriter& writer, SoftFail); - WithErrorPolicy(StreamWriter& writer, NoFail); - WithErrorPolicy(const WithErrorPolicy& other); - ~WithErrorPolicy() = default; - - private: - StreamErrorPolicy errorPolicy; - }; - class AsAsciiHelper { public: @@ -399,78 +368,77 @@ namespace infra return *this; } - template - template - DataOutputStream::WithWriter::WithWriter(Args&&... args) - : detail::StorageHolder>(std::forward(args)...) - , DataOutputStream(this->storage, errorPolicy) + template + OutputStreamWithWriter::OutputStreamWithWriter() + : Parent(this->storage, errorPolicy) + {} + + template + template + OutputStreamWithWriter::OutputStreamWithWriter(Arg&& arg, std::enable_if_t>>, std::nullptr_t>) + : detail::StorageHolder>(std::forward(arg)) + , Parent(this->storage, errorPolicy) + {} + + template + template + OutputStreamWithWriter::OutputStreamWithWriter(Arg0&& arg0, Arg1&& arg1, Args&&... args) + : detail::StorageHolder>(std::forward(arg0), std::forward(arg1), std::forward(args)...) + , Parent(this->storage, errorPolicy) {} - template + template template - DataOutputStream::WithWriter::WithWriter(Storage&& storage, SoftFail, Args&&... args) - : detail::StorageHolder>(std::forward(storage), std::forward(args)...) - , DataOutputStream(this->storage, errorPolicy) + OutputStreamWithWriter::OutputStreamWithWriter(Storage&& storage, SoftFail, Args&&... args) + : detail::StorageHolder>(std::forward(storage), std::forward(args)...) + , Parent(this->storage, errorPolicy) , errorPolicy(softFail) {} - template + template template - DataOutputStream::WithWriter::WithWriter(Storage&& storage, NoFail, Args&&... args) - : detail::StorageHolder>(std::forward(storage), std::forward(args)...) - , DataOutputStream(this->storage, errorPolicy) + OutputStreamWithWriter::OutputStreamWithWriter(Storage&& storage, NoFail, Args&&... args) + : detail::StorageHolder>(std::forward(storage), std::forward(args)...) + , Parent(this->storage, errorPolicy) , errorPolicy(noFail) {} - template - DataOutputStream::WithWriter::WithWriter(const WithWriter& other) - : detail::StorageHolder>(static_cast>&>(other)) - , DataOutputStream(this->storage, errorPolicy) + template + OutputStreamWithWriter::OutputStreamWithWriter(const OutputStreamWithWriter& other) + : detail::StorageHolder>(static_cast>&>(other)) + , Parent(this->storage, errorPolicy) , errorPolicy(other.ErrorPolicy()) {} - template - TheWriter& DataOutputStream::WithWriter::Writer() + template + WriterType& OutputStreamWithWriter::Writer() { return this->storage; } - template - template - TextOutputStream::WithWriter::WithWriter(Args&&... args) - : detail::StorageHolder>(std::forward(args)...) - , TextOutputStream(this->storage, errorPolicy) + template + OutputStreamWithErrorPolicy::OutputStreamWithErrorPolicy(StreamWriter& writer) + : Parent(writer, errorPolicy) {} - template - template - TextOutputStream::WithWriter::WithWriter(Storage&& storage, SoftFail, Args&&... args) - : detail::StorageHolder>(std::forward(storage), std::forward(args)...) - , TextOutputStream(this->storage, errorPolicy) + template + OutputStreamWithErrorPolicy::OutputStreamWithErrorPolicy(StreamWriter& writer, SoftFail) + : Parent(writer, errorPolicy) , errorPolicy(softFail) {} - template - template - TextOutputStream::WithWriter::WithWriter(Storage&& storage, NoFail, Args&&... args) - : detail::StorageHolder>(std::forward(storage), std::forward(args)...) - , TextOutputStream(this->storage, errorPolicy) + template + OutputStreamWithErrorPolicy::OutputStreamWithErrorPolicy(StreamWriter& writer, NoFail) + : Parent(writer, errorPolicy) , errorPolicy(noFail) {} - template - TextOutputStream::WithWriter::WithWriter(const WithWriter& other) - : detail::StorageHolder>(static_cast>&>(other)) - , TextOutputStream(this->storage, errorPolicy) + template + OutputStreamWithErrorPolicy::OutputStreamWithErrorPolicy(const OutputStreamWithErrorPolicy& other) + : Parent(other.Writer(), errorPolicy) , errorPolicy(other.ErrorPolicy()) {} - template - TheWriter& TextOutputStream::WithWriter::Writer() - { - return this->storage; - } - template TextOutputStream::Formatter::Formatter(T value) : value(value) diff --git a/infra/util/SharedPtr.hpp b/infra/util/SharedPtr.hpp index ba63fe0a3..5776601a1 100644 --- a/infra/util/SharedPtr.hpp +++ b/infra/util/SharedPtr.hpp @@ -730,11 +730,24 @@ namespace infra : private SharedObjectDeleter { public: - template - SharedObjectOnHeap(Args&&... args) + SharedObjectOnHeap() : control(&*object, this) { - object.Construct(std::forward(args)...); + object.Construct(); + } + + template + SharedObjectOnHeap(Arg&& arg, std::enable_if_t>>, std::nullptr_t> = nullptr) + : control(&*object, this) + { + object.Construct(std::forward(arg)); + } + + template + SharedObjectOnHeap(Arg0&& arg0, Arg1&& arg1, Args&&... args) + : control(&*object, this) + { + object.Construct(std::forward(arg0), std::forward(arg1), std::forward(args)...); } operator SharedPtr() diff --git a/infra/util/WithStorage.hpp b/infra/util/WithStorage.hpp index a13516a4a..52f78eb9e 100644 --- a/infra/util/WithStorage.hpp +++ b/infra/util/WithStorage.hpp @@ -23,10 +23,13 @@ namespace infra , public Base { public: + WithStorage(); template WithStorage(InPlace, StorageArg&& storageArg, Args&&... args); - template - WithStorage(Args&&... args); + template + WithStorage(Arg&& arg, std::enable_if_t>>, std::nullptr_t> = nullptr); + template + WithStorage(Arg0&& arg0, Arg1&& arg1, Args&&... args); template WithStorage(std::initializer_list initializerList, Args&&... args); @@ -63,9 +66,10 @@ namespace infra { public: StorageHolder() = default; - - template - StorageHolder(Arg0&& arg0, Args&&... args); + template + StorageHolder(Arg&& arg, std::enable_if_t>>, std::nullptr_t> = nullptr); + template + StorageHolder(Arg0&& arg0, Arg1&& arg1, Args&&... args); StorageType storage; }; @@ -73,6 +77,11 @@ namespace infra //// Implementation //// + template + WithStorage::WithStorage() + : Base(detail::StorageHolder::storage) + {} + template template WithStorage::WithStorage(InPlace, StorageArg&& storageArg, Args&&... args) @@ -81,9 +90,15 @@ namespace infra {} template - template - WithStorage::WithStorage(Args&&... args) - : Base(detail::StorageHolder::storage, std::forward(args)...) + template + WithStorage::WithStorage(Arg&& arg, std::enable_if_t>>, std::nullptr_t>) + : Base(detail::StorageHolder::storage, std::forward(arg)) + {} + + template + template + WithStorage::WithStorage(Arg0&& arg0, Arg1&& arg1, Args&&... args) + : Base(detail::StorageHolder::storage, std::forward(arg0), std::forward(arg1), std::forward(args)...) {} template @@ -141,9 +156,15 @@ namespace infra namespace detail { template - template - StorageHolder::StorageHolder(Arg0&& arg0, Args&&... args) - : storage(std::forward(arg0), std::forward(args)...) + template + StorageHolder::StorageHolder(Arg&& arg, std::enable_if_t>>, std::nullptr_t>) + : storage(std::forward(arg)) + {} + + template + template + StorageHolder::StorageHolder(Arg0&& arg0, Arg1&& arg1, Args&&... args) + : storage(std::forward(arg0), std::forward(arg1), std::forward(args)...) {} } } diff --git a/services/network/WebSocketClientConnectionObserver.cpp b/services/network/WebSocketClientConnectionObserver.cpp index 948c49994..56c2242fe 100644 --- a/services/network/WebSocketClientConnectionObserver.cpp +++ b/services/network/WebSocketClientConnectionObserver.cpp @@ -401,7 +401,7 @@ namespace services { std::array randomData; randomDataGenerator.GenerateRandomData(randomData); - infra::StringOutputStream::WithWriter stream(webSocketKey); + infra::TextOutputStream::WithWriter stream(webSocketKey); stream << infra::AsBase64(randomData); headers.emplace_back("Content-Length", "0"); diff --git a/services/util/WritableConfiguration.hpp b/services/util/WritableConfiguration.hpp index 3c871580b..4b3826cd1 100644 --- a/services/util/WritableConfiguration.hpp +++ b/services/util/WritableConfiguration.hpp @@ -132,7 +132,7 @@ namespace services template void WritableConfiguration::LoadConfiguration(infra::ConstByteRange memory) { - infra::ByteInputStream::WithReader stream(memory, infra::noFail); + infra::DataInputStream::WithReader stream(memory, infra::noFail); auto header = stream.Extract
(); valid = false;