jinja2cpp / jinja2cpp/Jinja2Cpp

non-const fmt format was deprecated and no longer compiles

Open
#257 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
600
Forks
114
PR merge metrics
No merged PRs in 30d

Description

```
In file included from jinja2cpp/Jinja2Cpp/src/error_info.cpp:3:
In file included from ./vpn/lib/shared/fmt/include/fmt/format.h:56:
./vpn/lib/shared/fmt/include/fmt/base.h:1389:23: error: no matching member function for call to 'format'
ctx.advance_to(cf.format(*static_cast(arg), ctx));
~~~^~~~~~
./vpn/lib/shared/fmt/include/fmt/base.h:1370:21: note: in instantiation of function template specialization 'fmt::detail::value::format_custom_arg>' requested here
custom.format = format_custom_arg<
^
jinja2cpp/Jinja2Cpp/src/error_info.cpp:134:9: note: in instantiation of function template specialization 'fmt::format_to>, const jinja2::Value &, 0>' requested here
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected exception occurred during template processing. Exception: {}").GetValue(), extraParams[0]);
^
jinja2cpp/Jinja2Cpp/src/error_info.cpp:267:5: note: in instantiation of function template specialization 'jinja2::RenderErrorInfo' requested here
RenderErrorInfo(result, *this);
^
jinja2cpp/Jinja2Cpp/src/error_info.cpp:105:10: note: candidate function template not viable: 'this' argument has type 'const fmt::formatter', but method is not marked const
auto format(const jinja2::Value& val, FormatContext& ctx)
^
In file included from jinja2cpp/Jinja2Cpp/src/error_info.cpp:3:
```

This fixes the issue:

```diff
diff --git a/src/error_info.cpp b/src/error_info.cpp
index b60cc8e..5cba8f3 100644
--- a/src/error_info.cpp
+++ b/src/error_info.cpp
@@ -102,7 +102,7 @@ struct formatter
}

template
- auto format(const jinja2::Value& val, FormatContext& ctx)
+ auto format(const jinja2::Value& val, FormatContext& ctx) const
{
nonstd::visit(ValueRenderer(&ctx), val.data());
return fmt::format_to(ctx.out(), UNIVERSAL_STR("").GetValue());
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.