value-preserving-literals 0.0.1
value-preserving literals for C++
Loading...
Searching...
No Matches
vir Namespace Reference

Classes

class  bad_value_preserving_cast
 Exception thrown when conversion to arithmetic type would change value. More...
struct  constinteger
 Untyped integer literal type. More...
struct  constreal
 Untyped real literal type. More...

Functions

consteval constinteger operator""_val (unsigned long long __x) noexcept
 User-defined literal for untyped constants.
consteval constinteger val (unsigned_integral auto __x) noexcept
 Create untyped constant from typed value / constant expression.
consteval constinteger val (signed_integral auto __x) noexcept
 Create untyped constant from typed value / constant expression.
consteval constreal operator""_val (long double __x) noexcept
 User-defined literal for untyped constants.
consteval constreal val (long double __x) noexcept
 Create untyped constant from typed value / constant expression.

Detailed Description

Note
Do not import the complete namespace into your namespace. For using the user-defined literal do using vir::operator""_val; and never using namespace vir;.

Function Documentation

◆ operator""_val() [1/2]

constinteger vir::operator""_val ( unsigned long long __x)
constevalnoexcept

User-defined literal for untyped constants.

Creates a constinteger from a literal interpreted as unsigned long long.

Parameters
__xThe literal value
Returns
constinteger Value-preserving integer constant

◆ val() [1/3]

constinteger vir::val ( unsigned_integral auto __x)
constevalnoexcept

Create untyped constant from typed value / constant expression.

Parameters
__xUnsigned integral value
Returns
constinteger Value-preserving integer constant

◆ val() [2/3]

constinteger vir::val ( signed_integral auto __x)
constevalnoexcept

Create untyped constant from typed value / constant expression.

Parameters
__xSigned integral value
Returns
constinteger Value-preserving integer constant

◆ operator""_val() [2/2]

constreal vir::operator""_val ( long double __x)
constevalnoexcept

User-defined literal for untyped constants.

Creates a constreal from a literal interpreted as long double.

Parameters
__xThe literal value
Returns
constreal Value-preserving real constant

◆ val() [3/3]

constreal vir::val ( long double __x)
constevalnoexcept

Create untyped constant from typed value / constant expression.

Parameters
__xFloating-point value
Returns
constreal Value-preserving real constant