SI  2.5.4
A header only c++ library that provides type safety and user defined literals for handling physical values defined in the International System of Units.
Namespaces | Classes | Typedefs | Functions | Variables
SI::detail Namespace Reference

Namespace containing implementation details for SI. More...

Namespaces

 parsing
 

Classes

struct  unit_t
 base template class for holding values of type _type to be multiplied with a ratio _ratio More...
 
struct  is_ratio
 to check if a template is an instantiation of std::ratio More...
 
struct  is_ratio< std::ratio< _num, _den > >
 
struct  ratio_gcd
 calculate gcd for rations More...
 
struct  is_unit_t
 
struct  is_unit_t< const unit_t< _symbol, _exponent, _type, _ratio > >
 template specialization to check if a type is a unit_t (true if unit_t) More...
 
struct  is_unit_t< unit_t< _symbol, _exponent, _type, _ratio > >
 non-const specialization of check above More...
 
struct  unit_with_common_ratio
 
struct  unit_symbol_impl
 Compile time string provider for conversion of unit types to strings. More...
 
struct  ratio_prefix
 base template for ratio prefix, unusable More...
 
struct  ratio_prefix< std::atto >
 
struct  ratio_prefix< std::femto >
 
struct  ratio_prefix< std::pico >
 
struct  ratio_prefix< std::nano >
 
struct  ratio_prefix< std::micro >
 
struct  ratio_prefix< std::milli >
 
struct  ratio_prefix< std::centi >
 
struct  ratio_prefix< std::kilo >
 
struct  ratio_prefix< std::mega >
 
struct  ratio_prefix< std::giga >
 
struct  ratio_prefix< std::tera >
 
struct  ratio_prefix< std::peta >
 
struct  ratio_prefix< std::exa >
 

Typedefs

template<typename _exponent , typename _type , typename _ratio >
using time_base_t = detail::unit_t< 'T', _exponent, _type, _ratio >
 

Functions

template<template< typename... > typename _resulting_unit, typename _unit_lhs , typename _unit_rhs >
constexpr auto cross_unit_divide (const _unit_lhs &lhs, const _unit_rhs &rhs)
 
template<template< typename... > typename _resulting_unit, typename _unit_lhs , typename _unit_rhs >
constexpr auto cross_unit_multiply (const _unit_lhs &lhs, const _unit_rhs &rhs)
 
template<typename T , std::enable_if_t< std::is_floating_point_v< T >> * = nullptr>
constexpr bool eps_equals (const T &lhs, const T &rhs)
 
template<typename _type , char _symbol, typename _exponent , typename _rhs_type , typename _ratio , std::enable_if_t< std::is_integral_v< _type >> * = nullptr>
constexpr auto operator/ (const _type &lhs, const unit_t< _symbol, _exponent, _rhs_type, _ratio > &rhs)
 
template<typename _target_type , typename _rhs_T >
constexpr auto unit_cast (const _rhs_T &rhs)
 function to cast between two units of the same type More...
 
 BUILD_UNIT_FROM_DIVISION (electric_conductance_t, electric_current_t, electric_potential_t) template< typename _type
 

Variables

template<typename _type >
constexpr bool is_ratio_v = is_ratio<_type>::value
 
template<typename _type >
constexpr bool is_unit_t_v = is_unit_t<_type>::value
 

Detailed Description

Namespace containing implementation details for SI.

Namespace containing all SI units.

This file is part of "SI" version 2.5.4 A header only c++ library that provides type safety and user defined literals for handling physical values defined in the International System of Units

https://github.com/bernedom/SI

SPDX-License-Identifier: MIT

Typedef Documentation

◆ time_base_t

template<typename _exponent , typename _type , typename _ratio >
using SI::detail::time_base_t = typedef detail::unit_t<'T', _exponent, _type, _ratio>

Function Documentation

◆ BUILD_UNIT_FROM_DIVISION()

SI::detail::BUILD_UNIT_FROM_DIVISION ( electric_conductance_t  ,
electric_current_t  ,
electric_potential_t   
)

Builds conductance from 1/resistance, to avoid include cycles the base unit_t is used instead of the type alias electric_resistance_t

Builds conductance from 1/conductance, to avoid include cycles the base unit_t is used instead of the type alias electric_conductance_t

◆ cross_unit_divide()

template<template< typename... > typename _resulting_unit, typename _unit_lhs , typename _unit_rhs >
constexpr auto SI::detail::cross_unit_divide ( const _unit_lhs &  lhs,
const _unit_rhs &  rhs 
)
constexpr

divide a value of a certain unit with another value of a possibly different type resulting in a new type, the resulting exponent is specified by resulting unit using a variadic template to simplify usage of implementation the internal type of the result is the internal type of lhs

◆ cross_unit_multiply()

template<template< typename... > typename _resulting_unit, typename _unit_lhs , typename _unit_rhs >
constexpr auto SI::detail::cross_unit_multiply ( const _unit_lhs &  lhs,
const _unit_rhs &  rhs 
)
constexpr

multiply a value of a unit with another value of a possibly different value resulting in a value of a new type with exponent 1 the internal type of the result is the internal type of lhs

Todo:
add function that works with variable exponent units and remove special typedefs for time

◆ eps_equals()

template<typename T , std::enable_if_t< std::is_floating_point_v< T >> * = nullptr>
constexpr bool SI::detail::eps_equals ( const T &  lhs,
const T &  rhs 
)
constexpr
Todo:
make eps_equal take different types with similar properties

◆ operator/()

template<typename _type , char _symbol, typename _exponent , typename _rhs_type , typename _ratio , std::enable_if_t< std::is_integral_v< _type >> * = nullptr>
constexpr auto SI::detail::operator/ ( const _type &  lhs,
const unit_t< _symbol, _exponent, _rhs_type, _ratio > &  rhs 
)
constexpr

operator to divide scalar type by unit encapsulating the same type template specialization handling integer types @results unit with negative exponent

operator to divide scalar type by unit encapsulating the same type template specialization for floating point types, to avoid possible loss of precision when adjusting for ratio @results unit with negative exponent

◆ unit_cast()

template<typename _target_type , typename _rhs_T >
constexpr auto SI::detail::unit_cast ( const _rhs_T &  rhs)
constexpr

function to cast between two units of the same type

Variable Documentation

◆ is_ratio_v

template<typename _type >
constexpr bool SI::detail::is_ratio_v = is_ratio<_type>::value
inlineconstexpr

◆ is_unit_t_v

template<typename _type >
constexpr bool SI::detail::is_unit_t_v = is_unit_t<_type>::value
inlineconstexpr