2021-10-29 13:25:12 -07:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <ostream>
|
2021-11-05 08:47:21 -07:00
|
|
|
#include <optional>
|
|
|
|
|
2021-11-19 08:10:07 -08:00
|
|
|
namespace std
|
|
|
|
{
|
2021-10-29 13:25:12 -07:00
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& lhs, const std::nullopt_t&)
|
|
|
|
{
|
|
|
|
return lhs << "none";
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2021-11-05 08:47:21 -07:00
|
|
|
auto operator<<(std::ostream& lhs, const std::optional<T>& t) -> decltype(lhs << *t) // SFINAE to only instantiate << for supported types
|
2021-10-29 13:25:12 -07:00
|
|
|
{
|
|
|
|
if (t)
|
|
|
|
return lhs << *t;
|
|
|
|
else
|
|
|
|
return lhs << "none";
|
|
|
|
}
|
2021-11-05 08:47:21 -07:00
|
|
|
|
|
|
|
} // namespace std
|