emlabcpp
modern opinionated embedded C++ library
status.h
Go to the documentation of this file.
1 #pragma once
23 
24 #include <concepts>
25 
26 namespace emlabcpp
27 {
28 
29 template < typename Derived, typename Enum >
30 struct [[nodiscard]] status
31 {
32  using enum_type = Enum;
33 
34  constexpr status( enum_type s ) noexcept
35  : s_( s )
36  {
37  }
38 
39  constexpr status( status const& ) noexcept = default;
40  constexpr status( status&& ) noexcept = default;
41  constexpr status& operator=( status const& ) noexcept = default;
42  constexpr status& operator=( status&& ) noexcept = default;
43 
44  [[nodiscard]] constexpr enum_type value() const noexcept
45  {
46  return s_;
47  }
48 
49  constexpr friend auto
50  operator<=>( status const& lhs, status const& rhs ) noexcept = default;
51 
52 private:
53  enum_type s_;
54 };
55 
56 } // namespace emlabcpp
MIT License.
Definition: impl.h:31
auto operator<=>(static_circular_buffer< T, N > const &lh, static_circular_buffer< T, N > const &rh)
Definition: static_circular_buffer.h:290
Definition: status.h:31
constexpr status(enum_type s) noexcept
Definition: status.h:34
Enum enum_type
Definition: status.h:32
constexpr status(status const &) noexcept=default
constexpr status(status &&) noexcept=default