quanta 0.1.0
Type-safe units for temperature, frequency, electrical and spatial quantities, modeled after std::chrono
Loading...
Searching...
No Matches
core.hpp File Reference

Configuration, traits and internals shared by every quanta domain. More...

#include <charconv>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <limits>
#include <ratio>
#include <string>
#include <system_error>
#include <type_traits>
#include <utility>
#include <version>

Go to the source code of this file.

Classes

struct  quanta::treat_as_inexact< T >
 Trait to indicate floating-point-like behavior. More...
 
struct  quanta::base_unit_t
 Tag type selecting the base-unit form, see base_unit. More...
 
struct  quanta::scaled_t
 Tag type selecting the scaled form, see scaled. More...
 

Namespaces

namespace  quanta
 Type-safe units modeled after std::chrono.
 

Macros

#define CONFIG_QUANTA_STD_FORMAT   0
 1 if std::format support (std::formatter specializations) is enabled.
 
#define QUANTA_HAS_UTF8_LITERALS   1
 1 if the compiler accepts non-ASCII literal suffixes (e.g.
 

Variables

template<typename T >
constexpr bool quanta::treat_as_inexact_v = treat_as_inexact<T>::value
 
constexpr base_unit_t quanta::base_unit {}
 Selects the base-unit form in to_string().
 
constexpr scaled_t quanta::scaled {}
 Selects the scaled form in to_string().
 

Detailed Description

Configuration, traits and internals shared by every quanta domain.

Included by each domain header; there is no need to include it directly.

Definition in file core.hpp.

Macro Definition Documentation

◆ CONFIG_QUANTA_STD_FORMAT

#define CONFIG_QUANTA_STD_FORMAT   0

1 if std::format support (std::formatter specializations) is enabled.

Defaults to 1 when <format> is available, and may be defined to 0 before including any quanta header to disable it. When quanta is used as an ESP-IDF component, the QUANTA_STD_FORMAT_SUPPORT Kconfig option controls it: enabled, std::format is supported where the toolchain provides <format>; disabled, the component's build defines this to 0.

Definition at line 36 of file core.hpp.

◆ QUANTA_HAS_UTF8_LITERALS

#define QUANTA_HAS_UTF8_LITERALS   1

1 if the compiler accepts non-ASCII literal suffixes (e.g.

_Ω).

GCC before 14 (including the ESP-IDF toolchains before GCC 14) cannot lex extended characters in user-defined literal suffixes, so those literals are omitted there. Each has an ASCII alternative that is always available:

  • thermo: _Δc, _Δmc, _Δk, _Δmk, _Δf, _Δmf → _delta_c, _delta_mc, _delta_k, _delta_mk, _delta_f, _delta_mf
  • electro: _mΩ, _Ω, _kΩ, _MΩ, _dBµV → _mOhm, _Ohm, _kOhm, _MOhm, _dBuV
  • spatial: _µm, _µL → _um, _uL

Definition at line 74 of file core.hpp.