From 0dc9e5e324ecc6005e753dbdf5b00125da75cf31 Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Thu, 25 Aug 2022 00:34:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Logger=20=E5=8F=AF=E8=BE=93=E5=87=BA=20?= =?UTF-8?q?ranges?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAssistant/Logger.hpp | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/src/MeoAssistant/Logger.hpp b/src/MeoAssistant/Logger.hpp index 391ea60143..c7b149e2ce 100644 --- a/src/MeoAssistant/Logger.hpp +++ b/src/MeoAssistant/Logger.hpp @@ -10,6 +10,7 @@ #include #include "AsstUtils.hpp" +#include "AsstRanges.hpp" #include "Version.h" namespace asst @@ -171,22 +172,7 @@ namespace asst struct has_stream_insertion_operator< Stream, T, std::void_t() << std::declval())>> - : std::true_type - { - }; - - template - struct is_range_expression : std::false_type {}; - - template - struct is_range_expression()))>::iterator_category, - std::forward_iterator_tag - > - >> : std::true_type - { - }; + : std::true_type {}; template static Stream& stream_put(Stream& s, T&& v) @@ -200,7 +186,7 @@ namespace asst s << std::forward(v); return s; } - else if constexpr (is_range_expression::value) { + else if constexpr (ranges::input_range) { s << "["; std::string_view comma{}; for (const auto& elem : std::forward(v)) { @@ -213,11 +199,11 @@ namespace asst } else { ASST_STATIC_ASSERT_FALSE( - "\nunsupported type, one of the following expected\n" - "\t1. those can be converted to string;\n" - "\t2. those can be inserted to stream with operator<< directly;\n" - "\t3. container or nested container containing 1. 2. or 3. and iterable with range-based for", - Stream, T); + "\nunsupported type, one of the following expected\n" + "\t1. those can be converted to string;\n" + "\t2. those can be inserted to stream with operator<< directly;\n" + "\t3. container or nested container containing 1. 2. or 3. and iterable with range-based for", + Stream, T); } }