diff --git a/doc/DESIGN.md b/doc/DESIGN.md index 60f96d72..a341ce47 100644 --- a/doc/DESIGN.md +++ b/doc/DESIGN.md @@ -51,7 +51,7 @@ Quantity is a concrete amount of a unit for a specified dimension with a specifi ```cpp units::quantity d1(123); -auto d2 = 123_km; // units::quantity +auto d2 = 123_km; // stde::units::quantity ``` There are C++ concepts provided for each such quantity type: @@ -64,7 +64,7 @@ concept Length = Quantity && std::Same\example\example.cpp:23: -/src/include/units/si/velocity.h:41:16: note: within 'template concept const bool units::Velocity [with T = units::quantity >, std::ratio<1> >, long long int>]' +/src/include/units/si/velocity.h:41:16: note: within 'template concept const bool stde::units::Velocity [with T = stde::units::quantity >, std::ratio<1> >, long long int>]' concept Velocity = Quantity && std::Same; ^~~~~~~~ In file included from /src/include/units/bits/tools.h:25, @@ -324,7 +324,7 @@ In file included from /src/include/units/bits/tools.h:25, from /src/include/units/si/base_dimensions.h:25, from /src/include/units/si/velocity.h:25, from \example\example.cpp:23: -/src/include/units/bits/stdconcepts.h:33:18: note: within 'template concept const bool std::Same [with T = units::dimension >; U = units::dimension, units::exp >]' +/src/include/units/bits/stdconcepts.h:33:18: note: within 'template concept const bool std::Same [with T = stde::units::dimension >; U = stde::units::dimension,stde::units::exp >]' concept Same = std::is_same_v; ^~~~ /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 >, std::ratio<1> >, long long int>] +[with T = stde::units::quantity >, std::ratio<1> >, long long int>] ``` and ```text -[with T = units::dimension >; U = units::dimension, units::exp >] +[with T = stde::units::dimension >; U = stde::units::dimension,stde::units::exp >] ``` 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 \example\example.cpp:23: -/src/include/units/si/velocity.h:48:16: note: within 'template concept const bool units::Velocity [with T = units::quantity]' +/src/include/units/si/velocity.h:48:16: note: within 'template concept const bool stde::units::Velocity [with T = stde::units::quantity]' concept Velocity = Quantity && std::Same; ^~~~~~~~ In file included from /src/include/units/bits/tools.h:25, @@ -361,7 +361,7 @@ In file included from /src/include/units/bits/tools.h:25, from /src/include/units/si/base_dimensions.h:25, from /src/include/units/si/velocity.h:25, from \example\example.cpp:23: -/src/include/units/bits/stdconcepts.h:33:18: note: within 'template concept const bool std::Same [with T = units::dimension_time; U = units::dimension_velocity]' +/src/include/units/bits/stdconcepts.h:33:18: note: within 'template concept const bool std::Same [with T = stde::units::dimension_time; U = stde::units::dimension_velocity]' concept Same = std::is_same_v; ^~~~ /src/include/units/bits/stdconcepts.h:33:18: note: 'std::is_same_v' evaluated to false @@ -370,13 +370,13 @@ In file included from /src/include/units/bits/tools.h:25, Now ```text -[with T = units::quantity] +[with T = stde::units::quantity] ``` 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. diff --git a/example/example.cpp b/example/example.cpp index 633b287a..598d61ed 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -25,26 +25,27 @@ namespace { -using namespace units::literals; +namespace stde = std::experimental; +using namespace stde::units::literals; -template -constexpr units::Velocity avg_speed(D d, T t) +template +constexpr stde::units::Velocity avg_speed(D d, T t) { return d / t; } -template +template 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>(distance).count() << " meters.\n"; + << stde::units::quantity_cast>(distance).count() << " meters.\n"; } void example_2(double distance_v, double duration_v) { - units::quantity distance(distance_v); - units::quantity duration(duration_v); + stde::units::quantity distance(distance_v); + stde::units::quantity 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"; diff --git a/src/include/units/area.h b/src/include/units/area.h index 9e8abbef..14619490 100644 --- a/src/include/units/area.h +++ b/src/include/units/area.h @@ -24,7 +24,7 @@ #include -namespace units { +namespace std::experimental::units { struct dimension_area : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -67,4 +67,4 @@ namespace units { } // namespace literals -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/base_dimensions.h b/src/include/units/base_dimensions.h index 293bb227..2d71c329 100644 --- a/src/include/units/base_dimensions.h +++ b/src/include/units/base_dimensions.h @@ -24,7 +24,7 @@ #include -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 diff --git a/src/include/units/bits/concepts.h b/src/include/units/bits/concepts.h index 1f32d003..b018eec7 100644 --- a/src/include/units/bits/concepts.h +++ b/src/include/units/bits/concepts.h @@ -24,7 +24,7 @@ #include -namespace units { +namespace std::experimental::units { template concept bool Number = std::Regular && @@ -43,4 +43,4 @@ namespace units { // … } ; -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/bits/downcasting.h b/src/include/units/bits/downcasting.h index b6e89620..958efbfc 100644 --- a/src/include/units/bits/downcasting.h +++ b/src/include/units/bits/downcasting.h @@ -25,7 +25,7 @@ #include #include -namespace units { +namespace std::experimental::units { template struct downcast_base { @@ -51,4 +51,4 @@ namespace units { template using downcasting_traits_t = downcasting_traits::type; -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/bits/type_list.h b/src/include/units/bits/type_list.h index 98275446..2e611926 100644 --- a/src/include/units/bits/type_list.h +++ b/src/include/units/bits/type_list.h @@ -24,7 +24,7 @@ #include -namespace units { +namespace std::experimental::units { namespace detail { @@ -182,4 +182,4 @@ namespace units { template typename Pred> using type_list_sort = detail::type_list_sort_impl::type; -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/bits/type_traits.h b/src/include/units/bits/type_traits.h index 4a9c8a50..a2928c5b 100644 --- a/src/include/units/bits/type_traits.h +++ b/src/include/units/bits/type_traits.h @@ -24,7 +24,7 @@ #include -namespace units { +namespace std::experimental::units { namespace detail { diff --git a/src/include/units/current.h b/src/include/units/current.h index 6011a1ef..a7a62e31 100644 --- a/src/include/units/current.h +++ b/src/include/units/current.h @@ -25,7 +25,7 @@ #include #include -namespace units { +namespace std::experimental::units { struct dimension_current : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -44,4 +44,4 @@ namespace units { } -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/dimension.h b/src/include/units/dimension.h index c27aff4f..57646242 100644 --- a/src/include/units/dimension.h +++ b/src/include/units/dimension.h @@ -25,7 +25,7 @@ #include #include -namespace units { +namespace std::experimental::units { // dim_id @@ -186,4 +186,4 @@ namespace units { template using dimension_divide_t = dimension_divide::type; -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/frequency.h b/src/include/units/frequency.h index d4625a92..1196a71b 100644 --- a/src/include/units/frequency.h +++ b/src/include/units/frequency.h @@ -25,7 +25,7 @@ #include #include -namespace units { +namespace std::experimental::units { struct dimension_frequency : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -79,4 +79,4 @@ namespace units { } // namespace literals -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/length.h b/src/include/units/length.h index fa43b527..0a7e9e20 100644 --- a/src/include/units/length.h +++ b/src/include/units/length.h @@ -25,7 +25,7 @@ #include #include -namespace units { +namespace std::experimental::units { struct dimension_length : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -99,4 +99,4 @@ namespace units { } // namespace literals -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/luminous_intensity.h b/src/include/units/luminous_intensity.h index 338d634b..dc597645 100644 --- a/src/include/units/luminous_intensity.h +++ b/src/include/units/luminous_intensity.h @@ -25,7 +25,7 @@ #include #include -namespace units { +namespace std::experimental::units { struct dimension_luminous_intensity : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -44,4 +44,4 @@ namespace units { } // namespace literals -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/mass.h b/src/include/units/mass.h index b0515980..f5a17729 100644 --- a/src/include/units/mass.h +++ b/src/include/units/mass.h @@ -25,7 +25,7 @@ #include #include -namespace units { +namespace std::experimental::units { struct dimension_mass : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -51,4 +51,4 @@ namespace units { } // namespace literals -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/quantity.h b/src/include/units/quantity.h index 4e0d4ba2..77bb3fb0 100644 --- a/src/include/units/quantity.h +++ b/src/include/units/quantity.h @@ -27,7 +27,7 @@ #include #include -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 diff --git a/src/include/units/ratio.h b/src/include/units/ratio.h index eca4333d..32f53faa 100644 --- a/src/include/units/ratio.h +++ b/src/include/units/ratio.h @@ -27,7 +27,7 @@ #include #include -namespace units { +namespace std::experimental::units { namespace detail { @@ -135,4 +135,4 @@ namespace units { template using common_ratio = typename detail::common_ratio_impl::type; -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/substance.h b/src/include/units/substance.h index 9a44590c..11baf372 100644 --- a/src/include/units/substance.h +++ b/src/include/units/substance.h @@ -25,7 +25,7 @@ #include #include -namespace units { +namespace std::experimental::units { struct dimension_substance : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -44,4 +44,4 @@ namespace units { } // namespace literals -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/temperature.h b/src/include/units/temperature.h index 3f69403e..8e040ca1 100644 --- a/src/include/units/temperature.h +++ b/src/include/units/temperature.h @@ -25,7 +25,7 @@ #include #include -namespace units { +namespace std::experimental::units { struct dimension_temperature : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -44,4 +44,4 @@ namespace units { } // namespace literals -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/time.h b/src/include/units/time.h index 950730be..372bc1d7 100644 --- a/src/include/units/time.h +++ b/src/include/units/time.h @@ -25,7 +25,7 @@ #include #include -namespace units { +namespace std::experimental::units { struct dimension_time : make_dimension_t> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -79,4 +79,4 @@ namespace units { } // namespace literals -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/unit.h b/src/include/units/unit.h index 9b261889..f2f85c91 100644 --- a/src/include/units/unit.h +++ b/src/include/units/unit.h @@ -26,7 +26,7 @@ #include #include -namespace units { +namespace std::experimental::units { template> requires (R::num > 0) @@ -68,7 +68,7 @@ namespace units { template struct get_ratio { - using ratio = ::units::ratio<1>; + using ratio = ::std::experimental::units::ratio<1>; }; template @@ -99,7 +99,7 @@ namespace units { template struct derived_ratio, Us...> { - using ratio = ::units::ratio<1>; + using ratio = ::std::experimental::units::ratio<1>; }; template @@ -131,4 +131,4 @@ namespace units { template using peta = unit>>; template using exa = unit>>; -} // namespace units +} // namespace std::experimental::units diff --git a/src/include/units/velocity.h b/src/include/units/velocity.h index 69b7b5f0..419ab7e1 100644 --- a/src/include/units/velocity.h +++ b/src/include/units/velocity.h @@ -25,7 +25,7 @@ #include #include -namespace units { +namespace std::experimental::units { struct dimension_velocity : make_dimension_t, exp> {}; template<> struct downcasting_traits> : downcast_to {}; @@ -58,4 +58,4 @@ namespace units { } // namespace literals -} // namespace units +} // namespace std::experimental::units diff --git a/test/metabench/list/type_list_concepts_all.cpp.erb b/test/metabench/list/type_list_concepts_all.cpp.erb index 8aacaafe..88c33108 100644 --- a/test/metabench/list/type_list_concepts_all.cpp.erb +++ b/test/metabench/list/type_list_concepts_all.cpp.erb @@ -6,6 +6,7 @@ using dim_id = std::integral_constant; template using dim_id_less = std::bool_constant; +namespace stde = std::experimental; template 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 %> diff --git a/test/metabench/list/type_list_concepts_all.h b/test/metabench/list/type_list_concepts_all.h index 3f0a4746..a0a17d0f 100644 --- a/test/metabench/list/type_list_concepts_all.h +++ b/test/metabench/list/type_list_concepts_all.h @@ -24,7 +24,7 @@ #include -namespace units { +namespace std::experimental::units { namespace detail { @@ -182,4 +182,4 @@ namespace units { template typename Pred> using type_list_sort_t = type_list_sort::type; -} // namespace units \ No newline at end of file +} // namespace std::experimental::units \ No newline at end of file diff --git a/test/metabench/list/type_list_concepts_iface.cpp.erb b/test/metabench/list/type_list_concepts_iface.cpp.erb index 4b89f825..ac5b688f 100644 --- a/test/metabench/list/type_list_concepts_iface.cpp.erb +++ b/test/metabench/list/type_list_concepts_iface.cpp.erb @@ -1,5 +1,7 @@ #include "type_list_concepts_iface.h" +namespace stde = std::experimental; + template using dim_id = std::integral_constant; @@ -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 %> diff --git a/test/metabench/list/type_list_concepts_iface.h b/test/metabench/list/type_list_concepts_iface.h index 056ba4f2..0fe3a290 100644 --- a/test/metabench/list/type_list_concepts_iface.h +++ b/test/metabench/list/type_list_concepts_iface.h @@ -24,7 +24,7 @@ #include -namespace units { +namespace std::experimental::units { namespace detail { @@ -201,4 +201,4 @@ namespace units { template typename Pred> using type_list_sort = detail::type_list_sort_impl::type; -} // namespace units +} // namespace std::experimental::units diff --git a/test/metabench/list/type_list_concepts_no.cpp.erb b/test/metabench/list/type_list_concepts_no.cpp.erb index 4adbf45e..3ac9d567 100644 --- a/test/metabench/list/type_list_concepts_no.cpp.erb +++ b/test/metabench/list/type_list_concepts_no.cpp.erb @@ -1,5 +1,7 @@ #include "type_list_concepts_no.h" +namespace stde = std::experimental; + template using dim_id = std::integral_constant; @@ -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 %> diff --git a/test/metabench/list/type_list_concepts_no.h b/test/metabench/list/type_list_concepts_no.h index ab74a04e..4c24c039 100644 --- a/test/metabench/list/type_list_concepts_no.h +++ b/test/metabench/list/type_list_concepts_no.h @@ -24,7 +24,7 @@ #include -namespace units { +namespace std::experimental::units { namespace detail { @@ -188,4 +188,4 @@ namespace units { template typename Pred> using type_list_sort = detail::type_list_sort_impl::type; -} // namespace units +} // namespace std::experimental::units diff --git a/test/metabench/list/type_list_conditional_alias.cpp.erb b/test/metabench/list/type_list_conditional_alias.cpp.erb index 80bf8526..eafda990 100644 --- a/test/metabench/list/type_list_conditional_alias.cpp.erb +++ b/test/metabench/list/type_list_conditional_alias.cpp.erb @@ -1,5 +1,7 @@ #include "type_list_conditional_alias.h" +namespace stde = std::experimental; + template using dim_id = std::integral_constant; @@ -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 %> diff --git a/test/metabench/list/type_list_conditional_alias.h b/test/metabench/list/type_list_conditional_alias.h index 056ba4f2..0fe3a290 100644 --- a/test/metabench/list/type_list_conditional_alias.h +++ b/test/metabench/list/type_list_conditional_alias.h @@ -24,7 +24,7 @@ #include -namespace units { +namespace std::experimental::units { namespace detail { @@ -201,4 +201,4 @@ namespace units { template typename Pred> using type_list_sort = detail::type_list_sort_impl::type; -} // namespace units +} // namespace std::experimental::units diff --git a/test/metabench/list/type_list_conditional_alias_hard.cpp.erb b/test/metabench/list/type_list_conditional_alias_hard.cpp.erb index 837a0a47..b22938bc 100644 --- a/test/metabench/list/type_list_conditional_alias_hard.cpp.erb +++ b/test/metabench/list/type_list_conditional_alias_hard.cpp.erb @@ -1,5 +1,7 @@ #include "type_list_conditional_alias_hard.h" +namespace stde = std::experimental; + template using dim_id = std::integral_constant; @@ -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 %> diff --git a/test/metabench/list/type_list_conditional_alias_hard.h b/test/metabench/list/type_list_conditional_alias_hard.h index c6b43d43..556ae9bd 100644 --- a/test/metabench/list/type_list_conditional_alias_hard.h +++ b/test/metabench/list/type_list_conditional_alias_hard.h @@ -24,7 +24,7 @@ #include -namespace units { +namespace std::experimental::units { template struct conditional { @@ -194,4 +194,4 @@ namespace units { template typename Pred> using type_list_sort = detail::type_list_sort_impl::type; -} // namespace units +} // namespace std::experimental::units diff --git a/test/metabench/list/type_list_conditional_std.cpp.erb b/test/metabench/list/type_list_conditional_std.cpp.erb index 8c9a1f95..50535cd9 100644 --- a/test/metabench/list/type_list_conditional_std.cpp.erb +++ b/test/metabench/list/type_list_conditional_std.cpp.erb @@ -1,5 +1,7 @@ #include "type_list_conditional_std.h" +namespace stde = std::experimental; + template using dim_id = std::integral_constant; @@ -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 %> diff --git a/test/metabench/list/type_list_conditional_std.h b/test/metabench/list/type_list_conditional_std.h index 54e0a100..5600f16b 100644 --- a/test/metabench/list/type_list_conditional_std.h +++ b/test/metabench/list/type_list_conditional_std.h @@ -24,7 +24,7 @@ #include -namespace units { +namespace std::experimental::units { namespace detail { @@ -182,4 +182,4 @@ namespace units { template typename Pred> using type_list_sort = detail::type_list_sort_impl::type; -} // namespace units +} // namespace std::experimental::units diff --git a/test/metabench/ratio/all_ratio_type_constexpr.cpp.erb b/test/metabench/ratio/all_ratio_type_constexpr.cpp.erb index cff47d9e..2e98e10d 100644 --- a/test/metabench/ratio/all_ratio_type_constexpr.cpp.erb +++ b/test/metabench/ratio/all_ratio_type_constexpr.cpp.erb @@ -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; - using r4 = units::ratio_divide; + using r3 = stde::units::ratio_multiply; + using r4 = stde::units::ratio_divide; - using r5 = units::common_ratio_t; + using r5 = stde::units::common_ratio_t; #endif }; <% end %> diff --git a/test/metabench/ratio/all_std_ratio.cpp.erb b/test/metabench/ratio/all_std_ratio.cpp.erb index 851b7256..0848d4f9 100644 --- a/test/metabench/ratio/all_std_ratio.cpp.erb +++ b/test/metabench/ratio/all_std_ratio.cpp.erb @@ -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; using r4 = std::ratio_divide; - using r5 = units::common_ratio_t; + using r5 = stde::units::common_ratio_t; #endif }; <% end %> diff --git a/test/metabench/ratio/common_ratio_ratio_type_constexpr.cpp.erb b/test/metabench/ratio/common_ratio_ratio_type_constexpr.cpp.erb index ec680850..89c5a6a1 100644 --- a/test/metabench/ratio/common_ratio_ratio_type_constexpr.cpp.erb +++ b/test/metabench/ratio/common_ratio_ratio_type_constexpr.cpp.erb @@ -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; - using r4 = units::ratio_divide; + using r3 = stde::units::ratio_multiply; + using r4 = stde::units::ratio_divide; #if defined(METABENCH) - using r5 = units::common_ratio_t; + using r5 = stde::units::common_ratio_t; #endif }; <% end %> diff --git a/test/metabench/ratio/common_ratio_std_ratio.cpp.erb b/test/metabench/ratio/common_ratio_std_ratio.cpp.erb index 5da2d0a0..3df70151 100644 --- a/test/metabench/ratio/common_ratio_std_ratio.cpp.erb +++ b/test/metabench/ratio/common_ratio_std_ratio.cpp.erb @@ -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; #if defined(METABENCH) - using r5 = units::common_ratio_t; + using r5 = stde::units::common_ratio_t; #endif }; <% end %> diff --git a/test/metabench/ratio/create_ratio_type_constexpr.cpp.erb b/test/metabench/ratio/create_ratio_type_constexpr.cpp.erb index 80fa9e72..918e50b8 100644 --- a/test/metabench/ratio/create_ratio_type_constexpr.cpp.erb +++ b/test/metabench/ratio/create_ratio_type_constexpr.cpp.erb @@ -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 %> diff --git a/test/metabench/ratio/create_std_ratio.cpp.erb b/test/metabench/ratio/create_std_ratio.cpp.erb index 3555aab8..038325e4 100644 --- a/test/metabench/ratio/create_std_ratio.cpp.erb +++ b/test/metabench/ratio/create_std_ratio.cpp.erb @@ -1,5 +1,7 @@ #include "std_ratio.h" +namespace stde = std::experimental; + <% (1..n).each do |i| %> struct test<%= i %> { #if defined(METABENCH) diff --git a/test/metabench/ratio/multiply_divide_ratio_type_constexpr.cpp.erb b/test/metabench/ratio/multiply_divide_ratio_type_constexpr.cpp.erb index d7c4d98f..18499cb7 100644 --- a/test/metabench/ratio/multiply_divide_ratio_type_constexpr.cpp.erb +++ b/test/metabench/ratio/multiply_divide_ratio_type_constexpr.cpp.erb @@ -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; - using r4 = units::ratio_divide; + using r3 = stde::units::ratio_multiply; + using r4 = stde::units::ratio_divide; #endif }; <% end %> diff --git a/test/metabench/ratio/multiply_divide_std_ratio.cpp.erb b/test/metabench/ratio/multiply_divide_std_ratio.cpp.erb index 0216d2ea..0ae19648 100644 --- a/test/metabench/ratio/multiply_divide_std_ratio.cpp.erb +++ b/test/metabench/ratio/multiply_divide_std_ratio.cpp.erb @@ -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 %>>; diff --git a/test/metabench/ratio/ratio_type_constexpr.h b/test/metabench/ratio/ratio_type_constexpr.h index 90b6cbf7..f344a168 100644 --- a/test/metabench/ratio/ratio_type_constexpr.h +++ b/test/metabench/ratio/ratio_type_constexpr.h @@ -27,7 +27,7 @@ #include #include -namespace units { +namespace std::experimental::units { namespace detail { @@ -120,4 +120,4 @@ namespace units { template using common_ratio_t = typename detail::common_ratio_impl::type; -} // namespace units +} // namespace std::experimental::units diff --git a/test/metabench/ratio/std_ratio.h b/test/metabench/ratio/std_ratio.h index 45422fe9..8e7d49e8 100644 --- a/test/metabench/ratio/std_ratio.h +++ b/test/metabench/ratio/std_ratio.h @@ -25,7 +25,7 @@ #include #include -namespace units { +namespace std::experimental::units { // static_sign @@ -66,4 +66,4 @@ namespace units { template using common_ratio_t = typename common_ratio::type; -} // namespace units +} // namespace std::experimental::units diff --git a/test/unit_test/test_dimension.cpp b/test/unit_test/test_dimension.cpp index dd09d602..8b637224 100644 --- a/test/unit_test/test_dimension.cpp +++ b/test/unit_test/test_dimension.cpp @@ -23,7 +23,7 @@ #include "units/dimension.h" #include -using namespace units; +using namespace std::experimental::units; namespace { diff --git a/test/unit_test/test_quantity.cpp b/test/unit_test/test_quantity.cpp index 4f2a10f4..f8d5f498 100644 --- a/test/unit_test/test_quantity.cpp +++ b/test/unit_test/test_quantity.cpp @@ -25,7 +25,7 @@ #include #include -using namespace units; +using namespace std::experimental::units; namespace { @@ -44,7 +44,7 @@ namespace { } // namespace -namespace units { +namespace std::experimental::units { template inline constexpr bool treat_as_floating_point> = std::is_floating_point_v; @@ -56,7 +56,7 @@ namespace units { static constexpr my_value min() { return std::numeric_limits::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() - quantity()), quantity>); static_assert(std::is_same_v() * 1.0), quantity>); static_assert(std::is_same_v()), quantity>); - static_assert(std::is_same_v() * units::quantity()), quantity>); - static_assert(std::is_same_v()), quantity>); + static_assert(std::is_same_v() * quantity()), quantity>); + static_assert(std::is_same_v()), quantity>); static_assert(std::is_same_v() / 1.0), quantity>); static_assert(std::is_same_v() / quantity()), double>); static_assert(std::is_same_v() / quantity()), double>); - static_assert(std::is_same_v() / units::quantity()), quantity>); + static_assert(std::is_same_v() / quantity()), quantity>); static_assert(std::is_same_v() % short(1)), quantity>); static_assert(std::is_same_v() % quantity(1)), quantity>); diff --git a/test/unit_test/test_tools.cpp b/test/unit_test/test_tools.cpp index ee887fba..23899293 100644 --- a/test/unit_test/test_tools.cpp +++ b/test/unit_test/test_tools.cpp @@ -24,7 +24,7 @@ namespace { - using namespace units; + using namespace std::experimental::units; template inline constexpr bool same = R1::num == R2::num && R1::den == R2::den; diff --git a/test/unit_test/test_type_list.cpp b/test/unit_test/test_type_list.cpp index 67f6e55a..2c6cd240 100644 --- a/test/unit_test/test_type_list.cpp +++ b/test/unit_test/test_type_list.cpp @@ -25,7 +25,7 @@ namespace { - using namespace units; + using namespace std::experimental::units; template struct type_list; diff --git a/test/unit_test/test_units.cpp b/test/unit_test/test_units.cpp index 48dcee0b..06efeaf9 100644 --- a/test/unit_test/test_units.cpp +++ b/test/unit_test/test_units.cpp @@ -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> {}; +// template<> struct downcasting_traits> : downcast_to {}; +// +// struct volt_per_sq_hertz : derived_unit {}; +// template<> struct downcasting_traits> : downcast_to {}; + } // namespace diff --git a/test_package/test_package.cpp b/test_package/test_package.cpp index 89383669..ec61a335 100644 --- a/test_package/test_package.cpp +++ b/test_package/test_package.cpp @@ -23,10 +23,11 @@ #include #include -using namespace units::literals; +namespace stde = std::experimental; +using namespace stde::units::literals; -template -constexpr units::Velocity avg_speed(D d, T t) +template +constexpr stde::units::Velocity avg_speed(D d, T t) { return d / t; }