|
micro-test-plus 6.0.0
µTest++ Testing Framework
|
Struct template representing a generic integral constant. More...
#include "micro-os-plus/micro-test-plus.h"
Public Types | |
| using | op_type |
| Marker identifying the framework expression types. | |
| using | value_type |
| The type of the stored value. | |
Public Member Functions | |
| constexpr | integral_constant (void) noexcept |
| Default constructor. | |
| constexpr const decltype(N) & | get (void) const noexcept |
| Getter for the stored value. | |
| constexpr | operator decltype(N) () const noexcept |
| Explicit conversion operator to the underlying value type. | |
| constexpr auto | operator- () const noexcept |
| Unary minus operator. | |
Static Public Attributes | |
| static constexpr auto | value = N |
| The compile-time constant value. | |
Private Attributes | |
| decltype(N) | value_ |
| The stored value. | |
| N | The compile-time constant value. |
The integral_constant struct template provides a compile-time constant value of an integral type, created by the integer literals. It inherits from value_base<decltype(N)>, which supplies the value_type alias, the run-time value storage, the explicit conversion operator, and the get() accessor.
This struct retains the compile-time value constant and provides a unary minus operator to obtain the negative value as a new integral_constant instance, of the same type.
Definition at line 430 of file deprecated.h.
|
inherited |
Declared directly rather than inherited from op, to avoid the empty base; detected by the extension::is_op concept.
Definition at line 360 of file deprecated.h.
|
inherited |
Exposed for use by generic code that inspects wrapper types.
Definition at line 368 of file deprecated.h.
|
constexprnoexcept |
Initialises the base with N.
Delegates to value_base<decltype(N)>{ N } to initialise the base.
Definition at line 516 of file deprecated-inlines.h.
References micro_os_plus::micro_test_plus::detail::value_base< decltype(N)>::value_base().
Referenced by micro_os_plus::micro_test_plus::detail::integral_literal(), and operator-().
|
nodiscardconstexprnoexceptinherited |
Returns a reference, so that a wrapped object (for example a to_t<std::string>) is not copied each time it is compared or formatted.
Returns a const reference to the stored value, valid as long as the wrapper.
Definition at line 398 of file deprecated-inlines.h.
|
explicitnodiscardconstexprnoexceptinherited |
Allows explicit conversion to the encapsulated value.
Definition at line 383 of file deprecated-inlines.h.
|
nodiscardconstexprnoexcept |
The result has the type of N, not the type promoted by the built-in unary minus, so -1_i8 is an int8_t. The negation of an unsigned value wraps around, as for unsigned int in C++ (-1_u8 is 255). The negation of the minimum of a signed type does not fit in the type, so it is a compilation error.
The built-in unary minus promotes the types narrower than int, so its result is converted back to the type of N. For the unsigned types, the value is subtracted from zero, which, after the conversion, gives the value modulo 2^n for all widths. For the signed types, the minimum is rejected before the negation, which would otherwise overflow for int and the wider types.
Definition at line 532 of file deprecated-inlines.h.
References integral_constant().
|
staticconstexpr |
Equal to N; also available at run time via get().
Definition at line 438 of file deprecated.h.
|
privateinherited |
Set by the constructor. Derived wrappers and comparators access it via get() or the explicit conversion operator.
Definition at line 408 of file deprecated.h.