Skip to content

Result型

Min edited this page Dec 23, 2023 · 2 revisions
template <typename T, typename E>
class Result
{
	private:
		T	*_value;
		E	_error;
		bool	_is_ok;

	public:
		Result();
		~Result();
		
		static Result<T, E>	Ok(const T &value); // 成功を表す静的メソッド
		static Result<T, E>	Err(E error); // 失敗を表す静的メソッド

		bool	ok() const;

		T	unwrap();
		E	unwrapErr();
};