Skip to content

Commit

Permalink
Fix clang-14 fmt compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Sherman committed Feb 5, 2024
1 parent ace4a7c commit 5c091f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion components/pango_core/include/pangolin/utils/fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@
namespace pangolin
{

template <typename TFmt, typename... TArgs>
std::string format(TFmt&& fmt, TArgs&&... args) {
if constexpr (sizeof...(args) == 0) {
return "";
} else if constexpr (std::is_convertible_v<TFmt, std::string_view>) {
return fmt::format(fmt::runtime(fmt), std::forward<TArgs>(args)...);
} else {
return fmt::format(fmt, std::forward<TArgs>(args)...);
}
}

template <typename... TArgs>
void println(TArgs&&... args)
{
fmt::print(std::forward<TArgs>(args)...);
fmt::print(fmt::runtime(format(std::forward<TArgs>(args)...)));
std::cout << std::endl;
}

Expand Down
4 changes: 2 additions & 2 deletions components/pango_core/include/pangolin/utils/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ struct Log {
const char* assertion_statement, Args... args)
{
if constexpr (sizeof...(args) > 0) {
const std::string arg_string = fmt::format(std::forward<Args>(args)...);
const std::string arg_string = pangolin::format(std::forward<Args>(args)...);
logImpl(kind, sFile, sFunction, nLine, assertion_statement, arg_string);
} else {
logImpl(kind, sFile, sFunction, nLine, assertion_statement, "");
Expand All @@ -137,7 +137,7 @@ struct Log {
const char* assertion_statement, Args... args)
{
if constexpr (sizeof...(args) > 0) {
const std::string arg_string = fmt::format(std::forward<Args>(args)...);
const std::string arg_string = pangolin::format(std::forward<Args>(args)...);
logImpl(kind, sFile, sFunction, nLine, assertion_statement, arg_string);
throw std::runtime_error(arg_string);
} else {
Expand Down

0 comments on commit 5c091f7

Please sign in to comment.