forked from mpusz/mp-units
units moved to std::experimental namespace
This commit is contained in:
@@ -51,7 +51,7 @@ Quantity is a concrete amount of a unit for a specified dimension with a specifi
|
||||
|
||||
```cpp
|
||||
units::quantity<units::kilometer, double> d1(123);
|
||||
auto d2 = 123_km; // units::quantity<units::kilometer, std::int64_t>
|
||||
auto d2 = 123_km; // stde::units::quantity<units::kilometer, std::int64_t>
|
||||
```
|
||||
|
||||
There are C++ concepts provided for each such quantity type:
|
||||
@@ -64,7 +64,7 @@ concept Length = Quantity<T> && std::Same<typename T::dimension, dimension_lengt
|
||||
With that we can easily write a function template like this:
|
||||
|
||||
```cpp
|
||||
constexpr units::Velocity auto avg_speed(units::Length auto d, units::Time auto t)
|
||||
constexpr stde::units::Velocity auto avg_speed(units::Length auto d,stde::units::Time auto t)
|
||||
{
|
||||
return d / t;
|
||||
}
|
||||
@@ -316,7 +316,7 @@ could generate a following compile time error:
|
||||
const Velocity auto t = 20_s;
|
||||
^~~~
|
||||
In file included from <path>\example\example.cpp:23:
|
||||
<path>/src/include/units/si/velocity.h:41:16: note: within 'template<class T> concept const bool units::Velocity<T> [with T = units::quantity<units::unit<units::dimension<units::exp<units::base_dim_time, 1> >, std::ratio<1> >, long long int>]'
|
||||
<path>/src/include/units/si/velocity.h:41:16: note: within 'template<class T> concept const bool stde::units::Velocity<T> [with T = stde::units::quantity<units::unit<units::dimension<units::exp<units::base_dim_time, 1> >, std::ratio<1> >, long long int>]'
|
||||
concept Velocity = Quantity<T> && std::Same<typename T::dimension, dimension_velocity>;
|
||||
^~~~~~~~
|
||||
In file included from <path>/src/include/units/bits/tools.h:25,
|
||||
@@ -324,7 +324,7 @@ In file included from <path>/src/include/units/bits/tools.h:25,
|
||||
from <path>/src/include/units/si/base_dimensions.h:25,
|
||||
from <path>/src/include/units/si/velocity.h:25,
|
||||
from <path>\example\example.cpp:23:
|
||||
<path>/src/include/units/bits/stdconcepts.h:33:18: note: within 'template<class T, class U> concept const bool std::Same<T, U> [with T = units::dimension<units::exp<units::base_dim_time, 1> >; U = units::dimension<units::exp<units::base_dim_length, 1>, units::exp<units::base_dim_time, -1> >]'
|
||||
<path>/src/include/units/bits/stdconcepts.h:33:18: note: within 'template<class T, class U> concept const bool std::Same<T, U> [with T = stde::units::dimension<units::exp<units::base_dim_time, 1> >; U = stde::units::dimension<units::exp<units::base_dim_length, 1>,stde::units::exp<units::base_dim_time, -1> >]'
|
||||
concept Same = std::is_same_v<T, U>;
|
||||
^~~~
|
||||
<path>/src/include/units/bits/stdconcepts.h:33:18: note: 'std::is_same_v' evaluated to false
|
||||
@@ -334,13 +334,13 @@ Time and velocity are not that complicated dimensions and there are much more co
|
||||
out there, but even for those dimensions
|
||||
|
||||
```text
|
||||
[with T = units::quantity<units::unit<units::dimension<units::exp<units::base_dim_time, 1> >, std::ratio<1> >, long long int>]
|
||||
[with T = stde::units::quantity<units::unit<units::dimension<units::exp<units::base_dim_time, 1> >, std::ratio<1> >, long long int>]
|
||||
```
|
||||
|
||||
and
|
||||
|
||||
```text
|
||||
[with T = units::dimension<units::exp<units::base_dim_time, 1> >; U = units::dimension<units::exp<units::base_dim_length, 1>, units::exp<units::base_dim_time, -1> >]
|
||||
[with T = stde::units::dimension<units::exp<units::base_dim_time, 1> >; U = stde::units::dimension<units::exp<units::base_dim_length, 1>,stde::units::exp<units::base_dim_time, -1> >]
|
||||
```
|
||||
|
||||
starts to be really hard to analyze or debug.
|
||||
@@ -353,7 +353,7 @@ same code will result with such an error:
|
||||
const Velocity t = 20_s;
|
||||
^~~~
|
||||
In file included from <path>\example\example.cpp:23:
|
||||
<path>/src/include/units/si/velocity.h:48:16: note: within 'template<class T> concept const bool units::Velocity<T> [with T = units::quantity<units::second, long long int>]'
|
||||
<path>/src/include/units/si/velocity.h:48:16: note: within 'template<class T> concept const bool stde::units::Velocity<T> [with T = stde::units::quantity<units::second, long long int>]'
|
||||
concept Velocity = Quantity<T> && std::Same<typename T::dimension, dimension_velocity>;
|
||||
^~~~~~~~
|
||||
In file included from <path>/src/include/units/bits/tools.h:25,
|
||||
@@ -361,7 +361,7 @@ In file included from <path>/src/include/units/bits/tools.h:25,
|
||||
from <path>/src/include/units/si/base_dimensions.h:25,
|
||||
from <path>/src/include/units/si/velocity.h:25,
|
||||
from <path>\example\example.cpp:23:
|
||||
<path>/src/include/units/bits/stdconcepts.h:33:18: note: within 'template<class T, class U> concept const bool std::Same<T, U> [with T = units::dimension_time; U = units::dimension_velocity]'
|
||||
<path>/src/include/units/bits/stdconcepts.h:33:18: note: within 'template<class T, class U> concept const bool std::Same<T, U> [with T = stde::units::dimension_time; U = stde::units::dimension_velocity]'
|
||||
concept Same = std::is_same_v<T, U>;
|
||||
^~~~
|
||||
<path>/src/include/units/bits/stdconcepts.h:33:18: note: 'std::is_same_v' evaluated to false
|
||||
@@ -370,13 +370,13 @@ In file included from <path>/src/include/units/bits/tools.h:25,
|
||||
Now
|
||||
|
||||
```text
|
||||
[with T = units::quantity<units::second, long long int>]
|
||||
[with T = stde::units::quantity<units::second, long long int>]
|
||||
```
|
||||
|
||||
and
|
||||
|
||||
```text
|
||||
[with T = units::dimension_time; U = units::dimension_velocity]
|
||||
[with T = stde::units::dimension_time; U = stde::units::dimension_velocity]
|
||||
```
|
||||
|
||||
are not arguably much easier to understand thus provide better user experience.
|
||||
|
@@ -25,26 +25,27 @@
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units::literals;
|
||||
namespace stde = std::experimental;
|
||||
using namespace stde::units::literals;
|
||||
|
||||
template<units::Length D, units::Time T>
|
||||
constexpr units::Velocity avg_speed(D d, T t)
|
||||
template<stde::units::Length D, stde::units::Time T>
|
||||
constexpr stde::units::Velocity avg_speed(D d, T t)
|
||||
{
|
||||
return d / t;
|
||||
}
|
||||
|
||||
template<units::Velocity V, units::Time T>
|
||||
template<stde::units::Velocity V, stde::units::Time T>
|
||||
void example_1(V v, T t)
|
||||
{
|
||||
const units::Length distance = v * t;
|
||||
const stde::units::Length distance = v * t;
|
||||
std::cout << "A car driving " << v.count() << " km/h in a time of " << t.count() << " minutes will pass "
|
||||
<< units::quantity_cast<units::quantity<units::meter, double>>(distance).count() << " meters.\n";
|
||||
<< stde::units::quantity_cast<stde::units::quantity<stde::units::meter, double>>(distance).count() << " meters.\n";
|
||||
}
|
||||
|
||||
void example_2(double distance_v, double duration_v)
|
||||
{
|
||||
units::quantity<units::kilometer> distance(distance_v);
|
||||
units::quantity<units::hour> duration(duration_v);
|
||||
stde::units::quantity<stde::units::kilometer> distance(distance_v);
|
||||
stde::units::quantity<stde::units::hour> duration(duration_v);
|
||||
const auto kmph = avg_speed(distance, duration);
|
||||
std::cout << "Average speed of a car that makes " << distance.count() << " km in "
|
||||
<< duration.count() << " hours is " << kmph.count() << " km/h.\n";
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <units/length.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_area : make_dimension_t<exp<base_dim_length, 2>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_area>> : downcast_to<dimension_area> {};
|
||||
@@ -67,4 +67,4 @@ namespace units {
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <units/dimension.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
// todo: to be replaced with fixed_string when supported by the compilers
|
||||
|
||||
@@ -36,4 +36,4 @@ namespace units {
|
||||
struct base_dim_substance : dim_id<5> {};
|
||||
struct base_dim_luminous_intensity : dim_id<6> {};
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <units/bits/hacks.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
template<typename T>
|
||||
concept bool Number = std::Regular<T> &&
|
||||
@@ -43,4 +43,4 @@ namespace units {
|
||||
// …
|
||||
} ;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <units/bits/hacks.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
template<typename BaseType>
|
||||
struct downcast_base {
|
||||
@@ -51,4 +51,4 @@ namespace units {
|
||||
template<Downcastable T>
|
||||
using downcasting_traits_t = downcasting_traits<T>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <units/bits/type_traits.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -182,4 +182,4 @@ namespace units {
|
||||
template<TypeList List, template<typename, typename> typename Pred>
|
||||
using type_list_sort = detail::type_list_sort_impl<List, Pred>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <units/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_current : make_dimension_t<exp<base_dim_current, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_current>> : downcast_to<dimension_current> {};
|
||||
@@ -44,4 +44,4 @@ namespace units {
|
||||
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <units/bits/type_list.h>
|
||||
#include <units/bits/downcasting.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
// dim_id
|
||||
|
||||
@@ -186,4 +186,4 @@ namespace units {
|
||||
template<Dimension D1, Dimension D2>
|
||||
using dimension_divide_t = dimension_divide<typename D1::base_type, typename D2::base_type>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <units/base_dimensions.h>
|
||||
#include <units/time.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_frequency : make_dimension_t<exp<base_dim_time, -1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_frequency>> : downcast_to<dimension_frequency> {};
|
||||
@@ -79,4 +79,4 @@ namespace units {
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <units/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_length : make_dimension_t<exp<base_dim_length, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_length>> : downcast_to<dimension_length> {};
|
||||
@@ -99,4 +99,4 @@ namespace units {
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <units/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_luminous_intensity : make_dimension_t<exp<base_dim_luminous_intensity, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_luminous_intensity>> : downcast_to<dimension_luminous_intensity> {};
|
||||
@@ -44,4 +44,4 @@ namespace units {
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <units/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_mass : make_dimension_t<exp<base_dim_mass, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_mass>> : downcast_to<dimension_mass> {};
|
||||
@@ -51,4 +51,4 @@ namespace units {
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include <limits>
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
// is_quantity
|
||||
namespace detail {
|
||||
@@ -408,4 +408,4 @@ namespace units {
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include <cstdint>
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -135,4 +135,4 @@ namespace units {
|
||||
template<Ratio R1, Ratio R2>
|
||||
using common_ratio = typename detail::common_ratio_impl<R1, R2>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <units/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_substance : make_dimension_t<exp<base_dim_substance, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_substance>> : downcast_to<dimension_substance> {};
|
||||
@@ -44,4 +44,4 @@ namespace units {
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <units/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_temperature : make_dimension_t<exp<base_dim_temperature, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_temperature>> : downcast_to<dimension_temperature> {};
|
||||
@@ -44,4 +44,4 @@ namespace units {
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <units/base_dimensions.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_time : make_dimension_t<exp<base_dim_time, 1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_time>> : downcast_to<dimension_time> {};
|
||||
@@ -79,4 +79,4 @@ namespace units {
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include <units/ratio.h>
|
||||
#include <ratio>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
template<Dimension D, Ratio R = ratio<1>>
|
||||
requires (R::num > 0)
|
||||
@@ -68,7 +68,7 @@ namespace units {
|
||||
|
||||
template<typename BaseDimension, Unit... Us>
|
||||
struct get_ratio {
|
||||
using ratio = ::units::ratio<1>;
|
||||
using ratio = ::std::experimental::units::ratio<1>;
|
||||
};
|
||||
|
||||
template<typename BaseDimension, Unit U, Unit... Rest>
|
||||
@@ -99,7 +99,7 @@ namespace units {
|
||||
|
||||
template<Unit... Us>
|
||||
struct derived_ratio<dimension<>, Us...> {
|
||||
using ratio = ::units::ratio<1>;
|
||||
using ratio = ::std::experimental::units::ratio<1>;
|
||||
};
|
||||
|
||||
template<Exponent E, Exponent... Rest, Unit... Us>
|
||||
@@ -131,4 +131,4 @@ namespace units {
|
||||
template<Unit U> using peta = unit<typename U::dimension, ratio_multiply<typename U::ratio, ratio<std::peta::num>>>;
|
||||
template<Unit U> using exa = unit<typename U::dimension, ratio_multiply<typename U::ratio, ratio<std::exa::num>>>;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <units/length.h>
|
||||
#include <units/time.h>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
struct dimension_velocity : make_dimension_t<exp<base_dim_length, 1>, exp<base_dim_time, -1>> {};
|
||||
template<> struct downcasting_traits<downcast_from<dimension_velocity>> : downcast_to<dimension_velocity> {};
|
||||
@@ -58,4 +58,4 @@ namespace units {
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -6,6 +6,7 @@ using dim_id = std::integral_constant<int, UniqueValue>;
|
||||
template<typename D1, typename D2>
|
||||
using dim_id_less = std::bool_constant<D1::value < D2::value>;
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
template<typename... Es>
|
||||
struct dimension;
|
||||
@@ -20,7 +21,7 @@ using <%= "dim#{i}" %> = dimension<<%=
|
||||
xs.shuffle(random: rng).join(', ')
|
||||
%>>;
|
||||
#if defined(METABENCH)
|
||||
using <%= "result#{i}" %> = units::type_list_sort_t<<%= "dim#{i}" %>, dim_id_less>;
|
||||
using <%= "result#{i}" %> = stde::units::type_list_sort_t<<%= "dim#{i}" %>, dim_id_less>;
|
||||
#endif
|
||||
<% end %>
|
||||
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -182,4 +182,4 @@ namespace units {
|
||||
template<TypeList List, template<typename, typename> typename Pred>
|
||||
using type_list_sort_t = type_list_sort<List, Pred>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
@@ -1,5 +1,7 @@
|
||||
#include "type_list_concepts_iface.h"
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
template<int UniqueValue>
|
||||
using dim_id = std::integral_constant<int, UniqueValue>;
|
||||
|
||||
@@ -20,7 +22,7 @@ using <%= "dim#{i}" %> = dimension<<%=
|
||||
xs.shuffle(random: rng).join(', ')
|
||||
%>>;
|
||||
#if defined(METABENCH)
|
||||
using <%= "result#{i}" %> = units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>;
|
||||
using <%= "result#{i}" %> = stde::units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>;
|
||||
#endif
|
||||
<% end %>
|
||||
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -201,4 +201,4 @@ namespace units {
|
||||
template<TypeList List, template<typename, typename> typename Pred>
|
||||
using type_list_sort = detail::type_list_sort_impl<List, Pred>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#include "type_list_concepts_no.h"
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
template<int UniqueValue>
|
||||
using dim_id = std::integral_constant<int, UniqueValue>;
|
||||
|
||||
@@ -20,7 +22,7 @@ using <%= "dim#{i}" %> = dimension<<%=
|
||||
xs.shuffle(random: rng).join(', ')
|
||||
%>>;
|
||||
#if defined(METABENCH)
|
||||
using <%= "result#{i}" %> = units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>;
|
||||
using <%= "result#{i}" %> = stde::units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>;
|
||||
#endif
|
||||
<% end %>
|
||||
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -188,4 +188,4 @@ namespace units {
|
||||
template<typename List, template<typename, typename> typename Pred>
|
||||
using type_list_sort = detail::type_list_sort_impl<List, Pred>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#include "type_list_conditional_alias.h"
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
template<int UniqueValue>
|
||||
using dim_id = std::integral_constant<int, UniqueValue>;
|
||||
|
||||
@@ -20,7 +22,7 @@ using <%= "dim#{i}" %> = dimension<<%=
|
||||
xs.shuffle(random: rng).join(', ')
|
||||
%>>;
|
||||
#if defined(METABENCH)
|
||||
using <%= "result#{i}" %> = units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>;
|
||||
using <%= "result#{i}" %> = stde::units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>;
|
||||
#endif
|
||||
<% end %>
|
||||
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -201,4 +201,4 @@ namespace units {
|
||||
template<TypeList List, template<typename, typename> typename Pred>
|
||||
using type_list_sort = detail::type_list_sort_impl<List, Pred>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#include "type_list_conditional_alias_hard.h"
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
template<int UniqueValue>
|
||||
using dim_id = std::integral_constant<int, UniqueValue>;
|
||||
|
||||
@@ -20,7 +22,7 @@ using <%= "dim#{i}" %> = dimension<<%=
|
||||
xs.shuffle(random: rng).join(', ')
|
||||
%>>;
|
||||
#if defined(METABENCH)
|
||||
using <%= "result#{i}" %> = units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>;
|
||||
using <%= "result#{i}" %> = stde::units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>;
|
||||
#endif
|
||||
<% end %>
|
||||
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
template<bool>
|
||||
struct conditional {
|
||||
@@ -194,4 +194,4 @@ namespace units {
|
||||
template<TypeList List, template<typename, typename> typename Pred>
|
||||
using type_list_sort = detail::type_list_sort_impl<List, Pred>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#include "type_list_conditional_std.h"
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
template<int UniqueValue>
|
||||
using dim_id = std::integral_constant<int, UniqueValue>;
|
||||
|
||||
@@ -20,7 +22,7 @@ using <%= "dim#{i}" %> = dimension<<%=
|
||||
xs.shuffle(random: rng).join(', ')
|
||||
%>>;
|
||||
#if defined(METABENCH)
|
||||
using <%= "result#{i}" %> = units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>;
|
||||
using <%= "result#{i}" %> = stde::units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>;
|
||||
#endif
|
||||
<% end %>
|
||||
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -182,4 +182,4 @@ namespace units {
|
||||
template<TypeList List, template<typename, typename> typename Pred>
|
||||
using type_list_sort = detail::type_list_sort_impl<List, Pred>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -1,15 +1,17 @@
|
||||
#include "ratio_type_constexpr.h"
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
<% (1..n).each do |i| %>
|
||||
struct test<%= i %> {
|
||||
#if defined(METABENCH)
|
||||
using r1 = units::ratio<<%= i %>, <%= n + 1 - i %>>;
|
||||
using r2 = units::ratio<<%= n + 1 - i %>, <%= i %>>;
|
||||
using r1 = stde::units::ratio<<%= i %>, <%= n + 1 - i %>>;
|
||||
using r2 = stde::units::ratio<<%= n + 1 - i %>, <%= i %>>;
|
||||
|
||||
using r3 = units::ratio_multiply<r1, r2>;
|
||||
using r4 = units::ratio_divide<r1, r2>;
|
||||
using r3 = stde::units::ratio_multiply<r1, r2>;
|
||||
using r4 = stde::units::ratio_divide<r1, r2>;
|
||||
|
||||
using r5 = units::common_ratio_t<r1, r2>;
|
||||
using r5 = stde::units::common_ratio_t<r1, r2>;
|
||||
#endif
|
||||
};
|
||||
<% end %>
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#include "std_ratio.h"
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
<% (1..n).each do |i| %>
|
||||
struct test<%= i %> {
|
||||
#if defined(METABENCH)
|
||||
@@ -9,7 +11,7 @@
|
||||
using r3 = std::ratio_multiply<r1, r2>;
|
||||
using r4 = std::ratio_divide<r1, r2>;
|
||||
|
||||
using r5 = units::common_ratio_t<r1, r2>;
|
||||
using r5 = stde::units::common_ratio_t<r1, r2>;
|
||||
#endif
|
||||
};
|
||||
<% end %>
|
||||
|
@@ -1,15 +1,17 @@
|
||||
#include "ratio_type_constexpr.h"
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
<% (1..n).each do |i| %>
|
||||
struct test<%= i %> {
|
||||
using r1 = units::ratio<<%= i %>, <%= n + 1 - i %>>;
|
||||
using r2 = units::ratio<<%= n + 1 - i %>, <%= i %>>;
|
||||
using r1 = stde::units::ratio<<%= i %>, <%= n + 1 - i %>>;
|
||||
using r2 = stde::units::ratio<<%= n + 1 - i %>, <%= i %>>;
|
||||
|
||||
using r3 = units::ratio_multiply<r1, r2>;
|
||||
using r4 = units::ratio_divide<r1, r2>;
|
||||
using r3 = stde::units::ratio_multiply<r1, r2>;
|
||||
using r4 = stde::units::ratio_divide<r1, r2>;
|
||||
|
||||
#if defined(METABENCH)
|
||||
using r5 = units::common_ratio_t<r1, r2>;
|
||||
using r5 = stde::units::common_ratio_t<r1, r2>;
|
||||
#endif
|
||||
};
|
||||
<% end %>
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#include "std_ratio.h"
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
<% (1..n).each do |i| %>
|
||||
struct test<%= i %> {
|
||||
using r1 = std::ratio<<%= i %>, <%= n + 1 - i %>>;
|
||||
@@ -9,7 +11,7 @@
|
||||
using r4 = std::ratio_divide<r1, r2>;
|
||||
|
||||
#if defined(METABENCH)
|
||||
using r5 = units::common_ratio_t<r1, r2>;
|
||||
using r5 = stde::units::common_ratio_t<r1, r2>;
|
||||
#endif
|
||||
};
|
||||
<% end %>
|
||||
|
@@ -1,10 +1,12 @@
|
||||
#include "ratio_type_constexpr.h"
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
<% (1..n).each do |i| %>
|
||||
struct test<%= i %> {
|
||||
#if defined(METABENCH)
|
||||
using r1 = units::ratio<<%= i %>, <%= n + 1 - i %>>;
|
||||
using r2 = units::ratio<<%= n + 1 - i %>, <%= i %>>;
|
||||
using r1 = stde::units::ratio<<%= i %>, <%= n + 1 - i %>>;
|
||||
using r2 = stde::units::ratio<<%= n + 1 - i %>, <%= i %>>;
|
||||
#endif
|
||||
};
|
||||
<% end %>
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#include "std_ratio.h"
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
<% (1..n).each do |i| %>
|
||||
struct test<%= i %> {
|
||||
#if defined(METABENCH)
|
||||
|
@@ -1,13 +1,15 @@
|
||||
#include "ratio_type_constexpr.h"
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
<% (1..n).each do |i| %>
|
||||
struct test<%= i %> {
|
||||
using r1 = units::ratio<<%= i %>, <%= n + 1 - i %>>;
|
||||
using r2 = units::ratio<<%= n + 1 - i %>, <%= i %>>;
|
||||
using r1 = stde::units::ratio<<%= i %>, <%= n + 1 - i %>>;
|
||||
using r2 = stde::units::ratio<<%= n + 1 - i %>, <%= i %>>;
|
||||
|
||||
#if defined(METABENCH)
|
||||
using r3 = units::ratio_multiply<r1, r2>;
|
||||
using r4 = units::ratio_divide<r1, r2>;
|
||||
using r3 = stde::units::ratio_multiply<r1, r2>;
|
||||
using r4 = stde::units::ratio_divide<r1, r2>;
|
||||
#endif
|
||||
};
|
||||
<% end %>
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#include "std_ratio.h"
|
||||
|
||||
namespace stde = std::experimental;
|
||||
|
||||
<% (1..n).each do |i| %>
|
||||
struct test<%= i %> {
|
||||
using r1 = std::ratio<<%= i %>, <%= n + 1 - i %>>;
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include <cstdint>
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -120,4 +120,4 @@ namespace units {
|
||||
template<typename R1, typename R2>
|
||||
using common_ratio_t = typename detail::common_ratio_impl<R1, R2>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <ratio>
|
||||
#include <type_traits>
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
// static_sign
|
||||
|
||||
@@ -66,4 +66,4 @@ namespace units {
|
||||
template<typename R1, typename R2>
|
||||
using common_ratio_t = typename common_ratio<R1, R2>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#include "units/dimension.h"
|
||||
#include <utility>
|
||||
|
||||
using namespace units;
|
||||
using namespace std::experimental::units;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <utility>
|
||||
#include <chrono>
|
||||
|
||||
using namespace units;
|
||||
using namespace std::experimental::units;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace {
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace units {
|
||||
namespace std::experimental::units {
|
||||
|
||||
template<typename T>
|
||||
inline constexpr bool treat_as_floating_point<my_value<T>> = std::is_floating_point_v<T>;
|
||||
@@ -56,7 +56,7 @@ namespace units {
|
||||
static constexpr my_value<T> min() { return std::numeric_limits<T>::lowest(); }
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
} // namespace std::experimental::units
|
||||
|
||||
namespace std {
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace std {
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace std::experimental::units;
|
||||
|
||||
// class invariants
|
||||
|
||||
@@ -192,12 +192,12 @@ namespace {
|
||||
static_assert(std::is_same_v<decltype(quantity<kilometer, double>() - quantity<meter, int>()), quantity<meter, double>>);
|
||||
static_assert(std::is_same_v<decltype(quantity<meter, int>() * 1.0), quantity<meter, double>>);
|
||||
static_assert(std::is_same_v<decltype(1.0 * quantity<meter, int>()), quantity<meter, double>>);
|
||||
static_assert(std::is_same_v<decltype(quantity<meter_per_second, int>() * units::quantity<second, int>()), quantity<units::meter, int>>);
|
||||
static_assert(std::is_same_v<decltype(1 / units::quantity<second, int>()), quantity<hertz, int>>);
|
||||
static_assert(std::is_same_v<decltype(quantity<meter_per_second, int>() * quantity<second, int>()), quantity<meter, int>>);
|
||||
static_assert(std::is_same_v<decltype(1 / quantity<second, int>()), quantity<hertz, int>>);
|
||||
static_assert(std::is_same_v<decltype(quantity<meter, int>() / 1.0), quantity<meter, double>>);
|
||||
static_assert(std::is_same_v<decltype(quantity<meter, int>() / quantity<meter, double>()), double>);
|
||||
static_assert(std::is_same_v<decltype(quantity<kilometer, int>() / quantity<meter, double>()), double>);
|
||||
static_assert(std::is_same_v<decltype(quantity<meter, int>() / units::quantity<second, int>()), quantity<meter_per_second, int>>);
|
||||
static_assert(std::is_same_v<decltype(quantity<meter, int>() / quantity<second, int>()), quantity<meter_per_second, int>>);
|
||||
static_assert(std::is_same_v<decltype(quantity<meter, int>() % short(1)), quantity<meter, int>>);
|
||||
static_assert(std::is_same_v<decltype(quantity<meter, int>() % quantity<meter, short>(1)), quantity<meter, int>>);
|
||||
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace std::experimental::units;
|
||||
|
||||
template<Ratio R1, Ratio R2>
|
||||
inline constexpr bool same = R1::num == R2::num && R1::den == R2::den;
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace std::experimental::units;
|
||||
|
||||
template<typename... Types>
|
||||
struct type_list;
|
||||
|
@@ -37,7 +37,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace std::experimental::units;
|
||||
|
||||
/* ************** BASE DIMENSIONS **************** */
|
||||
|
||||
@@ -71,6 +71,7 @@ namespace {
|
||||
static_assert(1000 / 1_s == 1_kHz);
|
||||
static_assert(1 / 1_ms == 1_kHz);
|
||||
static_assert(3.2_GHz == 3'200'000'000_Hz);
|
||||
// static_assert(10_Hz * 1_min == 600);
|
||||
|
||||
// velocity
|
||||
|
||||
@@ -100,4 +101,14 @@ namespace {
|
||||
static_assert(10_km * 10_km == 100_sq_km);
|
||||
static_assert(1_sq_m == 10'000_sq_cm);
|
||||
|
||||
|
||||
|
||||
// amplitude spectral density
|
||||
|
||||
// struct dimension_amplitude_spectral_density : make_dimension_t<exp<dim_voltage, 1>, exp<dim_frequency, ratio(-1, 2)>> {};
|
||||
// template<> struct downcasting_traits<downcast_from<dimension_amplitude_spectral_density>> : downcast_to<dimension_amplitude_spectral_density> {};
|
||||
//
|
||||
// struct volt_per_sq_hertz : derived_unit<dimension_amplitude_spectral_density, meter, second> {};
|
||||
// template<> struct downcasting_traits<downcast_from<meter_per_second>> : downcast_to<meter_per_second> {};
|
||||
|
||||
} // namespace
|
||||
|
@@ -23,10 +23,11 @@
|
||||
#include <units/velocity.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace units::literals;
|
||||
namespace stde = std::experimental;
|
||||
using namespace stde::units::literals;
|
||||
|
||||
template<units::Length D, units::Time T>
|
||||
constexpr units::Velocity avg_speed(D d, T t)
|
||||
template<stde::units::Length D, stde::units::Time T>
|
||||
constexpr stde::units::Velocity avg_speed(D d, T t)
|
||||
{
|
||||
return d / t;
|
||||
}
|
||||
|
Reference in New Issue
Block a user