diff --git a/doc/article/simple_cxx11_metaprogramming.adoc b/doc/article/simple_cxx11_metaprogramming.adoc index e05b815..a14356b 100644 --- a/doc/article/simple_cxx11_metaprogramming.adoc +++ b/doc/article/simple_cxx11_metaprogramming.adoc @@ -133,7 +133,7 @@ To do that, we need to first convert `std::tuple` to `mp_list`, apply `add_pointer` to each element obtaining `mp_list`, then convert that back to `std::tuple`. -These conversion steps are a quite common occurence, and we'll write a +These conversion steps are a quite common occurrence, and we'll write a primitive that helps us perform them, called `mp_rename`. We want ``` mp_rename, mp_list> @@ -1097,7 +1097,7 @@ template using sizeof_less = mp_bool<(sizeof(T) < sizeof(U))>; Finally, let me show the implementations of `mp_count` and `mp_count_if`, for no reason other than I find them interesting. `mp_count` returns the -number of occurences of the type `V` in the list `L`; `mp_count_if` +number of occurrences of the type `V` in the list `L`; `mp_count_if` counts the number of types in `L` for which `P` is `true`. As a first step, I'll implement `mp_plus`. `mp_plus` is a variadic (not just @@ -1175,7 +1175,7 @@ whether the list `L` contains the type `V`: template using mp_contains = mp_bool::value != 0>; ``` At first sight, this implementation appears horribly naive and inefficient -- -why would we need to count all the occurences just to throw that away if we're +why would we need to count all the occurrences just to throw that away if we're only interested in a boolean result -- but it's actually pretty competitive and perfectly usable. We just need to add one slight optimization to `mp_plus`, the engine behind `mp_count` and `mp_contains`: diff --git a/doc/article/simple_cxx11_metaprogramming_2.adoc b/doc/article/simple_cxx11_metaprogramming_2.adoc index a4e1283..9b15d4d 100644 --- a/doc/article/simple_cxx11_metaprogramming_2.adoc +++ b/doc/article/simple_cxx11_metaprogramming_2.adoc @@ -681,7 +681,7 @@ as the first argument are: |g$$++$$ 4.9.2, recursive |0.9 |4.7 |14.2 |32.4 |DNF ||| |=== -To improve upon this apalling result, we'll again exploit pack expansion into a +To improve upon this appalling result, we'll again exploit pack expansion into a function call, but in a novel way. Let's suppose that we need to access the fourth element (`I = 3`). We'll generate the function signature ``` @@ -838,7 +838,7 @@ one. We can pretty much tell who's going to win, and by how much. The final algorithm that I'll bring to your attention is `mp_find_index`. `mp_find_index` returns an integral constant of type `size_t` with a -value that is the index of the first occurence of `V` in `L`. If `V` is not in +value that is the index of the first occurrence of `V` in `L`. If `V` is not in `L`, the return value is the size of `L`. We'll start with the recursive implementation, as usual: @@ -974,7 +974,7 @@ needs to manipulate type lists of length 300. Note that once we have `mp_drop` and `mp_find_index`, we can derive the `mp_find` algorithm, which returns the suffix of `L` starting with the -first occurence of `V`, if any, and an empty list otherwise, by using +first occurrence of `V`, if any, and an empty list otherwise, by using `mp_drop>`. ## Conclusion diff --git a/doc/mp11/algorithm.adoc b/doc/mp11/algorithm.adoc index 372f406..a5b1ed1 100644 --- a/doc/mp11/algorithm.adoc +++ b/doc/mp11/algorithm.adoc @@ -71,7 +71,7 @@ using R1 = mp_all>; // mp_true As `mp_transform`, but takes a quoted metafunction. -.Using mp_transform_q to count the occurences of `void` in a list +.Using mp_transform_q to count the occurrences of `void` in a list ``` using L1 = std::tuple; @@ -97,7 +97,7 @@ using R1 = mp_apply` replaces the elements of the list `L1` for which `mp_to_bool>` is `mp_true` with `F`, and returns the result, where `Ti` are the corresponding elements of `Li`. -.Using mp_transform_if to replace the occurences of 'void' in a list with the corresponding elements of a second list +.Using mp_transform_if to replace the occurrences of 'void' in a list with the corresponding elements of a second list ``` using L1 = std::tuple; using L2 = std::tuple; @@ -128,7 +128,7 @@ using R1 = mp_transform_if; As `mp_transform_if`, but takes quoted metafunctions. -.Using mp_transform_if_q to replace the occurences of 'void' in a list with the corresponding elements of a second list +.Using mp_transform_if_q to replace the occurrences of 'void' in a list with the corresponding elements of a second list ``` using L1 = std::tuple; using L2 = std::tuple; @@ -531,7 +531,7 @@ As `mp_max_element`, but takes a quoted metafunction. template using mp_find = /*...*/; `mp_find` returns the index at which the type `V` is located in the list `L`. It's an alias for `mp_size_t`, -where `I` is the zero-based index of the first occurence of `V` in `L`. If `L` does not contain `V`, `mp_find` +where `I` is the zero-based index of the first occurrence of `V` in `L`. If `L` does not contain `V`, `mp_find` is `mp_size`. ## mp_find_if diff --git a/doc/mp11/examples.adoc b/doc/mp11/examples.adoc index d626566..858bd55 100644 --- a/doc/mp11/examples.adoc +++ b/doc/mp11/examples.adoc @@ -156,7 +156,7 @@ That is, when our `common_tuple` causes a substitution failure instead of a hard and `common_type_t`, which is defined as `typename common_type<...>::type`, will also cause a substitution failure. As another example, consider the hypothetical type `expected` that represents either a successful return with a value of `T`, -or an unsucessful return with an error code of some type in the list `E...`. The common type of `expected` and +or an unsuccessful return with an error code of some type in the list `E...`. The common type of `expected` and `expected` is `expected, E1, E2, E3, E4, E5>`. That is, the possible return values are combined into their common type, and we take the union of the set of error types. diff --git a/doc/mp11/map.adoc b/doc/mp11/map.adoc index f90e3f4..922924b 100644 --- a/doc/mp11/map.adoc +++ b/doc/mp11/map.adoc @@ -55,7 +55,7 @@ replaces the existing element with `T`. If the map `M` does not contain an element with a key `mp_first`, inserts it (using `mp_push_back`); otherwise, replaces the existing element `L` with `L>`. -.Using mp_map_update to count the number of occurences of types in a list +.Using mp_map_update to count the number of occurrences of types in a list ``` template using inc2nd = mp_int;