From 708fe55ce0a26d2cd90280deeb65df186e1defcd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 26 Nov 2023 13:17:08 +0100 Subject: a --- compat/debug.hpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/compat/debug.hpp b/compat/debug.hpp index 4de2e5ea..cb36e612 100644 --- a/compat/debug.hpp +++ b/compat/debug.hpp @@ -1,6 +1,7 @@ #pragma once #include -#include +#include +#include #include namespace floormat { @@ -23,7 +24,12 @@ struct ErrorString { int value; }; Debug& operator<<(Debug& dbg, ErrorString box); // ***** quoted ***** -template struct Quoted { const T& value; char c; }; +template struct Quoted +{ + using type = T; + T value; char c; +}; + Debug::Flags quoted_begin(Debug& dbg, char c); Debug& quoted_end(Debug& dbg, Debug::Flags flags, char c); @@ -46,7 +52,17 @@ floormat::detail::corrade_debug::Colon colon(char c = ':'); floormat::detail::corrade_debug::ErrorString error_string(int error); floormat::detail::corrade_debug::ErrorString error_string(); -template floormat::detail::corrade_debug::Quoted quoted(const T& value, char c = '\'') { return { value, c }; } -template floormat::detail::corrade_debug::Quoted quoted2(const T& value) { return { value, '"' }; } +template +auto quoted(T&& value, char c = '\'') +{ + using U = std::remove_cvref_t; + using floormat::detail::corrade_debug::Quoted; + if constexpr(std::is_rvalue_reference_v) + return Quoted{ .value = Utility::move(value), .c = c }; + else + return Quoted{ .value = value, .c = c }; +} + +template auto quoted2(T&& value) { return quoted(Utility::forward(value), '"'); } } // namespace floormat -- cgit v1.2.3