Merge pull request #3441 from tchaikov/fmt-format-const
This commit is contained in:
commit
f6ff6492ef
|
@ -92,7 +92,7 @@ struct formatter<pow_format> {
|
||||||
template <>
|
template <>
|
||||||
struct formatter<Glib::ustring> : formatter<std::string> {
|
struct formatter<Glib::ustring> : formatter<std::string> {
|
||||||
template <typename FormatContext>
|
template <typename FormatContext>
|
||||||
auto format(const Glib::ustring& value, FormatContext& ctx) {
|
auto format(const Glib::ustring& value, FormatContext& ctx) const {
|
||||||
return formatter<std::string>::format(static_cast<std::string>(value), ctx);
|
return formatter<std::string>::format(static_cast<std::string>(value), ctx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,14 +14,14 @@
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct fmt::formatter<Glib::VariantBase> : formatter<std::string> {
|
struct fmt::formatter<Glib::VariantBase> : formatter<std::string> {
|
||||||
bool is_printable(const Glib::VariantBase& value) {
|
bool is_printable(const Glib::VariantBase& value) const {
|
||||||
auto type = value.get_type_string();
|
auto type = value.get_type_string();
|
||||||
/* Print only primitive (single character excluding 'v') and short complex types */
|
/* Print only primitive (single character excluding 'v') and short complex types */
|
||||||
return (type.length() == 1 && islower(type[0]) && type[0] != 'v') || value.get_size() <= 32;
|
return (type.length() == 1 && islower(type[0]) && type[0] != 'v') || value.get_size() <= 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FormatContext>
|
template <typename FormatContext>
|
||||||
auto format(const Glib::VariantBase& value, FormatContext& ctx) {
|
auto format(const Glib::VariantBase& value, FormatContext& ctx) const {
|
||||||
if (is_printable(value)) {
|
if (is_printable(value)) {
|
||||||
return formatter<std::string>::format(static_cast<std::string>(value.print()), ctx);
|
return formatter<std::string>::format(static_cast<std::string>(value.print()), ctx);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue