value-preserving-literals 0.0.1
value-preserving literals for C++
Loading...
Searching...
No Matches
vir::constinteger Struct Reference

Untyped integer literal type. More...

#include <val.h>

Public Member Functions

template<__arithmetic _Up>
consteval operator _Up () const
 Conversion operator to arithmetic types.

Friends

consteval constinteger operator- (constinteger __v) noexcept
 Unary negation operator.
consteval constinteger operator+ (constinteger __v) noexcept
 Unary plus operator (identity)
consteval constinteger operator~ (constinteger)=delete("complement cannot be applied to value of unspecified width")
 Bitwise complement operator (deleted)
consteval constinteger operator! (constinteger)=delete("explicitly write 1 or 0 instead")
 Logical NOT operator (deleted)

Detailed Description

Untyped integer literal type.

Represents an integer value with up to the precision of unsigned long long.

Conversions to arithmetic types are only allowed when they are value-preserving. Otherwise, bad_value_preserving_cast is thrown.

Member Function Documentation

◆ operator _Up()

template<__arithmetic _Up>
vir::constinteger::operator _Up ( ) const
inlineconsteval

Conversion operator to arithmetic types.

Converts to the target type only if the conversion is value-preserving. Checks that the value fits within the target range and can be exactly represented without precision loss.

Template Parameters
_UpTarget arithmetic type
Returns
_Up Converted value
Exceptions
bad_value_preserving_castif conversion is not value-preserving

◆ operator-

constinteger operator- ( constinteger __v)
friend

Unary negation operator.

Note
C++ only knows about positive literals. Subsequent unary minus produces a negative value.

◆ operator+

constinteger operator+ ( constinteger __v)
friend

Unary plus operator (identity)

Note
Provided for completeness. (Useless.)

◆ operator~

constinteger operator~ ( constinteger )
friend

Bitwise complement operator (deleted)

Cannot be applied because the width is unspecified.

◆ operator!

constinteger operator! ( constinteger )
friend

Logical NOT operator (deleted)

Explicitly write 1 or 0 instead.


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