From f0fd62c7039efff0351e62fa574eca1027bb294a Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 27 Dec 2022 20:01:05 +0200 Subject: [PATCH] BAN: Strings can now be constructed using BAN::Formatter --- BAN/include/BAN/String.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/BAN/include/BAN/String.h b/BAN/include/BAN/String.h index 797da03a92..1782dd9b77 100644 --- a/BAN/include/BAN/String.h +++ b/BAN/include/BAN/String.h @@ -20,6 +20,9 @@ namespace BAN String(const char*, size_type = -1); ~String(); + template + static String Formatted(const char* format, const Args&... args); + String& operator=(const String&); String& operator=(String&&); @@ -63,6 +66,14 @@ namespace BAN size_type m_size = 0; }; + template + String String::Formatted(const char* format, const Args&... args) + { + String result; + BAN::Formatter::print([&](char c){ result.PushBack(c); }, format, args...); + return result; + } + } namespace BAN::Formatter