28 #ifndef BSL_BASIC_ERRC_TYPE_HPP 29 #define BSL_BASIC_ERRC_TYPE_HPP 54 template<
typename T = bsl::
int32, T SUCCESS = 0>
169 [[nodiscard]] constexpr
bool 172 return m_errc == SUCCESS;
186 [[nodiscard]] constexpr
bool 189 return m_errc != SUCCESS;
203 [[nodiscard]] constexpr
bool 220 [[nodiscard]] constexpr
bool 237 [[nodiscard]] constexpr bsl::string_view
message() const noexcept;
254 template<typename T1, T1 SUCCESS1, typename T2, T2 SUCCESS2>
259 return lhs.get() == rhs.get();
272 template<
typename T1, T1 SUCCESS1,
typename T2, T2 SUCCESS2>
277 return !(lhs == rhs);
334 template<
typename T, T SUCCESS>
335 [[nodiscard]] constexpr bsl::string_view
338 bsl::string_view msg{};
347 msg =
"general failure";
352 msg =
"general precondition failure";
357 msg =
"general postcondition failure";
362 msg =
"general assertion failure";
367 msg =
"invalid argument (precondition) failure";
372 msg =
"index out of bounds (precondition) failure";
377 msg =
"function not callable (precondition) failure";
382 msg =
"unsigned wrap (assertion) failure";
387 msg =
"narrow overflow (assertion) failure";
392 msg =
"signed overflow (assertion) failure";
397 msg =
"divide by zero (assertion) failure";
402 msg =
"null dereference (assertion) failure";
constexpr basic_errc_type errc_index_out_of_bounds
Defines an out of bounds error code.
Definition: basic_errc_type.hpp:301
constexpr const_reference_type get() const noexcept
Returns the integer value that represents the error code. Normally, this function should not be used,...
Definition: basic_errc_type.hpp:153
T const & const_reference_type
alias for: T const &
Definition: basic_errc_type.hpp:63
constexpr bool success() const noexcept
Returns true if the error code contains SUCCESS, otherwise, if the error code contains an error code,...
Definition: basic_errc_type.hpp:170
constexpr basic_errc_type errc_narrow_overflow
Defines an overflow, underflow or unsigned wrap error.
Definition: basic_errc_type.hpp:308
constexpr basic_errc_type errc_bad_function
Defines an out of bounds error code.
Definition: basic_errc_type.hpp:303
constexpr bool is_unchecked() const noexcept
Returns true if the error code is an unchecked error (i.e., that is the error code is positive),...
Definition: basic_errc_type.hpp:221
constexpr basic_errc_type errc_signed_overflow
Defines an overflow, underflow or unsigned wrap error.
Definition: basic_errc_type.hpp:310
constexpr basic_errc_type errc_failure
Defines the general unchecked error case.
Definition: basic_errc_type.hpp:290
~basic_errc_type() noexcept=default
Destroyes a previously created bsl::basic_errc_type.
Defines an error code. We do not use the same pattern as the standard library. The goal is to ensure ...
Definition: basic_errc_type.hpp:55
T value_type
alias for: T
Definition: basic_errc_type.hpp:59
constexpr bsl::string_view message() const noexcept
Returns a human readable version of the error code. If the error code is a custom,...
Definition: basic_errc_type.hpp:336
T & reference_type
alias for: T &
Definition: basic_errc_type.hpp:61
constexpr basic_errc_type errc_postcondition
Defines the general postcondition error case.
Definition: basic_errc_type.hpp:294
constexpr basic_errc_type errc_success
Defines the "no error" case.
Definition: basic_errc_type.hpp:288
constexpr basic_errc_type errc_divide_by_zero
Defines a divide by zero error.
Definition: basic_errc_type.hpp:312
constexpr basic_errc_type(value_type const &errc=SUCCESS) noexcept
Value initialization constructor.
Definition: basic_errc_type.hpp:80
constexpr basic_errc_type errc_unsigned_wrap
Defines an overflow, underflow or unsigned wrap error.
Definition: basic_errc_type.hpp:306
constexpr basic_errc_type errc_invalid_argument
Defines an invalid argument error code.
Definition: basic_errc_type.hpp:299
constexpr basic_errc_type errc_precondition
Defines the general precondition error case.
Definition: basic_errc_type.hpp:292
constexpr bool operator!=(basic_errc_type< T1, SUCCESS1 > const &lhs, basic_errc_type< T2, SUCCESS2 > const &rhs) noexcept
Returns false if the lhs is equal to the rhs, true otherwise.
Definition: basic_errc_type.hpp:274
constexpr bool is_checked() const noexcept
Returns true if the error code is a checked error (i.e., that is the error code is negative),...
Definition: basic_errc_type.hpp:204
constexpr basic_errc_type errc_nullptr_dereference
Defines an out of bounds error code.
Definition: basic_errc_type.hpp:314
constexpr basic_errc_type errc_assetion
Defines the general assertion error case.
Definition: basic_errc_type.hpp:296
constexpr bool failure() const noexcept
Returns true if the error code contains an error code, otherwise, if the error code contains SUCCESS,...
Definition: basic_errc_type.hpp:187