24 lines
470 B
C++
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>");
|
|
}
|
|
};
|
|
|