From 7ee95bcbebb50a05288743e0eb1c43642cd7dc16 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 27 Dec 2022 11:04:49 +0100 Subject: [PATCH] test: metabench tests removed from repo --- test/metabench/CMakeLists.txt | 43 ---- test/metabench/list/CMakeLists.txt | 65 ------ .../list/type_list_concepts_all.cpp.erb | 34 --- test/metabench/list/type_list_concepts_all.h | 184 --------------- .../list/type_list_concepts_iface.cpp.erb | 35 --- .../metabench/list/type_list_concepts_iface.h | 205 ----------------- .../list/type_list_concepts_no.cpp.erb | 35 --- test/metabench/list/type_list_concepts_no.h | 192 ---------------- .../list/type_list_conditional_alias.cpp.erb | 35 --- .../list/type_list_conditional_alias.h | 205 ----------------- .../type_list_conditional_alias_hard.cpp.erb | 35 --- .../list/type_list_conditional_alias_hard.h | 197 ---------------- .../list/type_list_conditional_std.cpp.erb | 35 --- .../list/type_list_conditional_std.h | 186 --------------- test/metabench/make_dimension/CMakeLists.txt | 40 ---- .../make_dimension/concepts_all.cpp.erb | 23 -- .../make_dimension/concepts_iface.cpp.erb | 23 -- .../make_dimension/dimension_concepts_all.h | 211 ------------------ .../make_dimension/dimension_concepts_iface.h | 211 ------------------ .../make_dimension/dimension_no_concepts.h | 184 --------------- .../make_dimension/downcasting_concepts_all.h | 48 ---- .../make_dimension/downcasting_no_concepts.h | 44 ---- test/metabench/make_dimension/hacks.h | 36 --- .../make_dimension/no_concepts.cpp.erb | 23 -- .../make_dimension/ratio_concepts_all.h | 140 ------------ .../make_dimension/ratio_concepts_iface.h | 140 ------------ .../make_dimension/ratio_no_concepts.h | 125 ----------- .../make_dimension/type_list_concepts_all.h | 186 --------------- .../make_dimension/type_list_concepts_iface.h | 186 --------------- .../make_dimension/type_list_no_concepts.h | 173 -------------- test/metabench/make_dimension/type_traits.h | 48 ---- test/metabench/ratio/CMakeLists.txt | 86 ------- .../ratio/all_ratio_type_constexpr.cpp.erb | 26 --- test/metabench/ratio/all_std_ratio.cpp.erb | 26 --- .../common_ratio_ratio_type_constexpr.cpp.erb | 19 -- .../ratio/common_ratio_std_ratio.cpp.erb | 19 -- .../ratio/create_ratio_type_constexpr.cpp.erb | 18 -- test/metabench/ratio/create_std_ratio.cpp.erb | 18 -- ...ltiply_divide_ratio_type_constexpr.cpp.erb | 21 -- .../ratio/multiply_divide_std_ratio.cpp.erb | 21 -- .../ratio/ratio_type_constexpr.cpp.erb | 20 -- test/metabench/ratio/ratio_type_constexpr.h | 128 ----------- test/metabench/ratio/std_ratio.h | 63 ------ 43 files changed, 3792 deletions(-) delete mode 100644 test/metabench/CMakeLists.txt delete mode 100644 test/metabench/list/CMakeLists.txt delete mode 100644 test/metabench/list/type_list_concepts_all.cpp.erb delete mode 100644 test/metabench/list/type_list_concepts_all.h delete mode 100644 test/metabench/list/type_list_concepts_iface.cpp.erb delete mode 100644 test/metabench/list/type_list_concepts_iface.h delete mode 100644 test/metabench/list/type_list_concepts_no.cpp.erb delete mode 100644 test/metabench/list/type_list_concepts_no.h delete mode 100644 test/metabench/list/type_list_conditional_alias.cpp.erb delete mode 100644 test/metabench/list/type_list_conditional_alias.h delete mode 100644 test/metabench/list/type_list_conditional_alias_hard.cpp.erb delete mode 100644 test/metabench/list/type_list_conditional_alias_hard.h delete mode 100644 test/metabench/list/type_list_conditional_std.cpp.erb delete mode 100644 test/metabench/list/type_list_conditional_std.h delete mode 100644 test/metabench/make_dimension/CMakeLists.txt delete mode 100644 test/metabench/make_dimension/concepts_all.cpp.erb delete mode 100644 test/metabench/make_dimension/concepts_iface.cpp.erb delete mode 100644 test/metabench/make_dimension/dimension_concepts_all.h delete mode 100644 test/metabench/make_dimension/dimension_concepts_iface.h delete mode 100644 test/metabench/make_dimension/dimension_no_concepts.h delete mode 100644 test/metabench/make_dimension/downcasting_concepts_all.h delete mode 100644 test/metabench/make_dimension/downcasting_no_concepts.h delete mode 100644 test/metabench/make_dimension/hacks.h delete mode 100644 test/metabench/make_dimension/no_concepts.cpp.erb delete mode 100644 test/metabench/make_dimension/ratio_concepts_all.h delete mode 100644 test/metabench/make_dimension/ratio_concepts_iface.h delete mode 100644 test/metabench/make_dimension/ratio_no_concepts.h delete mode 100644 test/metabench/make_dimension/type_list_concepts_all.h delete mode 100644 test/metabench/make_dimension/type_list_concepts_iface.h delete mode 100644 test/metabench/make_dimension/type_list_no_concepts.h delete mode 100644 test/metabench/make_dimension/type_traits.h delete mode 100644 test/metabench/ratio/CMakeLists.txt delete mode 100644 test/metabench/ratio/all_ratio_type_constexpr.cpp.erb delete mode 100644 test/metabench/ratio/all_std_ratio.cpp.erb delete mode 100644 test/metabench/ratio/common_ratio_ratio_type_constexpr.cpp.erb delete mode 100644 test/metabench/ratio/common_ratio_std_ratio.cpp.erb delete mode 100644 test/metabench/ratio/create_ratio_type_constexpr.cpp.erb delete mode 100644 test/metabench/ratio/create_std_ratio.cpp.erb delete mode 100644 test/metabench/ratio/multiply_divide_ratio_type_constexpr.cpp.erb delete mode 100644 test/metabench/ratio/multiply_divide_std_ratio.cpp.erb delete mode 100644 test/metabench/ratio/ratio_type_constexpr.cpp.erb delete mode 100644 test/metabench/ratio/ratio_type_constexpr.h delete mode 100644 test/metabench/ratio/std_ratio.h diff --git a/test/metabench/CMakeLists.txt b/test/metabench/CMakeLists.txt deleted file mode 100644 index 0186dc1a..00000000 --- a/test/metabench/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Mateusz Pusz -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -cmake_minimum_required(VERSION 3.12) - -function(add_metabench_test target name erb_path range) - metabench_add_dataset(${target} "${erb_path}" "${range}" NAME "${name}") - target_compile_features(${target} PUBLIC cxx_std_20) - target_link_libraries(${target} PUBLIC range-v3::range-v3>) - target_compile_options(${target} PUBLIC -fconcepts) -endfunction() - -include(metabench) -if(NOT METABENCH_DIR) - return() -endif() - -enable_testing() - -add_custom_target(metabench) - -add_subdirectory(list) -add_subdirectory(make_dimension) -add_subdirectory(ratio) diff --git a/test/metabench/list/CMakeLists.txt b/test/metabench/list/CMakeLists.txt deleted file mode 100644 index 383efcad..00000000 --- a/test/metabench/list/CMakeLists.txt +++ /dev/null @@ -1,65 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Mateusz Pusz -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -cmake_minimum_required(VERSION 3.2) - -add_metabench_test( - metabench.data.list.type_list.concepts_all "all concepts" type_list_concepts_all.cpp.erb "[3, 6, 9, 12, 15]" -) -add_metabench_test( - metabench.data.list.type_list.concepts_iface "concepts in interface" type_list_concepts_iface.cpp.erb - "[3, 6, 9, 12, 15]" -) -add_metabench_test( - metabench.data.list.type_list.concepts_no "no concepts" type_list_concepts_no.cpp.erb "[3, 6, 9, 12, 15]" -) -metabench_add_chart( - metabench.chart.list.concepts - TITLE "Sorting a list of size N" - SUBTITLE "(lower is better)" - DATASETS metabench.data.list.type_list.concepts_all metabench.data.list.type_list.concepts_iface - metabench.data.list.type_list.concepts_no -) - -add_metabench_test( - metabench.data.list.type_list.conditional_std "std::conditional" type_list_conditional_std.cpp.erb - "[3, 6, 9, 12, 15]" -) -add_metabench_test( - metabench.data.list.type_list.conditional_alias "alias conditional" type_list_conditional_alias.cpp.erb - "[3, 6, 9, 12, 15]" -) -add_metabench_test( - metabench.data.list.type_list.conditional_alias_hard "alias conditional hard" - type_list_conditional_alias_hard.cpp.erb "[3, 6, 9, 12, 15]" -) -metabench_add_chart( - metabench.chart.list.conditional - TITLE "Sorting a list of size N" - SUBTITLE "(lower is better)" - DATASETS metabench.data.list.type_list.conditional_std metabench.data.list.type_list.conditional_alias - metabench.data.list.type_list.conditional_alias_hard -) - -add_custom_target(metabench.chart.list DEPENDS metabench.chart.list.concepts metabench.chart.list.conditional) - -add_dependencies(metabench metabench.chart.list) diff --git a/test/metabench/list/type_list_concepts_all.cpp.erb b/test/metabench/list/type_list_concepts_all.cpp.erb deleted file mode 100644 index 142aa11b..00000000 --- a/test/metabench/list/type_list_concepts_all.cpp.erb +++ /dev/null @@ -1,34 +0,0 @@ -#include "type_list_concepts_all.h" - -template -using dim_id = std::integral_constant; - -template -using dim_id_less = std::bool_constant; - -template -struct dimension; - -<% (1..10).each do |k| %> -struct test<%= k %> { - -<% (1..n).each do |i| %> -using <%= "dim#{i}" %> = dimension<<%= - xs = ((1)..(i)).map { |j| "dim_id<#{k*n+i+j}>" } - rng = Random.new(i) - xs.shuffle(random: rng).join(', ') -%>>; -#if defined(METABENCH) -using <%= "result#{i}" %> = units::type_list_sort_t<<%= "dim#{i}" %>, dim_id_less>; -#else -using <%= "result#{i}" %> = void; -#endif -<% end %> - -}; - -<% end %> - -int main() -{ -} diff --git a/test/metabench/list/type_list_concepts_all.h b/test/metabench/list/type_list_concepts_all.h deleted file mode 100644 index d7523912..00000000 --- a/test/metabench/list/type_list_concepts_all.h +++ /dev/null @@ -1,184 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include - -namespace units { - -namespace detail { - -template -struct conditional { - template - using type = F; -}; - -template<> -struct conditional { - template - using type = T; -}; - -template -using conditional_t = conditional::template type; - -} // namespace detail - -namespace detail { - -template -inline constexpr bool is_type_list = false; - -template typename T, typename... Types> -inline constexpr bool is_type_list> = true; - -} // namespace detail - -template -concept TypeList = detail::is_type_list; - -// push_front - -template -struct type_list_push_front; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_front, NewTypes...> { - using type = List; -}; - -template -using type_list_push_front_t = type_list_push_front::type; - -// push_back - -template -struct type_list_push_back; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_back, NewTypes...> { - using type = List; -}; - -template -using type_list_push_back_t = type_list_push_back::type; - -// split - -namespace detail { - -template typename List, std::size_t Idx, std::size_t N, typename... Types> -struct split_impl; - -template typename List, std::size_t Idx, std::size_t N> -struct split_impl { - using first_list = List<>; - using second_list = List<>; -}; - -template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> -struct split_impl : split_impl { - using base = split_impl; - using base_first = base::first_list; - using base_second = base::second_list; - using first_list = detail::conditional_t < Idx, base_first>; - using second_list = detail::conditional_t < Idx>; -}; - -} // namespace detail - -template -struct type_list_split; - -template typename List, std::size_t N, typename... Types> -struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; -}; - -// split_half - -template -struct type_list_split_half; - -template typename List, typename... Types> -struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - -// merge_sorted - -template typename Pred> -struct type_list_merge_sorted; - -template typename Pred> -using type_list_merge_sorted_t = type_list_merge_sorted::type; - -template typename List, typename... Lhs, template typename Pred> -struct type_list_merge_sorted, List<>, Pred> { - using type = List; -}; - -template typename List, typename... Rhs, template typename Pred> -struct type_list_merge_sorted, List, Pred> { - using type = List; -}; - -template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> -struct type_list_merge_sorted, List, Pred> { - using type = detail::conditional_t< - Pred::value, - type_list_push_front_t, List, Pred>, Lhs1>, - type_list_push_front_t, List, Pred>, Rhs1>>; -}; - -// sort - -template typename Pred> -struct type_list_sort; - -template typename List, template typename Pred> -struct type_list_sort, Pred> { - using type = List<>; -}; - -template typename List, typename T, template typename Pred> -struct type_list_sort, Pred> { - using type = List; -}; - -template typename List, typename... Types, template typename Pred> -struct type_list_sort, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort::type; - using right = type_list_sort::type; - using type = type_list_merge_sorted_t; -}; - -template typename Pred> -using type_list_sort_t = type_list_sort::type; - -} // namespace units diff --git a/test/metabench/list/type_list_concepts_iface.cpp.erb b/test/metabench/list/type_list_concepts_iface.cpp.erb deleted file mode 100644 index 649440a9..00000000 --- a/test/metabench/list/type_list_concepts_iface.cpp.erb +++ /dev/null @@ -1,35 +0,0 @@ -#include "type_list_concepts_iface.h" - -template -using dim_id = std::integral_constant; - -template -using dim_id_less = std::bool_constant; - - -template -struct dimension; - -<% (1..10).each do |k| %> -struct test<%= k %> { - -<% (1..n).each do |i| %> -using <%= "dim#{i}" %> = dimension<<%= - xs = ((1)..(i)).map { |j| "dim_id<#{k*n+i+j}>" } - rng = Random.new(i) - xs.shuffle(random: rng).join(', ') -%>>; -#if defined(METABENCH) -using <%= "result#{i}" %> = units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>; -#else -using <%= "result#{i}" %> = void; -#endif -<% end %> - -}; - -<% end %> - -int main() -{ -} diff --git a/test/metabench/list/type_list_concepts_iface.h b/test/metabench/list/type_list_concepts_iface.h deleted file mode 100644 index b30478cb..00000000 --- a/test/metabench/list/type_list_concepts_iface.h +++ /dev/null @@ -1,205 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include - -namespace units { - -namespace detail { - -template -struct conditional { - template - using type = F; -}; - -template<> -struct conditional { - template - using type = T; -}; - -} // namespace detail - -template -using conditional = detail::conditional::template type; - -namespace detail { - -template -inline constexpr bool is_type_list = false; - -template typename T, typename... Types> -inline constexpr bool is_type_list> = true; - -} // namespace detail - -template -concept TypeList = detail::is_type_list; - -// push_front - -namespace detail { - -template -struct type_list_push_front_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_front_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_front = detail::type_list_push_front_impl::type; - -// push_back - -namespace detail { - -template -struct type_list_push_back_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_back_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_back = detail::type_list_push_back_impl::type; - -// split - -namespace detail { - -template typename List, std::size_t Idx, std::size_t N, typename... Types> -struct split_impl; - -template typename List, std::size_t Idx, std::size_t N> -struct split_impl { - using first_list = List<>; - using second_list = List<>; -}; - -template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> -struct split_impl : split_impl { - using base = split_impl; - using first_list = - units::conditional < - Idx::type, typename base::first_list>; - using second_list = - units::conditional < - Idx::type>; -}; - -} // namespace detail - -template -struct type_list_split; - -template typename List, std::size_t N, typename... Types> -struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; -}; - -// split_half - -template -struct type_list_split_half; - -template typename List, typename... Types> -struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - -// merge_sorted - -namespace detail { - -template typename Pred> -struct type_list_merge_sorted_impl; - -template typename List, typename... Lhs, template typename Pred> -struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; -}; - -template typename List, typename... Rhs, template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = List; -}; - -template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = units::conditional< - Pred::value, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; -}; - -} // namespace detail - -template typename Pred> -using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - - -// sort - -namespace detail { - -template typename Pred> -struct type_list_sort_impl; - -template typename List, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List<>; -}; - -template typename List, typename T, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List; -}; - -template typename List, typename... Types, template typename Pred> -struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; -}; - -} // namespace detail - -template typename Pred> -using type_list_sort = detail::type_list_sort_impl::type; - -} // namespace units diff --git a/test/metabench/list/type_list_concepts_no.cpp.erb b/test/metabench/list/type_list_concepts_no.cpp.erb deleted file mode 100644 index 19cec4f3..00000000 --- a/test/metabench/list/type_list_concepts_no.cpp.erb +++ /dev/null @@ -1,35 +0,0 @@ -#include "type_list_concepts_no.h" - -template -using dim_id = std::integral_constant; - -template -using dim_id_less = std::bool_constant; - - -template -struct dimension; - -<% (1..10).each do |k| %> -struct test<%= k %> { - -<% (1..n).each do |i| %> -using <%= "dim#{i}" %> = dimension<<%= - xs = ((1)..(i)).map { |j| "dim_id<#{k*n+i+j}>" } - rng = Random.new(i) - xs.shuffle(random: rng).join(', ') -%>>; -#if defined(METABENCH) -using <%= "result#{i}" %> = units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>; -#else -using <%= "result#{i}" %> = void; -#endif -<% end %> - -}; - -<% end %> - -int main() -{ -} diff --git a/test/metabench/list/type_list_concepts_no.h b/test/metabench/list/type_list_concepts_no.h deleted file mode 100644 index 4f480405..00000000 --- a/test/metabench/list/type_list_concepts_no.h +++ /dev/null @@ -1,192 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include - -namespace units { - -namespace detail { - -template -struct conditional { - template - using type = F; -}; - -template<> -struct conditional { - template - using type = T; -}; - -} // namespace detail - -template -using conditional = detail::conditional::template type; - -// push_front - -namespace detail { - -template -struct type_list_push_front_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_front_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_front = detail::type_list_push_front_impl::type; - -// push_back - -namespace detail { - -template -struct type_list_push_back_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_back_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_back = detail::type_list_push_back_impl::type; - -// split - -namespace detail { - -template typename List, std::size_t Idx, std::size_t N, typename... Types> -struct split_impl; - -template typename List, std::size_t Idx, std::size_t N> -struct split_impl { - using first_list = List<>; - using second_list = List<>; -}; - -template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> -struct split_impl : split_impl { - using base = split_impl; - using first_list = - units::conditional < - Idx::type, typename base::first_list>; - using second_list = - units::conditional < - Idx::type>; -}; - -} // namespace detail - -template -struct type_list_split; - -template typename List, std::size_t N, typename... Types> -struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; -}; - -// split_half - -template -struct type_list_split_half; - -template typename List, typename... Types> -struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - -// merge_sorted - -namespace detail { - -template typename Pred> -struct type_list_merge_sorted_impl; - -template typename List, typename... Lhs, template typename Pred> -struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; -}; - -template typename List, typename... Rhs, template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = List; -}; - -template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = units::conditional< - Pred::value, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; -}; - -} // namespace detail - -template typename Pred> -using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - - -// sort - -namespace detail { - -template typename Pred> -struct type_list_sort_impl; - -template typename List, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List<>; -}; - -template typename List, typename T, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List; -}; - -template typename List, typename... Types, template typename Pred> -struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; -}; - -} // namespace detail - -template typename Pred> -using type_list_sort = detail::type_list_sort_impl::type; - -} // namespace units diff --git a/test/metabench/list/type_list_conditional_alias.cpp.erb b/test/metabench/list/type_list_conditional_alias.cpp.erb deleted file mode 100644 index 5738e52e..00000000 --- a/test/metabench/list/type_list_conditional_alias.cpp.erb +++ /dev/null @@ -1,35 +0,0 @@ -#include "type_list_conditional_alias.h" - -template -using dim_id = std::integral_constant; - -template -using dim_id_less = std::bool_constant; - - -template -struct dimension; - -<% (1..10).each do |k| %> -struct test<%= k %> { - -<% (1..n).each do |i| %> -using <%= "dim#{i}" %> = dimension<<%= - xs = ((1)..(i)).map { |j| "dim_id<#{k*n+i+j}>" } - rng = Random.new(i) - xs.shuffle(random: rng).join(', ') -%>>; -#if defined(METABENCH) -using <%= "result#{i}" %> = units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>; -#else -using <%= "result#{i}" %> = void; -#endif -<% end %> - -}; - -<% end %> - -int main() -{ -} diff --git a/test/metabench/list/type_list_conditional_alias.h b/test/metabench/list/type_list_conditional_alias.h deleted file mode 100644 index b30478cb..00000000 --- a/test/metabench/list/type_list_conditional_alias.h +++ /dev/null @@ -1,205 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include - -namespace units { - -namespace detail { - -template -struct conditional { - template - using type = F; -}; - -template<> -struct conditional { - template - using type = T; -}; - -} // namespace detail - -template -using conditional = detail::conditional::template type; - -namespace detail { - -template -inline constexpr bool is_type_list = false; - -template typename T, typename... Types> -inline constexpr bool is_type_list> = true; - -} // namespace detail - -template -concept TypeList = detail::is_type_list; - -// push_front - -namespace detail { - -template -struct type_list_push_front_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_front_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_front = detail::type_list_push_front_impl::type; - -// push_back - -namespace detail { - -template -struct type_list_push_back_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_back_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_back = detail::type_list_push_back_impl::type; - -// split - -namespace detail { - -template typename List, std::size_t Idx, std::size_t N, typename... Types> -struct split_impl; - -template typename List, std::size_t Idx, std::size_t N> -struct split_impl { - using first_list = List<>; - using second_list = List<>; -}; - -template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> -struct split_impl : split_impl { - using base = split_impl; - using first_list = - units::conditional < - Idx::type, typename base::first_list>; - using second_list = - units::conditional < - Idx::type>; -}; - -} // namespace detail - -template -struct type_list_split; - -template typename List, std::size_t N, typename... Types> -struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; -}; - -// split_half - -template -struct type_list_split_half; - -template typename List, typename... Types> -struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - -// merge_sorted - -namespace detail { - -template typename Pred> -struct type_list_merge_sorted_impl; - -template typename List, typename... Lhs, template typename Pred> -struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; -}; - -template typename List, typename... Rhs, template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = List; -}; - -template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = units::conditional< - Pred::value, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; -}; - -} // namespace detail - -template typename Pred> -using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - - -// sort - -namespace detail { - -template typename Pred> -struct type_list_sort_impl; - -template typename List, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List<>; -}; - -template typename List, typename T, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List; -}; - -template typename List, typename... Types, template typename Pred> -struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; -}; - -} // namespace detail - -template typename Pred> -using type_list_sort = detail::type_list_sort_impl::type; - -} // namespace 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 deleted file mode 100644 index 737e2367..00000000 --- a/test/metabench/list/type_list_conditional_alias_hard.cpp.erb +++ /dev/null @@ -1,35 +0,0 @@ -#include "type_list_conditional_alias_hard.h" - -template -using dim_id = std::integral_constant; - -template -using dim_id_less = std::bool_constant; - - -template -struct dimension; - -<% (1..10).each do |k| %> -struct test<%= k %> { - -<% (1..n).each do |i| %> -using <%= "dim#{i}" %> = dimension<<%= - xs = ((1)..(i)).map { |j| "dim_id<#{k*n+i+j}>" } - rng = Random.new(i) - xs.shuffle(random: rng).join(', ') -%>>; -#if defined(METABENCH) -using <%= "result#{i}" %> = units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>; -#else -using <%= "result#{i}" %> = void; -#endif -<% end %> - -}; - -<% end %> - -int main() -{ -} diff --git a/test/metabench/list/type_list_conditional_alias_hard.h b/test/metabench/list/type_list_conditional_alias_hard.h deleted file mode 100644 index e81eb85c..00000000 --- a/test/metabench/list/type_list_conditional_alias_hard.h +++ /dev/null @@ -1,197 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include - -namespace units { - -template -struct conditional { - template - using type = F; -}; - -template<> -struct conditional { - template - using type = T; -}; - -namespace detail { - -template -inline constexpr bool is_type_list = false; - -template typename T, typename... Types> -inline constexpr bool is_type_list> = true; - -} // namespace detail - -template -concept TypeList = detail::is_type_list; - -// push_front - -namespace detail { - -template -struct type_list_push_front_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_front_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_front = detail::type_list_push_front_impl::type; - -// push_back - -namespace detail { - -template -struct type_list_push_back_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_back_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_back = detail::type_list_push_back_impl::type; - -// split - -namespace detail { - -template typename List, std::size_t Idx, std::size_t N, typename... Types> -struct split_impl; - -template typename List, std::size_t Idx, std::size_t N> -struct split_impl { - using first_list = List<>; - using second_list = List<>; -}; - -template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> -struct split_impl : split_impl { - using base = split_impl; - using first_list = - conditional < Idx::template type::type, - typename base::first_list>; - using second_list = - conditional < Idx::template type::type>; -}; - -} // namespace detail - -template -struct type_list_split; - -template typename List, std::size_t N, typename... Types> -struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; -}; - -// split_half - -template -struct type_list_split_half; - -template typename List, typename... Types> -struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - -// merge_sorted - -namespace detail { - -template typename Pred> -struct type_list_merge_sorted_impl; - -template typename List, typename... Lhs, template typename Pred> -struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; -}; - -template typename List, typename... Rhs, template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = List; -}; - -template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = units::conditional::value>::template type< - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; -}; - -} // namespace detail - -template typename Pred> -using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - - -// sort - -namespace detail { - -template typename Pred> -struct type_list_sort_impl; - -template typename List, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List<>; -}; - -template typename List, typename T, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List; -}; - -template typename List, typename... Types, template typename Pred> -struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; -}; - -} // namespace detail - -template typename Pred> -using type_list_sort = detail::type_list_sort_impl::type; - -} // namespace units diff --git a/test/metabench/list/type_list_conditional_std.cpp.erb b/test/metabench/list/type_list_conditional_std.cpp.erb deleted file mode 100644 index 772c689b..00000000 --- a/test/metabench/list/type_list_conditional_std.cpp.erb +++ /dev/null @@ -1,35 +0,0 @@ -#include "type_list_conditional_std.h" - -template -using dim_id = std::integral_constant; - -template -using dim_id_less = std::bool_constant; - - -template -struct dimension; - -<% (1..10).each do |k| %> -struct test<%= k %> { - -<% (1..n).each do |i| %> -using <%= "dim#{i}" %> = dimension<<%= - xs = ((1)..(i)).map { |j| "dim_id<#{k*n+i+j}>" } - rng = Random.new(i) - xs.shuffle(random: rng).join(', ') -%>>; -#if defined(METABENCH) -using <%= "result#{i}" %> = units::type_list_sort<<%= "dim#{i}" %>, dim_id_less>; -#else -using <%= "result#{i}" %> = void; -#endif -<% end %> - -}; - -<% end %> - -int main() -{ -} diff --git a/test/metabench/list/type_list_conditional_std.h b/test/metabench/list/type_list_conditional_std.h deleted file mode 100644 index 84c4fce3..00000000 --- a/test/metabench/list/type_list_conditional_std.h +++ /dev/null @@ -1,186 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include - -namespace units { - -namespace detail { - -template -inline constexpr bool is_type_list = false; - -template typename T, typename... Types> -inline constexpr bool is_type_list> = true; - -} // namespace detail - -template -concept TypeList = detail::is_type_list; - -// push_front - -namespace detail { - -template -struct type_list_push_front_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_front_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_front = detail::type_list_push_front_impl::type; - -// push_back - -namespace detail { - -template -struct type_list_push_back_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_back_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_back = detail::type_list_push_back_impl::type; - -// split - -namespace detail { - -template typename List, std::size_t Idx, std::size_t N, typename... Types> -struct split_impl; - -template typename List, std::size_t Idx, std::size_t N> -struct split_impl { - using first_list = List<>; - using second_list = List<>; -}; - -template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> -struct split_impl : split_impl { - using base = split_impl; - using first_list = - std::conditional_t < - Idx::type, typename base::first_list>; - using second_list = - std::conditional_t < - Idx::type>; -}; - -} // namespace detail - -template -struct type_list_split; - -template typename List, std::size_t N, typename... Types> -struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; -}; - -// split_half - -template -struct type_list_split_half; - -template typename List, typename... Types> -struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - -// merge_sorted - -namespace detail { - -template typename Pred> -struct type_list_merge_sorted_impl; - -template typename List, typename... Lhs, template typename Pred> -struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; -}; - -template typename List, typename... Rhs, template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = List; -}; - -template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = std::conditional_t< - Pred::value, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; -}; - -} // namespace detail - -template typename Pred> -using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - - -// sort - -namespace detail { - -template typename Pred> -struct type_list_sort_impl; - -template typename List, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List<>; -}; - -template typename List, typename T, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List; -}; - -template typename List, typename... Types, template typename Pred> -struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; -}; - -} // namespace detail - -template typename Pred> -using type_list_sort = detail::type_list_sort_impl::type; - -} // namespace units diff --git a/test/metabench/make_dimension/CMakeLists.txt b/test/metabench/make_dimension/CMakeLists.txt deleted file mode 100644 index 354c7c0a..00000000 --- a/test/metabench/make_dimension/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Mateusz Pusz -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -cmake_minimum_required(VERSION 3.2) - -add_metabench_test(metabench.data.make_dimension.no_concepts "no concepts" no_concepts.cpp.erb "[1, 2, 3, 4, 6, 8, 10]") -add_metabench_test( - metabench.data.make_dimension.concepts_iface "concepts iface" concepts_iface.cpp.erb "[1, 2, 3, 4, 6, 8, 10]" -) -add_metabench_test( - metabench.data.make_dimension.concepts_all "concepts all" concepts_all.cpp.erb "[1, 2, 3, 4, 6, 8, 10]" -) -metabench_add_chart( - metabench.chart.make_dimension - TITLE "100 x make_dimension" - SUBTITLE "(lower is better)" - DATASETS metabench.data.make_dimension.no_concepts metabench.data.make_dimension.concepts_iface - metabench.data.make_dimension.concepts_all -) - -add_dependencies(metabench metabench.chart.make_dimension) diff --git a/test/metabench/make_dimension/concepts_all.cpp.erb b/test/metabench/make_dimension/concepts_all.cpp.erb deleted file mode 100644 index cb987f93..00000000 --- a/test/metabench/make_dimension/concepts_all.cpp.erb +++ /dev/null @@ -1,23 +0,0 @@ -#include "dimension_concepts_all.h" - -<% (1..100).each do |k| %> -struct test<%= k %> { - <% (1..n).each do |i| %> - static constexpr units::base_dimension dim<%= i %>{"dim<%= i %>"}; - <% end %> - -#if defined(METABENCH) - using dim = units::make_dimension_t<<%= - xs = ((1)..(n)).map { |j| "units::exponent" } - rng = Random.new(k) - xs.shuffle(random: rng).join(', ') - %>>; -#else - using dim = void; -#endif -}; -<% end %> - -int main() -{ -} diff --git a/test/metabench/make_dimension/concepts_iface.cpp.erb b/test/metabench/make_dimension/concepts_iface.cpp.erb deleted file mode 100644 index 2e63f485..00000000 --- a/test/metabench/make_dimension/concepts_iface.cpp.erb +++ /dev/null @@ -1,23 +0,0 @@ -#include "dimension_concepts_iface.h" - -<% (1..100).each do |k| %> -struct test<%= k %> { - <% (1..n).each do |i| %> - static constexpr units::base_dimension dim<%= i %>{"dim<%= i %>"}; - <% end %> - -#if defined(METABENCH) - using dim = units::make_dimension_t<<%= - xs = ((1)..(n)).map { |j| "units::exponent" } - rng = Random.new(k) - xs.shuffle(random: rng).join(', ') - %>>; -#else - using dim = void; -#endif -}; -<% end %> - -int main() -{ -} diff --git a/test/metabench/make_dimension/dimension_concepts_all.h b/test/metabench/make_dimension/dimension_concepts_all.h deleted file mode 100644 index 7d9ae1f0..00000000 --- a/test/metabench/make_dimension/dimension_concepts_all.h +++ /dev/null @@ -1,211 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "downcasting_concepts_all.h" -#include "ratio_concepts_all.h" -#include "type_list_concepts_all.h" -#include - -namespace units { - -struct base_dimension { - const char* name; -}; - -constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) -{ - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if (*p1 != *p2) return false; - } - return *p1 == *p2; -} - -constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) -{ - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if (*p1 < *p2) return true; - if (*p2 < *p1) return false; - } - return (*p1 == '\0') && (*p2 != '\0'); -} - -// base_dimension_less - -template - struct base_dimension_less : std::bool_constant < D1 {}; - -// exponent - -template -struct exponent { - static constexpr const base_dimension& dimension = BaseDimension; - static constexpr std::intmax_t num = Num; - static constexpr std::intmax_t den = Den; -}; - -// is_exponent -namespace detail { -template -inline constexpr bool is_exponent = false; - -template -inline constexpr bool is_exponent> = true; -} // namespace detail - -template -concept Exponent = detail::is_exponent; - -// exp_dim_id_less - -template -struct exponent_less : base_dimension_less {}; - -// exponent_invert - -template -struct exponent_invert; - -template -struct exponent_invert> { - using type = exponent; -}; - -template -using exponent_invert_t = exponent_invert::type; - -// dimension - -template -struct dimension : downcast_base> {}; - -// is_dimension -namespace detail { - -template -inline constexpr bool is_dimension = false; - -template -inline constexpr bool is_dimension> = true; - -} // namespace detail - -template -concept Dimension = std::is_empty_v && detail::is_dimension>; - - -// dim_invert - -template -struct dim_invert; - -template -struct dim_invert> : std::type_identity...>>> {}; - -template -using dim_invert_t = dim_invert::type; - - -// make_dimension - -namespace detail { - -template -struct dim_consolidate; - -template -using dim_consolidate_t = dim_consolidate::type; - -template<> -struct dim_consolidate> { - using type = dimension<>; -}; - -template -struct dim_consolidate> { - using type = dimension; -}; - -template -struct dim_consolidate> { - using rest = dim_consolidate_t>; - using type = conditional>, dimension, type_list_push_front>; -}; - -template -struct dim_consolidate, exponent, ERest...>> { - using r1 = std::ratio; - using r2 = std::ratio; - using r = std::ratio_add; - using type = conditional>, - dim_consolidate_t, ERest...>>>; -}; - -} // namespace detail - -template -struct make_dimension { - using type = detail::dim_consolidate_t, exponent_less>>; -}; - -template -using make_dimension_t = make_dimension::type; - -template -struct merge_dimension { - using type = detail::dim_consolidate_t>; -}; - -template -using merge_dimension_t = merge_dimension::type; - -// dimension_multiply - -template -struct dimension_multiply; - -template -struct dimension_multiply, dimension> : - std::type_identity, dimension>>> {}; - -template -using dimension_multiply_t = dimension_multiply::type; - -// dimension_divide - -template -struct dimension_divide; - -template -struct dimension_divide, dimension> : - dimension_multiply, dimension...>> {}; - -template -using dimension_divide_t = dimension_divide::type; - -} // namespace units diff --git a/test/metabench/make_dimension/dimension_concepts_iface.h b/test/metabench/make_dimension/dimension_concepts_iface.h deleted file mode 100644 index 44b20ce5..00000000 --- a/test/metabench/make_dimension/dimension_concepts_iface.h +++ /dev/null @@ -1,211 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "downcasting_concepts_all.h" -#include "ratio_concepts_iface.h" -#include "type_list_concepts_iface.h" -#include - -namespace units { - -struct base_dimension { - const char* name; -}; - -constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) -{ - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if (*p1 != *p2) return false; - } - return *p1 == *p2; -} - -constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) -{ - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if (*p1 < *p2) return true; - if (*p2 < *p1) return false; - } - return (*p1 == '\0') && (*p2 != '\0'); -} - -// base_dimension_less - -template - struct base_dimension_less : std::bool_constant < D1 {}; - -// exponent - -template -struct exponent { - static constexpr const base_dimension& dimension = BaseDimension; - static constexpr int num = Num; - static constexpr int den = Den; -}; - -// is_exponent -namespace detail { -template -inline constexpr bool is_exponent = false; - -template -inline constexpr bool is_exponent> = true; -} // namespace detail - -template -concept Exponent = detail::is_exponent; - -// exp_dim_id_less - -template -struct exponent_less : base_dimension_less {}; - -// exponent_invert - -template -struct exponent_invert; - -template -struct exponent_invert> { - using type = exponent; -}; - -template -using exponent_invert_t = exponent_invert::type; - -// dimension - -template -struct dimension : downcast_base> {}; - -// is_dimension -namespace detail { - -template -inline constexpr bool is_dimension = false; - -template -inline constexpr bool is_dimension> = true; - -} // namespace detail - -template -concept Dimension = std::is_empty_v && detail::is_dimension>; - - -// dim_invert - -template -struct dim_invert; - -template -struct dim_invert> : std::type_identity...>>> {}; - -template -using dim_invert_t = dim_invert::type; - - -// make_dimension - -namespace detail { - -template -struct dim_consolidate; - -template -using dim_consolidate_t = dim_consolidate::type; - -template<> -struct dim_consolidate> { - using type = dimension<>; -}; - -template -struct dim_consolidate> { - using type = dimension; -}; - -template -struct dim_consolidate> { - using rest = dim_consolidate_t>; - using type = conditional>, dimension, type_list_push_front>; -}; - -template -struct dim_consolidate, exponent, ERest...>> { - using r1 = std::ratio; - using r2 = std::ratio; - using r = std::ratio_add; - using type = conditional>, - dim_consolidate_t, ERest...>>>; -}; - -} // namespace detail - -template -struct make_dimension { - using type = detail::dim_consolidate_t, exponent_less>>; -}; - -template -using make_dimension_t = make_dimension::type; - -template -struct merge_dimension { - using type = detail::dim_consolidate_t>; -}; - -template -using merge_dimension_t = merge_dimension::type; - -// dimension_multiply - -template -struct dimension_multiply; - -template -struct dimension_multiply, dimension> : - std::type_identity, dimension>>> {}; - -template -using dimension_multiply_t = dimension_multiply::type; - -// dimension_divide - -template -struct dimension_divide; - -template -struct dimension_divide, dimension> : - dimension_multiply, dimension...>> {}; - -template -using dimension_divide_t = dimension_divide::type; - -} // namespace units diff --git a/test/metabench/make_dimension/dimension_no_concepts.h b/test/metabench/make_dimension/dimension_no_concepts.h deleted file mode 100644 index d8706535..00000000 --- a/test/metabench/make_dimension/dimension_no_concepts.h +++ /dev/null @@ -1,184 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "downcasting_no_concepts.h" -#include "ratio_no_concepts.h" -#include "type_list_no_concepts.h" -#include - -namespace units { - -struct base_dimension { - const char* name; -}; - -constexpr bool operator==(const base_dimension& lhs, const base_dimension& rhs) -{ - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if (*p1 != *p2) return false; - } - return *p1 == *p2; -} - -constexpr bool operator<(const base_dimension& lhs, const base_dimension& rhs) -{ - const char* p1 = lhs.name; - const char* p2 = rhs.name; - for (; (*p1 != '\0') && (*p2 != '\0'); ++p1, (void)++p2) { - if (*p1 < *p2) return true; - if (*p2 < *p1) return false; - } - return (*p1 == '\0') && (*p2 != '\0'); -} - -// base_dimension_less - -template - struct base_dimension_less : std::bool_constant < D1 {}; - -// exponent - -template -struct exponent { - static constexpr const base_dimension& dimension = BaseDimension; - static constexpr std::intmax_t num = Num; - static constexpr std::intmax_t den = Den; -}; - -// exp_dim_id_less - -template -struct exponent_less : base_dimension_less {}; - -// exponent_invert - -template -struct exponent_invert; - -template -struct exponent_invert> { - using type = exponent; -}; - -template -using exponent_invert_t = exponent_invert::type; - -// dimension - -template -struct dimension : downcast_base> {}; - -// dim_invert - -template -struct dim_invert; - -template -struct dim_invert> : std::type_identity...>>> {}; - -template -using dim_invert_t = dim_invert::type; - - -// make_dimension - -namespace detail { - -template -struct dim_consolidate; - -template -using dim_consolidate_t = dim_consolidate::type; - -template<> -struct dim_consolidate> { - using type = dimension<>; -}; - -template -struct dim_consolidate> { - using type = dimension; -}; - -template -struct dim_consolidate> { - using rest = dim_consolidate_t>; - using type = conditional>, dimension, type_list_push_front>; -}; - -template -struct dim_consolidate, exponent, ERest...>> { - using r1 = std::ratio; - using r2 = std::ratio; - using r = std::ratio_add; - using type = conditional>, - dim_consolidate_t, ERest...>>>; -}; - -} // namespace detail - -template -struct make_dimension { - using type = detail::dim_consolidate_t, exponent_less>>; -}; - -template -using make_dimension_t = make_dimension::type; - -template -struct merge_dimension { - using type = detail::dim_consolidate_t>; -}; - -template -using merge_dimension_t = merge_dimension::type; - -// dimension_multiply - -template -struct dimension_multiply; - -template -struct dimension_multiply, dimension> : - std::type_identity, dimension>>> {}; - -template -using dimension_multiply_t = dimension_multiply::type; - -// dimension_divide - -template -struct dimension_divide; - -template -struct dimension_divide, dimension> : - dimension_multiply, dimension...>> {}; - -template -using dimension_divide_t = dimension_divide::type; - -} // namespace units diff --git a/test/metabench/make_dimension/downcasting_concepts_all.h b/test/metabench/make_dimension/downcasting_concepts_all.h deleted file mode 100644 index c08161c9..00000000 --- a/test/metabench/make_dimension/downcasting_concepts_all.h +++ /dev/null @@ -1,48 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "hacks.h" -#include - -namespace units { - -template -struct downcast_base { - using downcast_base_type = BaseType; -}; - -template -concept Downcastable = - requires { typename T::downcast_base_type; } && std::derived_from>; - -template -using downcast_base_t = T::downcast_base_type; - -template -struct downcast_traits : std::type_identity {}; - -template -using downcast_traits_t = downcast_traits::type; - -} // namespace units diff --git a/test/metabench/make_dimension/downcasting_no_concepts.h b/test/metabench/make_dimension/downcasting_no_concepts.h deleted file mode 100644 index 8b7bec8f..00000000 --- a/test/metabench/make_dimension/downcasting_no_concepts.h +++ /dev/null @@ -1,44 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "hacks.h" -#include - -namespace units { - -template -struct downcast_base { - using downcast_base_type = BaseType; -}; - -template -using downcast_base_t = T::downcast_base_type; - -template -struct downcast_traits : std::type_identity {}; - -template -using downcast_traits_t = downcast_traits::type; - -} // namespace units diff --git a/test/metabench/make_dimension/hacks.h b/test/metabench/make_dimension/hacks.h deleted file mode 100644 index b95278a9..00000000 --- a/test/metabench/make_dimension/hacks.h +++ /dev/null @@ -1,36 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include - -namespace std { - -// concepts -using concepts::convertible_to; -using concepts::derived_from; -using concepts::regular; -using concepts::same_as; -using concepts::totally_ordered; - -} // namespace std diff --git a/test/metabench/make_dimension/no_concepts.cpp.erb b/test/metabench/make_dimension/no_concepts.cpp.erb deleted file mode 100644 index 4f010f0d..00000000 --- a/test/metabench/make_dimension/no_concepts.cpp.erb +++ /dev/null @@ -1,23 +0,0 @@ -#include "dimension_no_concepts.h" - -<% (1..100).each do |k| %> -struct test<%= k %> { - <% (1..n).each do |i| %> - static constexpr units::base_dimension dim<%= i %>{"dim<%= i %>"}; - <% end %> - -#if defined(METABENCH) - using dim = units::make_dimension_t<<%= - xs = ((1)..(n)).map { |j| "units::exponent" } - rng = Random.new(k) - xs.shuffle(random: rng).join(', ') - %>>; -#else - using dim = void; -#endif -}; -<% end %> - -int main() -{ -} diff --git a/test/metabench/make_dimension/ratio_concepts_all.h b/test/metabench/make_dimension/ratio_concepts_all.h deleted file mode 100644 index 344a8511..00000000 --- a/test/metabench/make_dimension/ratio_concepts_all.h +++ /dev/null @@ -1,140 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "hacks.h" -#include -#include -#include - -namespace units { - -namespace detail { - -template -[[nodiscard]] constexpr T abs(T v) noexcept -{ - return v < 0 ? -v : v; -} - -} // namespace detail - -template -struct ratio { - static_assert(Den != 0, "zero denominator"); - static_assert(-INTMAX_MAX <= Num, "numerator too negative"); - static_assert(-INTMAX_MAX <= Den, "denominator too negative"); - - static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); - static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); - - using type = ratio; -}; - -// is_ratio - -namespace detail { - -template -inline constexpr bool is_ratio = false; - -template -inline constexpr bool is_ratio> = true; - -} // namespace detail - -template -concept Ratio = detail::is_ratio; - -// ratio_multiply - -namespace detail { - -static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) -{ - constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); - - const std::uintmax_t a0 = detail::abs(lhs) % c; - const std::uintmax_t a1 = detail::abs(lhs) / c; - const std::uintmax_t b0 = detail::abs(rhs) % c; - const std::uintmax_t b1 = detail::abs(rhs) / c; - - Expects(a1 == 0 || b1 == 0); // overflow in multiplication - Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication - Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication - Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication - - return lhs * rhs; -} - -template -struct ratio_multiply_impl { -private: - static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); - static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); - -public: - using type = ratio; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; -}; - -} // namespace detail - -template -using ratio_multiply = detail::ratio_multiply_impl::type; - -// ratio_divide - -namespace detail { - -template -struct ratio_divide_impl { - static_assert(R2::num != 0, "division by 0"); - using type = ratio_multiply>; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; -}; - -} // namespace detail - -template -using ratio_divide = detail::ratio_divide_impl::type; - -// common_ratio - -namespace detail { - -template -struct common_ratio_impl { - static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); - static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); - using type = ratio; -}; - -} // namespace detail - -template -using common_ratio = detail::common_ratio_impl::type; - -} // namespace units diff --git a/test/metabench/make_dimension/ratio_concepts_iface.h b/test/metabench/make_dimension/ratio_concepts_iface.h deleted file mode 100644 index fe59c2ca..00000000 --- a/test/metabench/make_dimension/ratio_concepts_iface.h +++ /dev/null @@ -1,140 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "hacks.h" -#include -#include -#include - -namespace units { - -namespace detail { - -template -[[nodiscard]] constexpr T abs(T v) noexcept -{ - return v < 0 ? -v : v; -} - -} // namespace detail - -template -struct ratio { - static_assert(Den != 0, "zero denominator"); - static_assert(-INTMAX_MAX <= Num, "numerator too negative"); - static_assert(-INTMAX_MAX <= Den, "denominator too negative"); - - static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); - static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); - - using type = ratio; -}; - -// is_ratio - -namespace detail { - -template -inline constexpr bool is_ratio = false; - -template -inline constexpr bool is_ratio> = true; - -} // namespace detail - -template -concept Ratio = detail::is_ratio; - -// ratio_multiply - -namespace detail { - -static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) -{ - constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); - - const std::uintmax_t a0 = detail::abs(lhs) % c; - const std::uintmax_t a1 = detail::abs(lhs) / c; - const std::uintmax_t b0 = detail::abs(rhs) % c; - const std::uintmax_t b1 = detail::abs(rhs) / c; - - Expects(a1 == 0 || b1 == 0); // overflow in multiplication - Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication - Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication - Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication - - return lhs * rhs; -} - -template -struct ratio_multiply_impl { -private: - static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); - static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); - -public: - using type = ratio; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; -}; - -} // namespace detail - -template -using ratio_multiply = detail::ratio_multiply_impl::type; - -// ratio_divide - -namespace detail { - -template -struct ratio_divide_impl { - static_assert(R2::num != 0, "division by 0"); - using type = ratio_multiply>; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; -}; - -} // namespace detail - -template -using ratio_divide = detail::ratio_divide_impl::type; - -// common_ratio - -namespace detail { - -template -struct common_ratio_impl { - static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); - static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); - using type = ratio; -}; - -} // namespace detail - -template -using common_ratio = detail::common_ratio_impl::type; - -} // namespace units diff --git a/test/metabench/make_dimension/ratio_no_concepts.h b/test/metabench/make_dimension/ratio_no_concepts.h deleted file mode 100644 index fa1b7ba9..00000000 --- a/test/metabench/make_dimension/ratio_no_concepts.h +++ /dev/null @@ -1,125 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "hacks.h" -#include -#include -#include - -namespace units { - -namespace detail { - -template -[[nodiscard]] constexpr T abs(T v) noexcept -{ - return v < 0 ? -v : v; -} - -} // namespace detail - -template -struct ratio { - static_assert(Den != 0, "zero denominator"); - static_assert(-INTMAX_MAX <= Num, "numerator too negative"); - static_assert(-INTMAX_MAX <= Den, "denominator too negative"); - - static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); - static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); - - using type = ratio; -}; - -// ratio_multiply - -namespace detail { - -static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) -{ - constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); - - const std::uintmax_t a0 = detail::abs(lhs) % c; - const std::uintmax_t a1 = detail::abs(lhs) / c; - const std::uintmax_t b0 = detail::abs(rhs) % c; - const std::uintmax_t b1 = detail::abs(rhs) / c; - - Expects(a1 == 0 || b1 == 0); // overflow in multiplication - Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication - Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication - Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication - - return lhs * rhs; -} - -template -struct ratio_multiply_impl { -private: - static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); - static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); - -public: - using type = ratio; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; -}; - -} // namespace detail - -template -using ratio_multiply = detail::ratio_multiply_impl::type; - -// ratio_divide - -namespace detail { - -template -struct ratio_divide_impl { - static_assert(R2::num != 0, "division by 0"); - using type = ratio_multiply>; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; -}; - -} // namespace detail - -template -using ratio_divide = detail::ratio_divide_impl::type; - -// common_ratio - -namespace detail { - -template -struct common_ratio_impl { - static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); - static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); - using type = ratio; -}; - -} // namespace detail - -template -using common_ratio = detail::common_ratio_impl::type; - -} // namespace units diff --git a/test/metabench/make_dimension/type_list_concepts_all.h b/test/metabench/make_dimension/type_list_concepts_all.h deleted file mode 100644 index 80392b3e..00000000 --- a/test/metabench/make_dimension/type_list_concepts_all.h +++ /dev/null @@ -1,186 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "type_traits.h" - -namespace units { - -namespace detail { - -template -inline constexpr bool is_type_list = false; - -template typename T, typename... Types> -inline constexpr bool is_type_list> = true; - -} // namespace detail - -template -concept TypeList = detail::is_type_list; - -// push_front - -namespace detail { - -template -struct type_list_push_front_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_front_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_front = detail::type_list_push_front_impl::type; - -// push_back - -namespace detail { - -template -struct type_list_push_back_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_back_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_back = detail::type_list_push_back_impl::type; - -// split - -namespace detail { - -template typename List, std::size_t Idx, std::size_t N, typename... Types> -struct split_impl; - -template typename List, std::size_t Idx, std::size_t N> -struct split_impl { - using first_list = List<>; - using second_list = List<>; -}; - -template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> -struct split_impl : split_impl { - using base = split_impl; - using first_list = - conditional < - Idx::type, typename base::first_list>; - using second_list = - conditional < - Idx::type>; -}; - -} // namespace detail - -template -struct type_list_split; - -template typename List, std::size_t N, typename... Types> -struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; -}; - -// split_half - -template -struct type_list_split_half; - -template typename List, typename... Types> -struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - -// merge_sorted - -namespace detail { - -template typename Pred> -struct type_list_merge_sorted_impl; - -template typename List, typename... Lhs, template typename Pred> -struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; -}; - -template typename List, typename... Rhs, template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = List; -}; - -template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = conditional< - Pred::value, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; -}; - -} // namespace detail - -template typename Pred> -using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - - -// sort - -namespace detail { - -template typename Pred> -struct type_list_sort_impl; - -template typename List, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List<>; -}; - -template typename List, typename T, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List; -}; - -template typename List, typename... Types, template typename Pred> -struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; -}; - -} // namespace detail - -template typename Pred> -using type_list_sort = detail::type_list_sort_impl::type; - -} // namespace units diff --git a/test/metabench/make_dimension/type_list_concepts_iface.h b/test/metabench/make_dimension/type_list_concepts_iface.h deleted file mode 100644 index 0737c88b..00000000 --- a/test/metabench/make_dimension/type_list_concepts_iface.h +++ /dev/null @@ -1,186 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "type_traits.h" - -namespace units { - -namespace detail { - -template -inline constexpr bool is_type_list = false; - -template typename T, typename... Types> -inline constexpr bool is_type_list> = true; - -} // namespace detail - -template -concept TypeList = detail::is_type_list; - -// push_front - -namespace detail { - -template -struct type_list_push_front_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_front_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_front = detail::type_list_push_front_impl::type; - -// push_back - -namespace detail { - -template -struct type_list_push_back_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_back_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_back = detail::type_list_push_back_impl::type; - -// split - -namespace detail { - -template typename List, std::size_t Idx, std::size_t N, typename... Types> -struct split_impl; - -template typename List, std::size_t Idx, std::size_t N> -struct split_impl { - using first_list = List<>; - using second_list = List<>; -}; - -template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> -struct split_impl : split_impl { - using base = split_impl; - using first_list = - conditional < - Idx::type, typename base::first_list>; - using second_list = - conditional < - Idx::type>; -}; - -} // namespace detail - -template -struct type_list_split; - -template typename List, std::size_t N, typename... Types> -struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; -}; - -// split_half - -template -struct type_list_split_half; - -template typename List, typename... Types> -struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - -// merge_sorted - -namespace detail { - -template typename Pred> -struct type_list_merge_sorted_impl; - -template typename List, typename... Lhs, template typename Pred> -struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; -}; - -template typename List, typename... Rhs, template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = List; -}; - -template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = conditional< - Pred::value, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; -}; - -} // namespace detail - -template typename Pred> -using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - - -// sort - -namespace detail { - -template typename Pred> -struct type_list_sort_impl; - -template typename List, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List<>; -}; - -template typename List, typename T, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List; -}; - -template typename List, typename... Types, template typename Pred> -struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; -}; - -} // namespace detail - -template typename Pred> -using type_list_sort = detail::type_list_sort_impl::type; - -} // namespace units diff --git a/test/metabench/make_dimension/type_list_no_concepts.h b/test/metabench/make_dimension/type_list_no_concepts.h deleted file mode 100644 index 82e40f40..00000000 --- a/test/metabench/make_dimension/type_list_no_concepts.h +++ /dev/null @@ -1,173 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include "type_traits.h" - -namespace units { - -// push_front - -namespace detail { - -template -struct type_list_push_front_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_front_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_front = detail::type_list_push_front_impl::type; - -// push_back - -namespace detail { - -template -struct type_list_push_back_impl; - -template typename List, typename... OldTypes, typename... NewTypes> -struct type_list_push_back_impl, NewTypes...> { - using type = List; -}; - -} // namespace detail - -template -using type_list_push_back = detail::type_list_push_back_impl::type; - -// split - -namespace detail { - -template typename List, std::size_t Idx, std::size_t N, typename... Types> -struct split_impl; - -template typename List, std::size_t Idx, std::size_t N> -struct split_impl { - using first_list = List<>; - using second_list = List<>; -}; - -template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> -struct split_impl : split_impl { - using base = split_impl; - using first_list = - conditional < - Idx::type, typename base::first_list>; - using second_list = - conditional < - Idx::type>; -}; - -} // namespace detail - -template -struct type_list_split; - -template typename List, std::size_t N, typename... Types> -struct type_list_split, N> { - static_assert(N <= sizeof...(Types), "Invalid index provided"); - using split = detail::split_impl; - using first_list = split::first_list; - using second_list = split::second_list; -}; - -// split_half - -template -struct type_list_split_half; - -template typename List, typename... Types> -struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - -// merge_sorted - -namespace detail { - -template typename Pred> -struct type_list_merge_sorted_impl; - -template typename List, typename... Lhs, template typename Pred> -struct type_list_merge_sorted_impl, List<>, Pred> { - using type = List; -}; - -template typename List, typename... Rhs, template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = List; -}; - -template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, - template typename Pred> -struct type_list_merge_sorted_impl, List, Pred> { - using type = conditional< - Pred::value, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type, - typename type_list_push_front_impl< - typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type>; -}; - -} // namespace detail - -template typename Pred> -using type_list_merge_sorted = detail::type_list_merge_sorted_impl::type; - - -// sort - -namespace detail { - -template typename Pred> -struct type_list_sort_impl; - -template typename List, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List<>; -}; - -template typename List, typename T, template typename Pred> -struct type_list_sort_impl, Pred> { - using type = List; -}; - -template typename List, typename... Types, template typename Pred> -struct type_list_sort_impl, Pred> { - using types = List; - using split = type_list_split_half>; - using left = type_list_sort_impl::type; - using right = type_list_sort_impl::type; - using type = type_list_merge_sorted_impl::type; -}; - -} // namespace detail - -template typename Pred> -using type_list_sort = detail::type_list_sort_impl::type; - -} // namespace units diff --git a/test/metabench/make_dimension/type_traits.h b/test/metabench/make_dimension/type_traits.h deleted file mode 100644 index 35d7e162..00000000 --- a/test/metabench/make_dimension/type_traits.h +++ /dev/null @@ -1,48 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include - -namespace units { - -namespace detail { - -template -struct conditional_impl { - template - using type = F; -}; - -template<> -struct conditional_impl { - template - using type = T; -}; - -} // namespace detail - -template -using conditional = TYPENAME detail::conditional_impl::template type; - -} // namespace units diff --git a/test/metabench/ratio/CMakeLists.txt b/test/metabench/ratio/CMakeLists.txt deleted file mode 100644 index a2c38c31..00000000 --- a/test/metabench/ratio/CMakeLists.txt +++ /dev/null @@ -1,86 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Mateusz Pusz -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -cmake_minimum_required(VERSION 3.2) - -add_metabench_test( - metabench.data.ratio.create.std_ratio "std::ratio" create_std_ratio.cpp.erb "[1000, 2500, 5000, 7500, 10000]" -) -add_metabench_test( - metabench.data.ratio.create.ratio_type_constexpr "ratio with constexpr" create_ratio_type_constexpr.cpp.erb - "[1000, 2500, 5000, 7500, 10000]" -) -metabench_add_chart( - metabench.chart.ratio.create - TITLE "Creation of 2*N ratios" - SUBTITLE "(lower is better)" - DATASETS metabench.data.ratio.create.std_ratio metabench.data.ratio.create.ratio_type_constexpr -) - -add_metabench_test( - metabench.data.ratio.multiply_divide.std_ratio "std::ratio" multiply_divide_std_ratio.cpp.erb - "[10, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 5000]" -) -add_metabench_test( - metabench.data.ratio.multiply_divide.ratio_type_constexpr "ratio constexpr" - multiply_divide_ratio_type_constexpr.cpp.erb "[10, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 5000]" -) -metabench_add_chart( - metabench.chart.ratio.multiply_divide - TITLE "N ratio multiply + divide operations" - SUBTITLE "(lower is better)" - DATASETS metabench.data.ratio.multiply_divide.std_ratio metabench.data.ratio.multiply_divide.ratio_type_constexpr -) - -add_metabench_test( - metabench.data.ratio.common_ratio.std_ratio "std::ratio" common_ratio_std_ratio.cpp.erb - "[10, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 5000]" -) -add_metabench_test( - metabench.data.ratio.common_ratio.ratio_type_constexpr "ratio constexpr" common_ratio_ratio_type_constexpr.cpp.erb - "[10, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 5000]" -) -metabench_add_chart( - metabench.chart.ratio.common_ratio - TITLE "N common_ratio operations" - SUBTITLE "(lower is better)" - DATASETS metabench.data.ratio.common_ratio.std_ratio metabench.data.ratio.common_ratio.ratio_type_constexpr -) - -add_metabench_test(metabench.data.ratio.all.std_ratio "std::ratio" all_std_ratio.cpp.erb "[10, 50, 100, 500, 1000]") -add_metabench_test( - metabench.data.ratio.all.ratio_type_constexpr "ratio with constexpr" all_ratio_type_constexpr.cpp.erb - "[10, 50, 100, 500, 1000]" -) -metabench_add_chart( - metabench.chart.ratio.all - TITLE "N x all ratio operations" - SUBTITLE "(lower is better)" - DATASETS metabench.data.ratio.all.std_ratio metabench.data.ratio.all.ratio_type_constexpr -) - -add_custom_target( - metabench.chart.ratio DEPENDS metabench.chart.ratio.create metabench.chart.ratio.multiply_divide - metabench.chart.ratio.common_ratio metabench.chart.ratio.all -) - -add_dependencies(metabench metabench.chart.ratio) diff --git a/test/metabench/ratio/all_ratio_type_constexpr.cpp.erb b/test/metabench/ratio/all_ratio_type_constexpr.cpp.erb deleted file mode 100644 index aa036f58..00000000 --- a/test/metabench/ratio/all_ratio_type_constexpr.cpp.erb +++ /dev/null @@ -1,26 +0,0 @@ -#include "ratio_type_constexpr.h" - -<% (1..n).each do |i| %> - struct test<%= i %> { -#if defined(METABENCH) - using r1 = units::ratio<<%= 2 * i - 1 %>, <%= 2 * n %>>; - using r2 = units::ratio<<%= 2 * i %>, <%= 2 * n %>>; - - using r3 = units::ratio_multiply; - using r4 = units::ratio_divide; - - using r5 = units::common_ratio_t; -#else - using r1 = void; - using r2 = void; - using r3 = void; - using r4 = void; - using r5 = void; -#endif - }; -<% end %> - - -int main() -{ -} diff --git a/test/metabench/ratio/all_std_ratio.cpp.erb b/test/metabench/ratio/all_std_ratio.cpp.erb deleted file mode 100644 index 2d34bc82..00000000 --- a/test/metabench/ratio/all_std_ratio.cpp.erb +++ /dev/null @@ -1,26 +0,0 @@ -#include "std_ratio.h" - -<% (1..n).each do |i| %> - struct test<%= i %> { -#if defined(METABENCH) - using r1 = std::ratio<<%= 2 * i - 1 %>, <%= 2 * n %>>; - using r2 = std::ratio<<%= 2 * i %>, <%= 2 * n %>>; - - using r3 = std::ratio_multiply; - using r4 = std::ratio_divide; - - using r5 = units::common_ratio_t; -#else - using r1 = void; - using r2 = void; - using r3 = void; - using r4 = void; - using r5 = void; -#endif - }; -<% end %> - - -int main() -{ -} diff --git a/test/metabench/ratio/common_ratio_ratio_type_constexpr.cpp.erb b/test/metabench/ratio/common_ratio_ratio_type_constexpr.cpp.erb deleted file mode 100644 index 23daae35..00000000 --- a/test/metabench/ratio/common_ratio_ratio_type_constexpr.cpp.erb +++ /dev/null @@ -1,19 +0,0 @@ -#include "ratio_type_constexpr.h" - -<% (1..n).each do |i| %> - struct test<%= i %> { - using r1 = units::ratio<<%= 2 * i - 1 %>, <%= 2 * n %>>; - using r2 = units::ratio<<%= 2 * i %>, <%= 2 * n %>>; - -#if defined(METABENCH) - using r3 = units::common_ratio_t; -#else - using r3 = void; -#endif - }; -<% end %> - - -int main() -{ -} diff --git a/test/metabench/ratio/common_ratio_std_ratio.cpp.erb b/test/metabench/ratio/common_ratio_std_ratio.cpp.erb deleted file mode 100644 index 5885f4f9..00000000 --- a/test/metabench/ratio/common_ratio_std_ratio.cpp.erb +++ /dev/null @@ -1,19 +0,0 @@ -#include "std_ratio.h" - -<% (1..n).each do |i| %> - struct test<%= i %> { - using r1 = std::ratio<<%= 2 * i - 1 %>, <%= 2 * n %>>; - using r2 = std::ratio<<%= 2 * i %>, <%= 2 * n %>>; - -#if defined(METABENCH) - using r3 = units::common_ratio_t; -#else - using r3 = void; -#endif - }; -<% end %> - - -int main() -{ -} diff --git a/test/metabench/ratio/create_ratio_type_constexpr.cpp.erb b/test/metabench/ratio/create_ratio_type_constexpr.cpp.erb deleted file mode 100644 index 145cc852..00000000 --- a/test/metabench/ratio/create_ratio_type_constexpr.cpp.erb +++ /dev/null @@ -1,18 +0,0 @@ -#include "ratio_type_constexpr.h" - -<% (1..n).each do |i| %> - struct test<%= i %> { -#if defined(METABENCH) - using r1 = units::ratio<<%= 2 * i - 1 %>, <%= 2 * n %>>; - using r2 = units::ratio<<%= 2 * i %>, <%= 2 * n %>>; -#else - using r1 = void; - using r2 = void; -#endif - }; -<% end %> - - -int main() -{ -} diff --git a/test/metabench/ratio/create_std_ratio.cpp.erb b/test/metabench/ratio/create_std_ratio.cpp.erb deleted file mode 100644 index eafe36a1..00000000 --- a/test/metabench/ratio/create_std_ratio.cpp.erb +++ /dev/null @@ -1,18 +0,0 @@ -#include - -<% (1..n).each do |i| %> - struct test<%= i %> { -#if defined(METABENCH) - using r1 = std::ratio<<%= 2 * i - 1 %>, <%= 2 * n %>>; - using r2 = std::ratio<<%= 2 * i %>, <%= 2 * n %>>; -#else - using r1 = void; - using r2 = void; -#endif - }; -<% end %> - - -int main() -{ -} diff --git a/test/metabench/ratio/multiply_divide_ratio_type_constexpr.cpp.erb b/test/metabench/ratio/multiply_divide_ratio_type_constexpr.cpp.erb deleted file mode 100644 index 9bdf1577..00000000 --- a/test/metabench/ratio/multiply_divide_ratio_type_constexpr.cpp.erb +++ /dev/null @@ -1,21 +0,0 @@ -#include "ratio_type_constexpr.h" - -<% (1..n).each do |i| %> - struct test<%= i %> { - using r1 = units::ratio<<%= 2 * i - 1 %>, <%= 2 * n %>>; - using r2 = units::ratio<<%= 2 * i %>, <%= 2 * n %>>; - -#if defined(METABENCH) - using r3 = units::ratio_multiply; - using r4 = units::ratio_divide; -#else - using r3 = void; - using r4 = void; -#endif - }; -<% end %> - - -int main() -{ -} diff --git a/test/metabench/ratio/multiply_divide_std_ratio.cpp.erb b/test/metabench/ratio/multiply_divide_std_ratio.cpp.erb deleted file mode 100644 index 5a5c2f17..00000000 --- a/test/metabench/ratio/multiply_divide_std_ratio.cpp.erb +++ /dev/null @@ -1,21 +0,0 @@ -#include - -<% (1..n).each do |i| %> - struct test<%= i %> { - using r1 = std::ratio<<%= 2 * i - 1 %>, <%= 2 * n %>>; - using r2 = std::ratio<<%= 2 * i %>, <%= 2 * n %>>; - -#if defined(METABENCH) - using r3 = std::ratio_multiply; - using r4 = std::ratio_divide; -#else - using r3 = void; - using r4 = void; -#endif - }; -<% end %> - - -int main() -{ -} diff --git a/test/metabench/ratio/ratio_type_constexpr.cpp.erb b/test/metabench/ratio/ratio_type_constexpr.cpp.erb deleted file mode 100644 index 2fe0c819..00000000 --- a/test/metabench/ratio/ratio_type_constexpr.cpp.erb +++ /dev/null @@ -1,20 +0,0 @@ -#include "ratio_type_constexpr.h" - -#if defined(METABENCH) -<% (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 r3 = units::ratio_multiply; - using r4 = units::ratio_divide; - - using r5 = units::common_ratio_t; - }; -<% end %> -#endif - - -int main() -{ -} diff --git a/test/metabench/ratio/ratio_type_constexpr.h b/test/metabench/ratio/ratio_type_constexpr.h deleted file mode 100644 index 86e2c0d6..00000000 --- a/test/metabench/ratio/ratio_type_constexpr.h +++ /dev/null @@ -1,128 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include -#include -#include -#include - -#define Expects(cond) \ - if (!(cond)) ::std::terminate(); - -namespace units { - -namespace detail { - -template -[[nodiscard]] constexpr T abs(T v) noexcept -{ - return v < 0 ? -v : v; -} - -} // namespace detail - -template -struct ratio { - static_assert(Den != 0, "zero denominator"); - static_assert(-INTMAX_MAX <= Num, "numerator too negative"); - static_assert(-INTMAX_MAX <= Den, "denominator too negative"); - - static constexpr std::intmax_t num = Num * (Den < 0 ? -1 : 1) / std::gcd(Num, Den); - static constexpr std::intmax_t den = detail::abs(Den) / std::gcd(Num, Den); - - using type = ratio; -}; - -// ratio_multiply - -namespace detail { - -static constexpr std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs) -{ - constexpr std::uintmax_t c = std::uintmax_t(1) << (sizeof(std::intmax_t) * 4); - - const std::uintmax_t a0 = detail::abs(lhs) % c; - const std::uintmax_t a1 = detail::abs(lhs) / c; - const std::uintmax_t b0 = detail::abs(rhs) % c; - const std::uintmax_t b1 = detail::abs(rhs) / c; - - Expects(a1 == 0 || b1 == 0); // overflow in multiplication - Expects(a0 * b1 + b0 * a1 < (c >> 1)); // overflow in multiplication - Expects(b0 * a0 <= INTMAX_MAX); // overflow in multiplication - Expects((a0 * b1 + b0 * a1) * c <= INTMAX_MAX - b0 * a0); // overflow in multiplication - - return lhs * rhs; -} - -template -struct ratio_multiply { -private: - static constexpr std::intmax_t gcd1 = std::gcd(R1::num, R2::den); - static constexpr std::intmax_t gcd2 = std::gcd(R2::num, R1::den); - -public: - using type = ratio; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; -}; - -} // namespace detail - -template -using ratio_multiply = typename detail::ratio_multiply::type; - -// ratio_divide - -namespace detail { - -template -struct ratio_divide { - static_assert(R2::num != 0, "division by 0"); - using type = ratio_multiply>; - static constexpr std::intmax_t num = type::num; - static constexpr std::intmax_t den = type::den; -}; - -} // namespace detail - -template -using ratio_divide = typename detail::ratio_divide::type; - -// common_ratio - -namespace detail { - -template -struct common_ratio_impl { - static constexpr std::intmax_t gcd_num = std::gcd(R1::num, R2::num); - static constexpr std::intmax_t gcd_den = std::gcd(R1::den, R2::den); - using type = ratio; -}; - -} // namespace detail - -template -using common_ratio_t = typename detail::common_ratio_impl::type; - -} // namespace units diff --git a/test/metabench/ratio/std_ratio.h b/test/metabench/ratio/std_ratio.h deleted file mode 100644 index 459b5acd..00000000 --- a/test/metabench/ratio/std_ratio.h +++ /dev/null @@ -1,63 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include -#include - -namespace units { - -// static_sign - -template -struct static_sign : std::integral_constant {}; - -// static_abs - -template -struct static_abs : std::integral_constant::value> {}; - -// static_gcd - -template -struct static_gcd : static_gcd {}; - -template -struct static_gcd : std::integral_constant::value> {}; - -template -struct static_gcd<0, Qn> : std::integral_constant::value> {}; - -// common_ratio - -template -struct common_ratio { - using gcd_num = static_gcd; - using gcd_den = static_gcd; - using type = std::ratio; -}; - -template -using common_ratio_t = typename common_ratio::type; - -} // namespace units