BAN: Strings can now be constructed using BAN::Formatter

This commit is contained in:
Bananymous 2022-12-27 20:01:05 +02:00
parent fd4fdffd46
commit f0fd62c703
1 changed files with 11 additions and 0 deletions

View File

@ -20,6 +20,9 @@ namespace BAN
String(const char*, size_type = -1); String(const char*, size_type = -1);
~String(); ~String();
template<typename... Args>
static String Formatted(const char* format, const Args&... args);
String& operator=(const String&); String& operator=(const String&);
String& operator=(String&&); String& operator=(String&&);
@ -63,6 +66,14 @@ namespace BAN
size_type m_size = 0; size_type m_size = 0;
}; };
template<typename... Args>
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 namespace BAN::Formatter