diff --git a/.github/workflows/asciidoctor-ghpages.yml b/.github/workflows/asciidoctor-ghpages.yml index c3d28ff..6054fc7 100644 --- a/.github/workflows/asciidoctor-ghpages.yml +++ b/.github/workflows/asciidoctor-ghpages.yml @@ -3,8 +3,6 @@ name: Publish Ascii Doc on: push: branches: [ main, develop ] - pull_request: - branches: [ main, develop ] jobs: build: diff --git a/docs/container/algorithms.adoc b/docs/container/algorithms.adoc index 65d39b4..9e3e198 100644 --- a/docs/container/algorithms.adoc +++ b/docs/container/algorithms.adoc @@ -1,5 +1,6 @@ == Algorithms +:hardbreaks-option: Once the heterogenous list is created, algorithms are required to do some work with that list. like for example, to add new element to existing list, or to retrieve an element, or remove specific entry in the list like or even sorting the types in the list. Just like data structure `std::vector<>` (note that `std::vector<>` can be used to hold the values of homogenous type at runtime). @@ -21,8 +22,10 @@ where, * _ algo name _ => name of the modifiable algorithms listed below * L => list which has to be modified -* U => type of the interest. It could be single type or another list type! This is optional parameter depending on algorithm. -* `::type` => to access the type from the result of the modified list. If algorithm name is postfixed with `_t` then there is no need of using `::type` +* U => type of the interest. It could be single type or another list type! +This is optional parameter depending on algorithm. +* `::type` => to access the type from the result of the modified list. +If algorithm name is postfixed with `_t` then there is no need of using `::type` Following are some of `modifiable` algorithms (replaced with _ algo name _): @@ -32,7 +35,13 @@ Usage: [source, cpp] using result = ctl::rename, Y>::type -if `L = ctl::list` and `Y == std::tuple` then `result = std::tuple` +---- +if + `L = ctl::list` + `Y == std::tuple` +then + `result = std::tuple` +---- Variants: @@ -45,7 +54,13 @@ Usage: [source, cpp] using result = ctl::apply>::type -if `Y == std::tuple` and `L = ctl::list` then `result = std::tuple` +---- +if + `Y == std::tuple` + `L = ctl::list` +then + `result = std::tuple` +---- Variants: @@ -58,7 +73,13 @@ Usage: [source, cpp] using result = rotate_left_c, _num_>::type -if `L = L` and `_num_ = 1` then `result = L` +---- +if + `L = L` + `_num_ = 1` +then + `result = L` +---- Variants: @@ -73,7 +94,13 @@ Usage: [source, cpp] using result = rotate_right_c, _num_>::type -if `L = L` and `_num_ = 1` then `result = L` +---- +if + `L = L` + `_num_ = 1` +then + `result = L` +---- Variants: @@ -88,7 +115,16 @@ Usage: [source, cpp] using result = sort>::type -if `L = L` then `result = L` when `T1::value <= T2::value <= T3::value`. Logic used here is `Quick sort`. +---- +if + `L = L` +then + `result = L` + +where `T1::value <= T2::value <= T3::value`. +---- + +Logic used here is `Quick sort`. Variants: @@ -106,7 +142,12 @@ Usage: [source, cpp] using result = ctl::reverse>::type -if `L = L` then `result = L` +---- +if + `L = L` +then + `result = L` +---- Variants: @@ -119,7 +160,14 @@ Usage: [source, cpp] using result = ctl::replace, TR, RW>::type -if `L = L`, `TR = T2` and `RW = T4` then `result = L` +---- +if + `L = L` + `TR = T2` + `RW = T4` +then + `result = L` +---- Variants: @@ -140,7 +188,13 @@ Usage: [source, cpp] using result = ctl::push_front, T>::type -if `L = L` and `L` then `result = L` +---- +if + `L = L` + `L` +then + `result = L` +---- Variants: @@ -153,7 +207,13 @@ Usage: [source, cpp] using result = ctl::push_back, T>::type -if `L = L` and `L` then `result = L` +---- +if + `L = L` + `L` +then + `result = L` +---- Variants: @@ -166,7 +226,13 @@ Usage: [source, cpp] using result = ctl::append, T>::type -if `L = L` and `L` then `result = L` +---- +if + `L = L` + `T = `L` +then + `result = L` +---- Variants: @@ -179,7 +245,13 @@ Usage: [source, cpp] using result = ctl::pop_front>::type -if `L = L` then `result = L` +---- +if + `L = L` +then + `result = L` +---- + if list provided is empty, then it will result in error Variants: @@ -193,7 +265,12 @@ Usage: [source, cpp] using result = ctl::pop_back>::type -if `L = L` then `result = L` +---- +if + `L = L` +then + `result = L` +---- Variants: @@ -206,7 +283,15 @@ Usage: [source, cpp] using result = ctl::insert_c, _index_, Us...>::type -if `L = L`, `_index_ = 1` and `Us... = U1, U2, U3` then `result = L`. +---- +if + `L = L` + `_index_ = 1` + `Us... = U1, U2, U3` +then + `result = L` +---- + if _index_ should be less than size of the `L`. otherwise it will result in compiler error Variants: @@ -222,7 +307,14 @@ Usage: [source, cpp] using result = ctl::repeat_c, _count_>::type -if `L = L` and _count_ = 2 then `result = L`. +---- +if + `L = L` + _count_ = 2 +then + `result = L` +---- + if _count_ == 0, then `result = L<>` Variants: @@ -238,7 +330,12 @@ Usage: [source, cpp] using result = ctl::repeat_c>::type -if `L = L` then `result = L<>` +---- +if + `L = L` +then + `result = L<>` +---- Variants: @@ -251,7 +348,15 @@ Usage: [source, cpp] using result = ctl::erase_c, _pos1_, _pos2_>::type -if `L = L`, _pos1_ == 0 and _pos2_ == 1 then `result = L`. +---- +if + `L = L` + _pos1_ == 0 + _pos2_ == 1 +then + `result = L` +---- + if condition _pos1_ < `L` <= _pos2_ fails, then results in compiler error. Variants: @@ -267,7 +372,13 @@ Usage: [source, cpp] using result = ctl::remove_type, U>::type -if `L = L` and `U = T2` then `result = L`. +---- +if + `L = L` + `U = T2` +then + `result = L` +---- Variants: @@ -284,7 +395,17 @@ Usage: [source, cpp] using result = ctl::filter_if::type -if `L1, L2 ... Ln` and `P = true` then `result = L`. +---- +if + `L1 = L1, + `L2 = L2` + ... + `Ln` + + `P = P = true` +then + `result = L` +---- Variants: @@ -299,7 +420,14 @@ Usage: [source, cpp] using result = ctl::copy_if, P>::type -if `L = L` and `P = true` then `result = L`. +---- +if + `L = L` + + `P = true` +then + `result = L` +---- Variants: @@ -314,7 +442,14 @@ Usage: [source, cpp] using result = ctl::drop_c, _count_>::type -if `L = L` and _count_ = 2 then `result = L`. +---- +if + `L = L` + _count_ = 2 +then + `result = L` +---- + if _count_ >= `L` size, then `result = L<>` Variants: @@ -330,7 +465,13 @@ Usage: [source, cpp] using result = ctl::remove_duplicates>::type -if `L = L` and _count_ = 2 then `result = L`. +---- +if + `L = L` + _count_ = 2 +then + `result = L` +---- Variants: @@ -343,7 +484,13 @@ Usage: [source, cpp] using result = ctl::unique>::type -if `L = L` and _count_ = 2 then `result = L`. +---- +if + `L = L` + _count_ = 2 +then + `result = L` +---- Variants: @@ -356,7 +503,13 @@ Usage: [source, cpp] using result = ctl::unique_if, P>::type -if `L = L` and `P = T2` then `result = L`. +---- +if + `L = L` + `P = T2` +then + `result = L` +---- Variants: @@ -371,7 +524,16 @@ Usage: [source, cpp] using result = ctl::transform::type -if `L1, L2 ... Ln` then `result = L, F, F>`. F is templated type. +---- +if + `L1 = L1 + `L2 = L2 ` + ... + `Ln` +then + `result = L, F, F>`. + where, F is templated type. +---- Variants: @@ -396,8 +558,10 @@ where, * _ algo name _ => name of the accessor algorithms listed below * L => list from which one or more type is retrieved -* P => `predicate/function` which is `applied on each type` to access/retrieve. It is `optional`, not every algorithm needs this parameter -* `::type` => to access the type from the result. If algorithm name is postfixed with `_t` then there is no need of using `::type` +* P => `predicate/function` which is `applied on each type` to access/retrieve. +It is `optional`, not every algorithm needs this parameter +* `::type` => to access the type from the result. +If algorithm name is postfixed with `_t` then there is no need of using `::type` Following are some of `accessor` algorithms (replaced with _ algo name _): @@ -407,7 +571,15 @@ Usage: [source, cpp] using result = ctl::at_c, _pos_>::type -if `L = L` and _pos_ == 2 then `result = T3`. if condition _pos_ < size of `L` then it will result in compiler error +---- +if + `L = L` + _pos_ == 2 +then + `result = T3` +---- + +If condition _pos_ < size of `L` then it will result in compiler error Variants: @@ -422,7 +594,14 @@ Usage: [source, cpp] using result = ctl::first>::type -if `L = L` then `result = T1`. if list provided is empty, then it will result in compiler error +---- +if + `L = L` +then + `result = T1` +---- + +If list provided is empty, then it will result in compiler error Variants: @@ -435,7 +614,14 @@ Usage: [source, cpp] using result = ctl::front>::type -if `L = L` then `result = T1`. if list provided is empty, then it will result in compiler error +---- +if + `L = L` +then + `result = T1` +---- + +If list provided is empty, then it will result in compiler error Variants: @@ -448,7 +634,15 @@ Usage: [source, cpp] using result = ctl::last>::type -if `L = L` then `result = T3`. if list provided is empty, then it will result in compiler error +---- +if + `L = L` +then + `result = T3` +---- + +If list provided is empty, then it will result in compiler error + Variants: @@ -461,7 +655,14 @@ Usage: [source, cpp] using result = ctl::back>::type -if `L = L` then `result = T3`. if list provided is empty, then it will result in compiler error +---- +if + `L = L` +then + `result = T3` +---- + +If list provided is empty, then it will result in compiler error Variants: @@ -474,7 +675,15 @@ Usage: [source, cpp] using result = ctl::head>::type -if `L = L` then `result = L`. if list provided is empty, then it will result in compiler error. If there is only one entry in the list, then `result = L<>` +---- +if + `L = L` +then + `result = L` +---- + +If list provided is empty, then it will result in compiler error. +If there is only one entry in the list, then `result = L<>` Variants: @@ -487,7 +696,15 @@ Usage: [source, cpp] using result = ctl::tail>::type -if `L = L` then `result = L`. if list provided is empty, then it will result in compiler error. If there is only one entry in the list, then `result = L<>` +---- +if + `L = L` +then + `result = L` +---- + +If list provided is empty, then it will result in compiler error. +If there is only one entry in the list, then `result = L<>` Variants: @@ -500,7 +717,15 @@ Usage: [source, cpp] using result = ctl::take, _count_>::type -if `L = L` and _count_ = 2, then `result = L`. if _count_ >= size of `L` then `result = L` +---- +if + `L = L` + _count_ = 2, +then + `result = L` +---- + +If _count_ >= size of `L` then `result = L` Variants: @@ -512,7 +737,7 @@ Variants: === Miscellaneous -Set of algorithms used for miscellaneous stuffs which are not listed above! like ex, creating the integer sequence, getting the position of the type in a list, getting the size of the list, etc. +Set of algorithms used for miscellaneous stuffs which are not listed above! like for ex, creating the integer sequence, getting the position of the type in a list, getting the size of the list, etc. Following are some of algorithms: @@ -522,7 +747,12 @@ Usage: [source, cpp] using result = ctl::size>::type -if `L = L` then `result = std::integral_constant` +---- +if + `L = L` +then + `result = std::integral_constant` +---- Variants: @@ -536,7 +766,12 @@ Usage: [source, cpp] using result = ctl::count>::type -if `L = L` then `result = std::integral_constant` +---- +if + `L = L` +then + `result = std::integral_constant` +---- Variants: @@ -556,7 +791,14 @@ Usage: [source, cpp] using result = ctl::empty>::type -if `L = L` then `result = std::false_type`. if `L = L<>` then `result = std::true_type` +---- +if + `L = L` +then + `result = std::false_type` +---- + +If `L = L<>` then `result = std::true_type` Variants: @@ -570,7 +812,15 @@ Usage: [source, cpp] using result = ctl::contains, U>::type -if `L = L` and `U == T2` then `result = std::true_type`. if `U == T4` then `result = std::false_type` +---- +if + `L = L` + `U == T2` +then + `result = std::true_type` +---- + +If `U == T4` then `result = std::false_type` Variants: @@ -584,7 +834,15 @@ Usage: [source, cpp] using result = ctl::find, U>::type -if `L = L` and `U == T2` then `result = std::integral_constant`. if `U` is not found in list, then `result` is size of the list +---- +if + `L = L` + `U == T2` +then + `result = std::integral_constant`. +---- + +If `U` is not found in list, then `result` is size of the list Variants: @@ -604,7 +862,14 @@ Usage: [source, cpp] using result = ctl::all_of, P>::type -if `L = L` and `P == true` for all T1, T2, T3 types then `result = std::true_type`, otherwise `result = std::false_type`. +---- +if + `L = L` + `P == true` for all T1, T2, T3 types +then + `result = std::true_type`, + `result = std::false_type`, if P == false for any one of the types +---- Variants: @@ -621,7 +886,14 @@ Usage: [source, cpp] using result = ctl::any_of, P>::type -if `L = L` and `P == true` for any T1, T2, T3 types then `result = std::true_type`, otherwise `result = std::false_type`. +---- +if + `L = L` + `P == true` for any T1, T2, T3 types +then + `result = std::true_type`, + `result = std::false_type`, if P == false for all types +---- Variants: @@ -638,7 +910,14 @@ Usage: [source, cpp] using result = ctl::none_of, P>::type -if `L = L` and `P == false` for all T1, T2, T3 types then `result = std::true_type`, otherwise `result = std::false_type`. +---- +if + `L = L` + `P == false` for all T1, T2, T3 types +then + `result = std::true_type`, + `result = std::false_type`, if P for any one of the types +---- Variants: @@ -655,7 +934,13 @@ Usage: [source, cpp] using result = ctl::from_integer_sequence::type -if `sequence = std::integer_sequence` and `RT == ctl::list` then `result = ctl::list, std::integral_constant, std::integral_constant >` +---- +if + `sequence = std::integer_sequence` + `RT == ctl::list` +then + `result = ctl::list, std::integral_constant, std::integral_constant >` +---- `RT` default type is `std::tuple`. @@ -670,7 +955,14 @@ Usage: [source, cpp] using result = ctl::iota_c<_count_, DT, RT>::type -if _count_ = 3, `DT = uint32_t` and `RT == ctl::list` then `result = ctl::list, std::integral_constant, std::integral_constant >` +---- +if + _count_ = 3, + `DT = uint32_t` + `RT == ctl::list` +then + `result = ctl::list, std::integral_constant, std::integral_constant >` +---- `DT` default type is `uint32_t`. `RT` default type is `std::tuple`. diff --git a/docs/container/list.adoc b/docs/container/list.adoc index 471cb0d..2dcbbdd 100644 --- a/docs/container/list.adoc +++ b/docs/container/list.adoc @@ -1,5 +1,6 @@ == List +:hardbreaks-option: It is a container which holds the types. It is an heterogenous container. @@ -9,6 +10,9 @@ There are 3 variants of list * `clt::list<>` => non-instantiable list * `ctl::ilist<>` => instantiable list -* `ctl::clist<>` => instantiable and callable list. It has many operator over-loadings which can be called at runtime. Example for the same can be found in `src/main.cpp` file +* `ctl::clist<>` => instantiable and callable list. +It has many operator over-loadings which can be called at runtime. +Example for the same can be found in `src/main.cpp` file -Many algorithms can be applied on the created list type. Algorithms from MP11 can also be used with the list type. +Many algorithms can be applied on the created list type. +Even algorithms from MP11 can also be used with the list type. diff --git a/docs/ctl.adoc b/docs/ctl.adoc index 82aa694..dc3d40a 100644 --- a/docs/ctl.adoc +++ b/docs/ctl.adoc @@ -1,6 +1,7 @@ = CTL (Compile Time Library) == Overview +:hardbreaks-option: This is a C++ library, created to include algorithms that can be worked out at compile time. It uses C++ template meta programming and functional programming techniques to execute many algorithms at compile time on one or more types. @@ -16,11 +17,19 @@ Features available to use: *Note:* -* Container algorithms and utility are influenced by https://www.boost.org/doc/libs/1_80_0/libs/mp11/doc/html/mp11.html#list[Boost::MP11]. This has been started as re-inventing wheel theory and used personal approach to implement the APIs/Functions that MP11 library supports, many of the algorithms are having the same name as mentioned in library MP11. +* Container algorithms and utility are influenced by https://www.boost.org/doc/libs/1_80_0/libs/mp11/doc/html/mp11.html#list[Boost::MP11]. +This has been started as re-inventing wheel theory and taken personal approach to implement the APIs/Functions that MP11 library supports. +Many of the algorithms are having the same name as mentioned in library MP11. + * `_t` next to algorithm name is implemented to avoid using `::type` keyword with algorithm + * `_c` next to algorithm name is implemented to take constants which are known at compile time (ex: true/false or numbers) + * `_f` next to algorithm name is implemented to take template types as template parameter + * `_p` next to algorithm name is implemented to take predicate as template parameter (predicate is a template type). It is same as `_f`, but `_p` is used to make it more clear to read + * `_qmf` next to algorithm name is implemented to take Quoted meta functions as template parameter ** `_qmf` implementations are using its *non `_qmf`* counterparts + * `_v` next to algorithm name is implemented to get the constant value (boolean or number). it is like using `::value` on the integral_constant type diff --git a/docs/utility.adoc b/docs/utility.adoc index b2dc521..a749118 100644 --- a/docs/utility.adoc +++ b/docs/utility.adoc @@ -1,11 +1,13 @@ == Utility +:hardbreaks-option: Following struct(s)/algorithm(s) can be applied on the types. To use algorithms make sure to add `#include ` in source file. === quote -This helps to wrap template type inside a structure called `quote`. template type can be accessed with the help of nested type `fn`. +This helps to wrap template type inside a structure called `quote`. +Template type can be accessed with the help of nested type `fn`. [source, cpp] template