2#ifndef LIBSBX_UTILITY_PRIMITIVE_HPP_
3#define LIBSBX_UTILITY_PRIMITIVE_HPP_
10#include <libsbx/utility/string_literal.hpp>
12namespace sbx::utility {
14template<
typename Type,
string_literal Unit>
15requires (std::is_arithmetic_v<Type>)
20 using value_type = Type;
22 inline static constexpr auto unit = Unit;
24 constexpr explicit primitive(Type value =
static_cast<value_type
>(0)) noexcept
29 constexpr operator Type()
const noexcept {
41template<
typename Type, sbx::utility::
string_literal Unit>
42struct fmt::formatter<sbx::utility::primitive<Type, Unit>> {
44 template<
typename ParseContext>
45 constexpr auto parse(ParseContext& context) ->
decltype(context.begin()) {
46 return context.begin();
49 template<
typename FormatContext>
51 return fmt::format_to(context.out(),
"{}{}",
static_cast<Type
>(value), Unit);
Definition: primitive.hpp:16