From 9ce29b6830c00b251297bc9079d5f74cd5909136 Mon Sep 17 00:00:00 2001 From: "matthias@arch" Date: Wed, 28 Sep 2022 15:32:40 +0200 Subject: [PATCH] New concepts --- src/log.hpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/log.hpp b/src/log.hpp index 0922d0b..f8ad72d 100755 --- a/src/log.hpp +++ b/src/log.hpp @@ -39,22 +39,22 @@ namespace gz { * @details * As of now you can log type T with instance t: * -# Any @ref util::Stringy "string-like type": eg. std::string, std::string_view - * -# Any @ref util::WorksWithStdToString "type that works with std::to_string()" - * -# Any @ref util::HasToStringMember "type that has a to_string() const member that returns a string" + * -# Any @ref util::WorksWithStdToString "type that works with std::toString()" + * -# Any @ref util::HasToStringMember "type that has a toString() const member that returns a string" * -# Any @ref util::ContainerConvertibleToString "type that has a forward_iterator" which references any one of 1-3 * -# Any @ref util::PairConvertibleToString "type with t.first, t.second" provided t.first satisfies one of 1-4 and t.second satisfies 1-4 * -# Any @ref util::MapConvertibleToString "type that has a forward_iterator" which references 5 * -# Any @ref util::Vector2ConvertibleToString "type with t.x and t.y", provided t.x and t.y satisfy one of 1-6 * -# Any @ref util::Vector3ConvertibleToString "type with t.x, t.y, t.z", provided t.x, t.y, t.z satisfy one of 1-6 * -# Any @ref util::Vector4ConvertibleToString "type with t.x, t.y, t.z and t.w", provided t.x, t.y, t.z, t.w satisfy one of 1-6 - * -# Any @ref ConvertibleToString "type for which an overload of" util::Stringy to_string(const T&) exists in global or gz namespace + * -# Any @ref ConvertibleToString "type for which an overload of" util::Stringy toString(const T&) exists in global or gz namespace * * The higher number takes precedence in overload resolution for the log function. * * 1-6 include for example: * - int, float, bool... * - std::vector, std::list - * - std::map> if A.to_string() returns a string - ... + * - std::map> if A.toString() returns a string - ... */ template concept Logable = ConvertibleToString; @@ -68,9 +68,9 @@ namespace gz { * If you want your custom data type to be logable, it easiest to provide a member function with this signature: * @code * public: - * std::string to_string() const; + * std::string toString() const; * @endcode - * Alternatively, or if the type is not a class overload std::string to_string(const T& t) in global or gz namespace. + * Alternatively, or if the type is not a class overload std::string toString(const T& t) in global or gz namespace. * * @subsection log_threads Thread safety * Log can use a static mutex for thread safety. To use this feature, you have to #define LOG_MULTITHREAD at the top of log.hpp. @@ -214,17 +214,16 @@ class Log { logLines[iter] += appendChars; vlog(" ", std::forward< Args>(args)...); } - /// Log anything where to_string exists + /// Log anything where toString exists template void vlog(const char* appendChars, T&& t, Args&&... args) requires (!util::Stringy) { - logLines[iter] += to_string(t); + logLines[iter] += toString(t); logLines[iter] += appendChars; vlog(" ", std::forward< Args>(args)...); } void vlog(const char* appendChars) {}; - private: /// Where the lines are stored std::vector logLines;