1#ifndef LIBSBX_UTILITY_PRIMITIVE_HPP_
2#define LIBSBX_UTILITY_PRIMITIVE_HPP_
9#include <libsbx/utility/string_literal.hpp>
11namespace sbx::utility {
13template<
typename Type,
string_literal Unit>
14requires (std::is_arithmetic_v<Type>)
19 using value_type = Type;
21 inline static constexpr auto unit = Unit;
23 constexpr explicit primitive(Type value =
static_cast<value_type
>(0)) noexcept
28 constexpr operator Type()
const noexcept {
40template<
typename Type, sbx::utility::
string_literal Unit>
41struct fmt::formatter<sbx::utility::primitive<Type, Unit>> {
43 template<
typename ParseContext>
44 constexpr auto parse(ParseContext& context) ->
decltype(context.begin()) {
45 return context.begin();
48 template<
typename FormatContext>
50 return fmt::format_to(context.out(),
"{}{}",
static_cast<Type
>(value), Unit);
Definition: primitive.hpp:15