Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. Data structures & utilities
  5. pw_result
  6. pw::HasValue Class Reference
pw::HasValue Class Referencefinal

Overview

Status type used by pw::Optional<T> (pw::Result<T, pw::HasValue>) to indicate whether a value is present (ok() == true).

Inheritance diagram for pw::HasValue:
pw::StatusBase< HasValue, internal_result::HasValueCode::kHasValue, StatusMessages::kDisabled >

Public Member Functions

constexpr HasValue () noexcept=default
 
constexpr HasValue (Code code) noexcept
 
- Public Member Functions inherited from pw::StatusBase< HasValue, internal_result::HasValueCode::kHasValue, StatusMessages::kDisabled >
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 (HasValue other) noexcept
 
constexpr void IgnoreError () const noexcept
 Ignores any errors, suppressing unused-result warnings.
 
constexpr const char * str () const
 

Static Public Attributes

static constexpr Code kEmpty = Code::kEmpty
 
static constexpr Code kHasValue = Code::kHasValue
 

Additional Inherited Members

- Public Types inherited from pw::StatusBase< HasValue, internal_result::HasValueCode::kHasValue, StatusMessages::kDisabled >
using Code = decltype(kOkCode)
 The underlying status code type.
 
- Protected Member Functions inherited from pw::StatusBase< HasValue, internal_result::HasValueCode::kHasValue, StatusMessages::kDisabled >
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 (StatusBase &&)=default
 
constexpr StatusBase & operator= (const StatusBase &)=default
 
constexpr StatusBase & operator= (StatusBase &&)=default
 

Constructor & Destructor Documentation

◆ HasValue() [1/2]

constexpr pw::HasValue::HasValue ( )
constexprdefaultnoexcept

Constructs a HasValue status indicating that a value is present (ok() == true).

◆ HasValue() [2/2]

constexpr pw::HasValue::HasValue ( Code  code)
inlineexplicitconstexprnoexcept

Explicitly constructs a HasValue status from HasValue::kEmpty or HasValue::kHasValue.


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