1
0
Files
YYCCommonplace/src/yycc/option.hpp
yyc12345 c48e79753d refactor: cancel the namespace Rust.
- all sub-functions are put into respective position.
2025-10-07 18:15:17 +08:00

26 lines
663 B
C++

#pragma once
#include <optional>
/**
* @brief The reproduction of Rust Option type.
* @details
* This namespace reproduce Rust Option type, and its members Some and None in C++.
* However Option is not important than Result, so its implementation is very casual.
*/
namespace yycc::option {
template<typename T>
using Option = std::optional<T>;
template<typename OptionType, typename... Args>
OptionType Some(Args &&...args) {
return OptionType(std::in_place, std::forward<Args>(args)...);
}
template<typename OptionType>
OptionType None() {
return OptionType(std::nullopt);
}
} // namespace yycc::option