diff --git a/include/flux.hpp b/include/flux.hpp index 3721fa97..179b48f3 100644 --- a/include/flux.hpp +++ b/include/flux.hpp @@ -14,8 +14,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/include/flux/op/cartesian_power.hpp b/include/flux/op/cartesian_product_repeat.hpp similarity index 71% rename from include/flux/op/cartesian_power.hpp rename to include/flux/op/cartesian_product_repeat.hpp index 6f0df1c5..15ca4c56 100644 --- a/include/flux/op/cartesian_power.hpp +++ b/include/flux/op/cartesian_product_repeat.hpp @@ -5,8 +5,8 @@ // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef FLUX_OP_CARTESIAN_POWER_HPP_INCLUDED -#define FLUX_OP_CARTESIAN_POWER_HPP_INCLUDED +#ifndef FLUX_OP_CARTESIAN_PRODUCT_REPEAT_HPP_INCLUDED +#define FLUX_OP_CARTESIAN_PRODUCT_REPEAT_HPP_INCLUDED #include #include @@ -20,13 +20,13 @@ namespace flux { namespace detail { template -struct cartesian_power_adaptor - : inline_sequence_base> { +struct cartesian_product_repeat_adaptor + : inline_sequence_base> { private: FLUX_NO_UNIQUE_ADDRESS Base base_; public: - constexpr explicit cartesian_power_adaptor(Base&& base) + constexpr explicit cartesian_product_repeat_adaptor(Base&& base) : base_(FLUX_FWD(base)) {} @@ -42,7 +42,7 @@ struct cartesian_power_adaptor template -struct cartesian_power_fn { +struct cartesian_product_repeat_fn { template requires multipass_sequence @@ -52,7 +52,7 @@ struct cartesian_power_fn { if constexpr(PowN == 0) { return empty>; } else { - return cartesian_power_adaptor>( + return cartesian_product_repeat_adaptor>( FLUX_FWD(seq)); } } @@ -63,7 +63,7 @@ struct cartesian_power_fn { FLUX_EXPORT template -inline constexpr auto cartesian_power = detail::cartesian_power_fn{}; +inline constexpr auto cartesian_product_repeat = detail::cartesian_product_repeat_fn{}; } // end namespace flux diff --git a/include/flux/op/cartesian_power_map.hpp b/include/flux/op/cartesian_product_repeat_map.hpp similarity index 68% rename from include/flux/op/cartesian_power_map.hpp rename to include/flux/op/cartesian_product_repeat_map.hpp index f41e3296..64f78e0e 100644 --- a/include/flux/op/cartesian_power_map.hpp +++ b/include/flux/op/cartesian_product_repeat_map.hpp @@ -3,8 +3,8 @@ // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef FLUX_OP_CARTESIAN_POWER_MAP_HPP_INCLUDED -#define FLUX_OP_CARTESIAN_POWER_MAP_HPP_INCLUDED +#ifndef FLUX_OP_CARTESIAN_PRODUCT_REPEAT_MAP_HPP_INCLUDED +#define FLUX_OP_CARTESIAN_PRODUCT_REPEAT_MAP_HPP_INCLUDED #include #include @@ -14,14 +14,14 @@ namespace flux { namespace detail { template -struct cartesian_power_map_adaptor - : inline_sequence_base> { +struct cartesian_product_repeat_map_adaptor + : inline_sequence_base> { private: FLUX_NO_UNIQUE_ADDRESS Base base_; FLUX_NO_UNIQUE_ADDRESS Func func_; public: - constexpr explicit cartesian_power_map_adaptor(decays_to auto&& func, decays_to auto&& base) + constexpr explicit cartesian_product_repeat_map_adaptor(decays_to auto&& func, decays_to auto&& base) : base_(FLUX_FWD(base)), func_(FLUX_FWD(func)) {} @@ -36,7 +36,7 @@ struct cartesian_power_map_adaptor }; template -struct cartesian_power_map_fn +struct cartesian_product_repeat_map_fn { template requires multipass_sequence && @@ -47,7 +47,7 @@ struct cartesian_power_map_fn if constexpr(PowN == 0) { return empty>; } else { - return cartesian_power_map_adaptor>( + return cartesian_product_repeat_map_adaptor>( std::move(func), FLUX_FWD(seq)); } } @@ -58,7 +58,7 @@ struct cartesian_power_map_fn FLUX_EXPORT template requires (N >= 0) -inline constexpr auto cartesian_power_map = detail::cartesian_power_map_fn{}; +inline constexpr auto cartesian_product_repeat_map = detail::cartesian_product_repeat_map_fn{}; } // namespace flux diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 85589933..f0b3fa2e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,8 +26,8 @@ add_executable(test-flux test_cache_last.cpp test_cartesian_product.cpp test_cartesian_product_map.cpp - test_cartesian_power.cpp - test_cartesian_power_map.cpp + test_cartesian_product_repeat.cpp + test_cartesian_product_repeat_map.cpp test_chain.cpp test_chunk.cpp test_chunk_by.cpp diff --git a/test/test_cartesian_power.cpp b/test/test_cartesian_product_repeat.cpp similarity index 93% rename from test/test_cartesian_power.cpp rename to test/test_cartesian_product_repeat.cpp index e3428289..71fc42b8 100644 --- a/test/test_cartesian_power.cpp +++ b/test/test_cartesian_product_repeat.cpp @@ -14,19 +14,19 @@ namespace { -constexpr bool test_cartesian_power() +constexpr bool test_cartesian_product_repeat() { - // cartesian_power<0> should be empty ( same as cartesian_product<>() ) + // cartesian_product_repeat<0> should be empty ( same as cartesian_product<>() ) { - auto cart = flux::cartesian_power<0>(std::array{100, 200, 300}); + auto cart = flux::cartesian_product_repeat<0>(std::array{100, 200, 300}); using C = decltype(cart); static_assert(std::is_same_v, std::tuple<>>); STATIC_CHECK(cart.is_empty()); } - // cartesian_power<1> should be the same as cartesian_product() + // cartesian_product_repeat<1> should be the same as cartesian_product() { - auto cart = flux::cartesian_power<1>(std::array{100, 200, 300}); + auto cart = flux::cartesian_product_repeat<1>(std::array{100, 200, 300}); using C = decltype(cart); @@ -82,7 +82,7 @@ constexpr bool test_cartesian_power() } { - auto cart = flux::cartesian_power<2>(std::array{100, 200, 300}); + auto cart = flux::cartesian_product_repeat<2>(std::array{100, 200, 300}); using C = decltype(cart); @@ -148,7 +148,7 @@ constexpr bool test_cartesian_power() } { - auto prod = flux::cartesian_power<3>(std::array{'a', 'b', 'c', 'd'}); + auto prod = flux::cartesian_product_repeat<3>(std::array{'a', 'b', 'c', 'd'}); static_assert(prod.size() == 64); using C = decltype(prod); @@ -259,11 +259,11 @@ constexpr bool test_cartesian_power() return true; } -static_assert(test_cartesian_power()); +static_assert(test_cartesian_product_repeat()); } TEST_CASE("cartesian power") { - REQUIRE(test_cartesian_power()); + REQUIRE(test_cartesian_product_repeat()); } diff --git a/test/test_cartesian_power_map.cpp b/test/test_cartesian_product_repeat_map.cpp similarity index 82% rename from test/test_cartesian_power_map.cpp rename to test/test_cartesian_product_repeat_map.cpp index 2a209ba1..1168f105 100644 --- a/test/test_cartesian_power_map.cpp +++ b/test/test_cartesian_product_repeat_map.cpp @@ -9,24 +9,24 @@ namespace { constexpr auto sum = [](auto... args) { return (args + ...); }; -constexpr bool test_cartesian_power_map() +constexpr bool test_cartesian_product_repeat_map() { - // cartesian_power_map<0> should be empty ( same as cartesian_product<>() ) + // cartesian_product_repeat_map<0> should be empty ( same as cartesian_product<>() ) { auto make_0_1_pair = [](){ return std::make_pair(0, 1); }; - auto cart = flux::cartesian_power_map<0>(make_0_1_pair, std::array{100, 200, 300}); + auto cart = flux::cartesian_product_repeat_map<0>(make_0_1_pair, std::array{100, 200, 300}); using C = decltype(cart); static_assert(std::is_same_v, std::pair>); STATIC_CHECK(cart.is_empty()); } - // cartesian_power_map<1> should same as map() + // cartesian_product_repeat_map<1> should same as map() { std::array arr1{100, 200}; constexpr auto square_individual = [](auto arg) { return arg * arg; }; - auto cart = flux::cartesian_power_map<1>(square_individual, flux::ref(arr1)); + auto cart = flux::cartesian_product_repeat_map<1>(square_individual, flux::ref(arr1)); using C = decltype(cart); static_assert(flux::sequence); @@ -58,7 +58,7 @@ constexpr bool test_cartesian_power_map() { std::array arr1{100, 200}; - auto cart = flux::cartesian_power_map<2>(sum, flux::ref(arr1)); + auto cart = flux::cartesian_product_repeat_map<2>(sum, flux::ref(arr1)); using C = decltype(cart); static_assert(flux::sequence); @@ -89,7 +89,7 @@ constexpr bool test_cartesian_power_map() { std::array arr1{1, 3}; - auto cart = flux::cartesian_power_map<3>(sum, flux::ref(arr1)); + auto cart = flux::cartesian_product_repeat_map<3>(sum, flux::ref(arr1)); using C = decltype(cart); static_assert(flux::sequence); @@ -117,7 +117,7 @@ constexpr bool test_cartesian_power_map() // Product with a zero-sized sequence works and produces an empty sequence { auto emp = flux::empty; - auto cart = flux::cartesian_power_map<5>(sum, emp); + auto cart = flux::cartesian_product_repeat_map<5>(sum, emp); static_assert(flux::bidirectional_sequence); @@ -133,7 +133,7 @@ constexpr bool test_cartesian_power_map() double vals[3][3] = {}; auto get = [&vals](auto i, auto j) -> double& { return vals[i][j]; }; - auto seq = flux::cartesian_power_map<2>(get, flux::iota(0, 3)); + auto seq = flux::cartesian_product_repeat_map<2>(get, flux::iota(0, 3)); static_assert(std::same_as, double&>); @@ -148,11 +148,11 @@ constexpr bool test_cartesian_power_map() return true; } -static_assert(test_cartesian_power_map()); +static_assert(test_cartesian_product_repeat_map()); -TEST_CASE("cartesian_power_map") +TEST_CASE("cartesian_product_repeat_map") { - REQUIRE(test_cartesian_power_map()); + REQUIRE(test_cartesian_product_repeat_map()); } } \ No newline at end of file