libkazv
maybe.hpp
Go to the documentation of this file.
1
/*
2
* This file is part of libkazv.
3
* SPDX-FileCopyrightText: 2021 Tusooa Zhu <tusooa@kazv.moe>
4
* SPDX-License-Identifier: AGPL-3.0-or-later
5
*/
6
7
#pragma once
8
#include "
libkazv-config.hpp
"
9
10
#include <string>
11
#include <optional>
12
13
namespace
Kazv
14
{
15
class
NotBut
16
{
17
std::string m_reason;
18
public
:
19
explicit
NotBut
(std::string r) : m_reason(r) {}
20
std::string
reason
()
const
{
return
m_reason; }
21
};
22
23
template
<
class
T>
24
class
Maybe
:
public
std::optional<T>
25
{
26
std::string m_reason;
27
using
BaseT = std::optional<T>;
28
public
:
29
Maybe
(T x) : BaseT(
std
::move(x)) {}
30
Maybe
(
NotBut
r) : BaseT(), m_reason(r.
reason
()) {}
31
32
std::string
reason
()
const
{
return
m_reason; }
33
};
34
35
using
MaybeString
=
Maybe<std::string>
;
36
}
Kazv::Maybe::Maybe
Maybe(NotBut r)
Definition:
maybe.hpp:30
Kazv::Maybe
Definition:
maybe.hpp:24
Kazv::NotBut::NotBut
NotBut(std::string r)
Definition:
maybe.hpp:19
Kazv
Definition:
location.hpp:10
Kazv::Maybe::Maybe
Maybe(T x)
Definition:
maybe.hpp:29
Kazv::Maybe::reason
std::string reason() const
Definition:
maybe.hpp:32
std
Definition:
clientutil.hpp:216
libkazv-config.hpp
Kazv::NotBut::reason
std::string reason() const
Definition:
maybe.hpp:20
Kazv::NotBut
Definition:
maybe.hpp:15
src
base
maybe.hpp
Generated by
1.8.17