wuzp
Wrong Unit? Zero Points! Compile-time checks for units, coordinate systems and points vs. vectors.
Toggle main menu visibility
Loading...
Searching...
No Matches
Unit.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <type_traits>
4
5
#include "
wuzp/core/traits.hpp
"
6
7
namespace
wuzp
{
8
9
template
<
typename
ImplementationT_>
10
struct
Unit
{
11
using
ImplementationT
= ImplementationT_;
12
};
13
14
// The sum and the difference of quantities only exist if their units match. Every units backend gives equal units the same type
15
// (see UnitSystem in concepts.hpp), so the core compares them by their types, for every units backend.
16
template
<
typename
ImplementationLhsT_,
typename
ImplementationRhsT_>
17
struct
Sum<
Unit
<ImplementationLhsT_>,
Unit
<ImplementationRhsT_>> {
18
static_assert
(std::is_same_v<ImplementationLhsT_, ImplementationRhsT_>,
"Units do not match."
);
19
using
type
=
Unit<ImplementationLhsT_>
;
20
};
21
22
template
<
typename
ImplementationLhsT_,
typename
ImplementationRhsT_>
23
struct
Difference<
Unit
<ImplementationLhsT_>,
Unit
<ImplementationRhsT_>> {
24
static_assert
(std::is_same_v<ImplementationLhsT_, ImplementationRhsT_>,
"Units do not match."
);
25
using
type
=
Unit<ImplementationLhsT_>
;
26
};
27
28
}
// namespace wuzp
traits.hpp
wuzp
Definition
Absolute.hpp:15
wuzp::Difference< Unit< ImplementationLhsT_ >, Unit< ImplementationRhsT_ > >::type
Unit< ImplementationLhsT_ > type
Definition
Unit.hpp:25
wuzp::Sum< Unit< ImplementationLhsT_ >, Unit< ImplementationRhsT_ > >::type
Unit< ImplementationLhsT_ > type
Definition
Unit.hpp:19
wuzp::Unit
Definition
Unit.hpp:10
wuzp::Unit::ImplementationT
ImplementationT_ ImplementationT
Definition
Unit.hpp:11
wuzp
include
wuzp
core
Unit.hpp
Generated by
1.18.0