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

Exception thrown when conversion to arithmetic type would change value. More...

#include <val.h>

Public Member Functions

consteval bad_value_preserving_cast (source_location __where=source_location::current()) noexcept
 Construct with source location.
consteval bad_value_preserving_cast (const bad_value_preserving_cast &)=default
 Defaulted copy constructor.
consteval bad_value_preserving_cast (bad_value_preserving_cast &&)=default
 Defaulted move constructor.
consteval bad_value_preserving_castoperator= (const bad_value_preserving_cast &)=default
 Defaulted copy assignment.
consteval bad_value_preserving_castoperator= (bad_value_preserving_cast &&)=default
 Defaulted move assignment.
consteval const char * what () const noexcept override
 Get error description.
consteval u8string_view u8what () const noexcept
 Get UTF-8 error description.
consteval source_location where () const noexcept
 Get source location of the failed conversion.

Detailed Description

Exception thrown when conversion to arithmetic type would change value.

This exception is thrown at compile time (and can only be caught at compile time) when attempting to convert a constinteger or constreal to an arithmetic type that cannot preserve the exact value (e.g., overflow, precision loss, or range violation).

The type is consteval-only to ensure it can only be used at compile time.

Constructor & Destructor Documentation

◆ bad_value_preserving_cast()

vir::bad_value_preserving_cast::bad_value_preserving_cast ( source_location __where = source_location::current())
inlineconstevalnoexcept

Construct with source location.

Parameters
__whereSource location where the conversion failed

Member Function Documentation

◆ what()

const char * vir::bad_value_preserving_cast::what ( ) const
inlineconstevaloverridenoexcept

Get error description.

Returns
const char* Error message

◆ u8what()

u8string_view vir::bad_value_preserving_cast::u8what ( ) const
inlineconstevalnoexcept

Get UTF-8 error description.

Returns
u8string_view UTF-8 error message

◆ where()

source_location vir::bad_value_preserving_cast::where ( ) const
inlineconstevalnoexcept

Get source location of the failed conversion.

Returns
source_location Where the error occurred

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