tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
monostate.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2021 Tobias Hienzsch
3
4#ifndef TETL_VARIANT_MONOSTATE_HPP
5#define TETL_VARIANT_MONOSTATE_HPP
6
7#include <etl/_compare/strong_ordering.hpp>
8
9namespace etl {
10
11/// \brief Unit type intended for use as a well-behaved empty alternative in
12/// etl::variant. In particular, a variant of non-default-constructible types
13/// may list etl::monostate as its first alternative: this makes the variant
14/// itself default-constructible
15///
16/// \headerfile etl/variant.hpp
17struct monostate {
18 /// \brief All instances of etl::monostate compare equal.
19 [[nodiscard]] friend constexpr auto operator==(monostate /*l*/, monostate /*r*/) noexcept -> bool
20 {
21 return true;
22 }
23
24 /// \brief All instances of etl::monostate compare equal.
25 [[nodiscard]] friend constexpr auto operator<=>(monostate /*l*/, monostate /*r*/) noexcept -> etl::strong_ordering
26 {
28 }
29};
30
31} // namespace etl
32
33#endif // TETL_VARIANT_MONOSTATE_HPP
Definition adjacent_find.hpp:9
Unit type intended for use as a well-behaved empty alternative in etl::variant. In particular,...
Definition monostate.hpp:17
friend constexpr auto operator==(monostate, monostate) noexcept -> bool
All instances of etl::monostate compare equal.
Definition monostate.hpp:19
friend constexpr auto operator<=>(monostate, monostate) noexcept -> etl::strong_ordering
All instances of etl::monostate compare equal.
Definition monostate.hpp:25
Definition strong_ordering.hpp:15
static strong_ordering const equal
Definition strong_ordering.hpp:17