From a4c430da013ae4b0351d91c5ea869f2926c407e4 Mon Sep 17 00:00:00 2001 From: Basavaraju B V Date: Tue, 2 Jan 2024 22:38:31 +0530 Subject: [PATCH] :sparkles: (#32) * :sparkles: + added is_similar and flatten + added _v support for valid and invert + updated the corresponding doc * :green_heart: ci build fix --- docs/container/algorithms.adoc | 41 +++++++++ docs/utility.adoc | 4 + include/container/algorithms.hpp | 87 +++++++++++++++++++ include/utils.hpp | 12 +++ test/container/list_test.cpp | 139 +++++++++++++++++++++++++++++++ test/utils_test.cpp | 19 +++++ 6 files changed, 302 insertions(+) diff --git a/docs/container/algorithms.adoc b/docs/container/algorithms.adoc index 9e3e198..75d06c7 100644 --- a/docs/container/algorithms.adoc +++ b/docs/container/algorithms.adoc @@ -546,6 +546,27 @@ Variants: * `transform_if_qmf` => when `F` and predicate provided as quoted meta function * `transform_if_qmf_t` => to avoid `::type` +==== flatten + +Usage: +[source, cpp] +using result = ctl::flatten>::type + +---- +if + `L1 = L1> + `L2 = std::tuple<>` +then + `result = L1 +---- + +`L2` is `optional`. If `L2` is not provided, then `L2` will be assumed as `L1<>` + +Variants: + +* `flatten` +* `flatten_t` => to avoid `::type` + === Accessors Set of algorithms are used to retrieve the one or more types from the `original list`. In some case `conditional retrieval` is possible. *These algorithms will result in compiler error if the provided `list` is empty*. @@ -971,3 +992,23 @@ then * `iota_c_t` => to avoid `::type` * `iota` => when _count_ is provided as type. `::type` is needed to access the result type * `iota_t` => to avoid `::type` + +==== is_similar + +Usage: +[source, cpp] +using result = ctl::is_similar::type + +---- +if + T1 = std::tuple, + T2 = std::tuple +then + `result = std::integral_constant +---- + +if T1 or T2 are not similar list, then result will be false type + +* `is_similar` +* `is_similar_t` => to avoid `::type` +* `is_similar_v` => to avoid `::value` diff --git a/docs/utility.adoc b/docs/utility.adoc index a749118..afddf3b 100644 --- a/docs/utility.adoc +++ b/docs/utility.adoc @@ -30,9 +30,11 @@ variants of `invert` are: * `invert_c` * `invert_c_t` => to avoid `::type` +* `invert_c_v` => to avoid `::value` * `invert` => to pass typename as template parameter. boolean value is accessed with the help of `C::value` * `invert_t` => to avoid `::type` +* `invert_v` => to avoid `::value` === valid @@ -50,8 +52,10 @@ variants of `valid` are: * `valid` * `valid_t` => to avoid using `::type` +* `valid_v` => to avoid using `::value` * `valid_qmf` => to pass template function as a quoted meta function * `valid_qmf_t` => to avoid using `::type` +* `valid_qmf_v` => to avoid using `::value` === select diff --git a/include/container/algorithms.hpp b/include/container/algorithms.hpp index 54289d3..b357375 100644 --- a/include/container/algorithms.hpp +++ b/include/container/algorithms.hpp @@ -1594,4 +1594,91 @@ using sort_qmf_p = sort_p; template using sort_qmf_p_t = typename sort_qmf_p::type; +//similar +template +struct is_similar { + private: + template + struct is_similar_impl : public std::false_type {}; + + template