Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. Data structures & utilities
  5. pw_status
  6. pw::StatusOf< kOkCode, kMessages > Class Template Reference
pw::StatusOf< kOkCode, kMessages > Class Template Referencefinal

Overview

template<auto kOkCode, StatusMessages kMessages = StatusMessages::kDefault>
class pw::StatusOf< kOkCode, kMessages >

Status type wrapping an existing status code enum.

StatusOf is default constructible (OK), explicitly constructible from the enum, and constructible from (Code, Message) using PW_STATUS_MSG("..."). Enumerators are accessed through the enum type or the Code alias (e.g. MyStatus::Code::kFailed).

Users typically create a type alias of StatusOf for their status code enum (e.g. using MyStatus = pw::StatusOf<MyCode::kOk>;).

Template Parameters
kOkCodeEnumerator that represents success (ok() == true).
kMessagesPass StatusMessages::kDisabled for a status that never carries a message.
Inheritance diagram for pw::StatusOf< kOkCode, kMessages >:
pw::StatusBase< Derived, kOkCode, kMessages >

Public Types

using Code = decltype(kOkCode)
 The underlying status code type.
 
- Public Types inherited from pw::StatusBase< Derived, kOkCode, kMessages >
using Code = decltype(kOkCode)
 The underlying status code type.
 

Public Member Functions

constexpr StatusOf (Code code) noexcept
 
constexpr StatusOf (Code code, Message message) noexcept
 
- Public Member Functions inherited from pw::StatusBase< Derived, kOkCode, kMessages >
constexpr bool ok () const noexcept
 Returns true if the status is the OK code.
 
constexpr Code code () const noexcept
 Returns the underlying status code.
 
constexpr bool has_message () const noexcept
 
constexpr Message message () const noexcept
 
constexpr void Update (Derived other) noexcept
 
constexpr void IgnoreError () const noexcept
 Ignores any errors, suppressing unused-result warnings.
 
constexpr const char * str () const
 

Additional Inherited Members

- Protected Member Functions inherited from pw::StatusBase< Derived, kOkCode, kMessages >
constexpr StatusBase () noexcept=default
 Defaults to kOkCode (ok() == true).
 
constexpr StatusBase (Code code) noexcept
 Explicitly construct from the underlying code.
 
constexpr StatusBase (Code code, Message message) noexcept
 
constexpr StatusBase (const StatusBase &)=default
 
constexpr StatusBase & operator= (const StatusBase &)=default
 
constexpr StatusBase (StatusBase &&)=default
 
constexpr StatusBase & operator= (StatusBase &&)=default
 

The documentation for this class was generated from the following file: