integral_constant Struct Template
Struct template representing a generic integral constant. More...
Declaration
struct micro_os_plus::micro_test_plus::detail::integral_constant<N> { ... }
Included Headers
Base struct
| struct | value_base<T> |
|
Base struct template providing common storage and accessors for run-time value-wrapper types. More... | |
Public Member Typedefs Index
template <auto N> | |
| using | op_type = op |
|
Marker identifying the framework expression types. More... | |
template <auto N> | |
| using | value_type = decltype(N) |
|
The type of the stored value. More... | |
Public Constructors Index
template <auto N> | |
| constexpr | integral_constant (void) noexcept |
|
Default constructor. More... | |
Public Operators Index
template <auto N> | |
| constexpr | operator decltype(N) () const noexcept |
|
Explicit conversion operator to the underlying value type. More... | |
template <auto N> | |
| constexpr auto | operator- () const noexcept |
|
Unary minus operator. More... | |
Public Member Functions Index
template <auto N> | |
| constexpr auto | get (void) const noexcept -> const decltype(N) & |
|
Getter for the stored value. More... | |
Private Member Attributes Index
template <auto N> | |
| decltype(N) | value_ |
|
The stored value. More... | |
Public Static Attributes Index
template <auto N> | |
| static constexpr auto | value = N |
|
The compile-time constant value. More... | |
Description
Struct template representing a generic integral constant.
- Template Parameters
-
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.
Public Member Typedefs
op_type
|
Marker identifying the framework expression types.
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.
value_type
|
The type of the stored value.
Exposed for use by generic code that inspects wrapper types.
Definition at line 368 of file deprecated.h.
Public Constructors
integral_constant()
| constexpr noexcept |
Default constructor.
Initialises the base with N.
Delegates to value_base<decltype(N)>{ N } to initialise the base.
Declaration at line 446 of file deprecated.h, definition at line 516 of file deprecated-inlines.h.
Reference 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 micro_os_plus::micro_test_plus::detail::integral_constant< N >::operator-.
Public Operators
operator decltype(N)()
| explicit nodiscard constexpr noexcept |
Explicit conversion operator to the underlying value type.
- Returns
The stored value as type T.
Allows explicit conversion to the encapsulated value.
Declaration at line 383 of file deprecated.h, definition at line 492 of file deprecated-inlines.h.
operator-()
| nodiscard constexpr noexcept |
Unary minus operator.
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.
- Returns
An integral_constant with value -N, converted to the type of N.
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.
Declaration at line 462 of file deprecated.h, definition at line 532 of file deprecated-inlines.h.
Reference micro_os_plus::micro_test_plus::detail::integral_constant< N >::integral_constant.
Public Member Functions
get()
| nodiscard constexpr noexcept |
Getter for the stored value.
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.
- Parameters
None.
- Returns
A reference to the stored value.
Returns a const reference to the stored value, valid as long as the wrapper.
Declaration at line 398 of file deprecated.h, definition at line 504 of file deprecated-inlines.h.
Private Member Attributes
value_
|
The stored value.
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.
Public Static Attributes
value
| constexpr static |
The compile-time constant value.
Equal to N; also available at run time via get().
Definition at line 438 of file deprecated.h.
The documentation for this struct was generated from the following files:
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.