dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
Literals.hpp File Reference

Fixed-width integer user-defined literals. More...

Include dependency graph for Literals.hpp:

Go to the source code of this file.

Namespaces

namespace  dfx::Utils::literals
 Namespace containing fixed-width integer literal operators.

Functions

constexpr int8_t dfx::Utils::literals::operator""_i8 (unsigned long long int val) noexcept
 Convert an unsigned literal to int8_t.
constexpr int16_t dfx::Utils::literals::operator""_i16 (unsigned long long int val) noexcept
 Convert an unsigned literal to int16_t.
constexpr int32_t dfx::Utils::literals::operator""_i32 (unsigned long long int val) noexcept
 Convert an unsigned literal to int32_t.
constexpr int64_t dfx::Utils::literals::operator""_i64 (unsigned long long int val) noexcept
 Convert an unsigned literal to int64_t.
constexpr uint8_t dfx::Utils::literals::operator""_u8 (unsigned long long int val) noexcept
 Convert an unsigned literal to uint8_t.
constexpr uint16_t dfx::Utils::literals::operator""_u16 (unsigned long long int val) noexcept
 Convert an unsigned literal to uint16_t.
constexpr uint32_t dfx::Utils::literals::operator""_u32 (unsigned long long int val) noexcept
 Convert an unsigned literal to uint32_t.
constexpr uint64_t dfx::Utils::literals::operator""_u64 (unsigned long long int val) noexcept
 Convert an unsigned literal to uint64_t.

Detailed Description

Fixed-width integer user-defined literals.

This header provides a small set of user-defined literal (UDL) suffixes to explicitly spell fixed-width integer types at the call site.

Typical usage:

using namespace dfx::Utils::literals;
auto a = 42_u8; // uint8_t
auto b = 123_i16; // int16_t
auto c = 1_u64; // uint64_t
Fixed-width integer user-defined literals.
Namespace containing fixed-width integer literal operators.
Warning
These literals perform a plain static_cast<T> from unsigned long long to the destination type:
  • If the value is not representable in an unsigned destination type, the result is reduced modulo 2^N (well-defined).
  • If the value is not representable in a signed destination type, the result is implementation-defined.

In other words: these literals do not validate ranges at compile time. They are convenience casts, not safe parsers.