Files
jeanlemotan 8297b0b45f First
2024-07-02 18:06:33 +02:00

24 lines
470 B
C++

#pragma once
#include "tl/detail/prologue.h"
#include <EASTL/optional.h>
#include <format>
namespace tl
{
using namespace eastl;
}
template<typename T>
struct std::formatter<tl::optional<T>>
{
constexpr auto parse(format_parse_context& ctx) noexcept { return ctx.begin(); }
auto format(const tl::optional<T>& s, std::format_context& ctx) const
{
if (s.has_value())
return format_to(ctx.out(), "{}", s.value());
return format_to(ctx.out(), "<null>");
}
};