Skip to content

Commit

Permalink
Revert "OrcLib: Text: fmt: std_optional: enhance compatibility with s…
Browse files Browse the repository at this point in the history
…td::decay_t"

This reverts commit 6179e0600b581e139f6354dfa86f017a957dad96.
  • Loading branch information
fabienfl-orc committed Jun 4, 2024
1 parent 824c266 commit d1574d5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/OrcLib/Text/Fmt/std_optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@
#include <fmt/format.h>

template <typename T>
struct fmt::formatter<std::optional<T>> : public fmt::formatter<std::decay_t<T>>
struct fmt::formatter<std::optional<T>> : public fmt::formatter<T>
{
template <typename FormatContext>
auto format(const std::optional<T>& optional, FormatContext& ctx) const -> decltype(ctx.out())
auto format(const std::optional<T>& optional, FormatContext& ctx) -> decltype(ctx.out())
{
if (!optional.has_value())
{
formatter<std::string_view> na;
return na.format("N/A", ctx);
}

return formatter<std::decay_t<T>>::format(optional.value(), ctx);
return formatter<T>::format(optional.value(), ctx);
}
};

template <typename T>
struct fmt::formatter<std::optional<T>, wchar_t> : public fmt::formatter<std::decay_t<T>, wchar_t>
struct fmt::formatter<std::optional<T>, wchar_t> : public fmt::formatter<T, wchar_t>
{
template <typename FormatContext>
auto format(const std::optional<T>& optional, FormatContext& ctx) const -> decltype(ctx.out())
auto format(const std::optional<T>& optional, FormatContext& ctx) -> decltype(ctx.out())
{
if (!optional.has_value())
{
formatter<std::wstring_view, wchar_t> na;
return na.format(L"N/A", ctx);
}

return formatter<std::decay_t<T>, wchar_t>::format(optional.value(), ctx);
return formatter<T, wchar_t>::format(optional.value(), ctx);
}
};

0 comments on commit d1574d5

Please sign in to comment.