micro-test-plus 6.0.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::detail::named_bool Struct Reference

Struct representing a named boolean constant, created by the _b literal. More...

#include "micro-os-plus/micro-test-plus.h"

Inheritance diagram for micro_os_plus::micro_test_plus::detail::named_bool:

Public Types

using op_type = op
 Marker identifying the framework expression types.
using value_type = bool
 The type of the value.

Public Member Functions

constexpr named_bool (std::string_view name) noexcept
 Constructs a named boolean constant with the given name.
constexpr std::string_view name (void) const noexcept
 Returns the name of the constant.
constexpr operator value_type () const noexcept
 Conversion operator to bool.

Private Attributes

std::string_view name_
 The name of the constant.

Detailed Description

The named_bool struct holds the constant true, together with a name, which the expression formatter prints instead of the value, so that a failed comparison like "flag"_b == flag, with the operators in the operators namespace, is reported as flag == false.

The value is available only via the implicit conversion to bool, and the struct has neither a get() accessor nor comparison operators. Thus detail::unwrap() returns the object itself, so that the formatter receives the name, the comparators compare it as the bool value true, and the generic operators in the operators namespace, not a better matching operator of this struct, are selected for it.

The name is not owned; it refers to the string literal, which has static storage duration.

Definition at line 743 of file deprecated.h.

Member Typedef Documentation

◆ op_type

Detected by the extension::is_op concept, and inherited by all types derived from op.

Definition at line 128 of file extension.h.

◆ value_type

The named literal behaves as a boolean value.

Definition at line 751 of file deprecated.h.

Constructor & Destructor Documentation

◆ named_bool()

micro_os_plus::micro_test_plus::detail::named_bool::named_bool ( std::string_view name)
explicitconstexprnoexcept
Parameters
nameThe name, printed in place of the value.

Stores the view of the name; the characters are not copied.

Definition at line 647 of file deprecated-inlines.h.

648 : name_{ name }
649 {
650 }
constexpr std::string_view name(void) const noexcept
Returns the name of the constant.
std::string_view name_
The name of the constant.
Definition deprecated.h:787

References name(), and name_.

Member Function Documentation

◆ name()

std::string_view micro_os_plus::micro_test_plus::detail::named_bool::name ( void ) const
nodiscardconstexprnoexcept
Parameters
None.
Returns
The name passed to the constructor.

Returns the stored view of the name.

Definition at line 667 of file deprecated-inlines.h.

668 {
669 return name_;
670 }

References name_.

Referenced by named_bool(), and micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<().

◆ operator value_type()

micro_os_plus::micro_test_plus::detail::named_bool::operator value_type ( ) const
nodiscardconstexprnoexcept
Parameters
None.
Returns
true.

Always returns true, the value of all named boolean constants.

Definition at line 656 of file deprecated-inlines.h.

658 {
659 return true;
660 }

Member Data Documentation

◆ name_

std::string_view micro_os_plus::micro_test_plus::detail::named_bool::name_
private

Not owned; refers to the characters of the string literal.

Definition at line 787 of file deprecated.h.

Referenced by named_bool(), and name().


The documentation for this struct was generated from the following files: