value-preserving-literals 0.0.1
value-preserving literals for C++
Loading...
Searching...
No Matches
val.h File Reference

Value-preserving literal types for C++26. More...

#include <concepts>
#include <exception>
#include <limits>
#include <source_location>
#include <string_view>

Go to the source code of this file.

Classes

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

Namespaces

namespace  vir

Macros

#define vir_lib_val_literal   202601L
 Feature macro for value-preserving literals.

Functions

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

Detailed Description

Value-preserving literal types for C++26.

This header provides user-defined literal to produce untyped values that ensure their value is preserved on conversion to arithmetic type, preventing precision loss and overflow.

Requires C++26.

Macro Definition Documentation

◆ vir_lib_val_literal

#define vir_lib_val_literal   202601L

Feature macro for value-preserving literals.

This is modelled after C++ feature macros.