forked from mpusz/mp-units
Unit specific concepts introduced
This commit is contained in:
@@ -25,11 +25,11 @@
|
|||||||
|
|
||||||
using namespace units;
|
using namespace units;
|
||||||
|
|
||||||
template<Unit U1, typename Rep1, Unit U2, typename Rep2>
|
template<typename V, typename T>
|
||||||
void foo(velocity<U1, Rep1> v, time<U2, Rep2> t)
|
requires Velocity<V> && Time<T>
|
||||||
|
void foo(V v, T t)
|
||||||
{
|
{
|
||||||
const auto distance = v * t;
|
const auto distance = v * t;
|
||||||
|
|
||||||
std::cout << "A car driving " << v.count() << " km/h in a time of " << t.count() << " minutes will pass "
|
std::cout << "A car driving " << v.count() << " km/h in a time of " << t.count() << " minutes will pass "
|
||||||
<< quantity_cast<length<meter, int>>(distance).count() << " meters.\n";
|
<< quantity_cast<length<meter, int>>(distance).count() << " meters.\n";
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,19 @@ namespace units {
|
|||||||
template<Unit U = hertz, typename Rep = std::intmax_t>
|
template<Unit U = hertz, typename Rep = std::intmax_t>
|
||||||
using frequency = quantity<dimension_frequency, U, Rep>;
|
using frequency = quantity<dimension_frequency, U, Rep>;
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct is_frequency : std::false_type {};
|
||||||
|
|
||||||
|
template<Unit U, typename Rep>
|
||||||
|
struct is_frequency<frequency<U, Rep>> : std::true_type {};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
concept bool Frequency = detail::is_frequency<T>::value;
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
namespace literals {
|
namespace literals {
|
||||||
|
@@ -36,6 +36,19 @@ namespace units {
|
|||||||
template<Unit U = meter, typename Rep = std::intmax_t>
|
template<Unit U = meter, typename Rep = std::intmax_t>
|
||||||
using length = quantity<dimension_length, U, Rep>;
|
using length = quantity<dimension_length, U, Rep>;
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct is_length : std::false_type {};
|
||||||
|
|
||||||
|
template<Unit U, typename Rep>
|
||||||
|
struct is_length<length<U, Rep>> : std::true_type {};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
concept bool Length = detail::is_length<T>::value;
|
||||||
|
|
||||||
namespace literals {
|
namespace literals {
|
||||||
|
|
||||||
// mm
|
// mm
|
||||||
|
@@ -39,6 +39,19 @@ namespace units {
|
|||||||
template<Unit U = second, typename Rep = std::intmax_t>
|
template<Unit U = second, typename Rep = std::intmax_t>
|
||||||
using time = quantity<dimension_time, U, Rep>;
|
using time = quantity<dimension_time, U, Rep>;
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct is_time : std::false_type {};
|
||||||
|
|
||||||
|
template<Unit U, typename Rep>
|
||||||
|
struct is_time<time<U, Rep>> : std::true_type {};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
concept bool Time = detail::is_time<T>::value;
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
namespace literals {
|
namespace literals {
|
||||||
|
@@ -37,6 +37,19 @@ namespace units {
|
|||||||
template<Unit U = meter_per_second, typename Rep = std::intmax_t>
|
template<Unit U = meter_per_second, typename Rep = std::intmax_t>
|
||||||
using velocity = quantity<dimension_velocity, U, Rep>;
|
using velocity = quantity<dimension_velocity, U, Rep>;
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct is_velocity : std::false_type {};
|
||||||
|
|
||||||
|
template<Unit U, typename Rep>
|
||||||
|
struct is_velocity<velocity<U, Rep>> : std::true_type {};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
concept bool Velocity = detail::is_velocity<T>::value;
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
namespace literals {
|
namespace literals {
|
||||||
|
Reference in New Issue
Block a user