Skip to content

Commit

Permalink
Fix more documentation references
Browse files Browse the repository at this point in the history
  • Loading branch information
pfultz2 committed Feb 15, 2018
1 parent ea0d4af commit 77a9538
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion doc/src/example_overloading.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ this:
The `id` parameter passed to the lambda is the [`identity`](/include/boost/hof/identity) function. As explained in the article, this is used to delay the lookup of types by making it a dependent type(i.e. the type depends on a template parameter), which is necessary to avoid compile errors. The [`eval`](/include/boost/hof/eval) function that is called will pass this `identity` function to the lambdas.

The advantage of using Boost.HigherOrderFunctions instead of the solution in Baptiste
Wicht's blog, is that [`conditional`](/include/boost/hof/conditional) allows more than just two conditions. So if
Wicht's blog, is that [`first_of`](/include/boost/hof/conditional) allows more than just two conditions. So if
there was another trait to be checked, such as `is_stack`, it could be written
like this:

Expand Down
8 changes: 4 additions & 4 deletions doc/src/example_print.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ However, there is lot of things that don't print directly to `std::cout` such as
Overloading
-----------

Boost.HigherOrderFunctions provides several ways to do overloading. One of the ways is with the [`conditional`](/include/boost/hof/conditional) adaptor which will pick the first function that is callable. This allows ordering the functions based on which one is more important. So then the first function will print to `std::cout` if possible otherwise we will add an overload to print a range:
Boost.HigherOrderFunctions provides several ways to do overloading. One of the ways is with the [`first_of`](/include/boost/hof/conditional) adaptor which will pick the first function that is callable. This allows ordering the functions based on which one is more important. So then the first function will print to `std::cout` if possible otherwise we will add an overload to print a range:


BOOST_HOF_STATIC_LAMBDA_FUNCTION(print) = conditional(
Expand Down Expand Up @@ -72,7 +72,7 @@ And print out:
Tuples
------

We could extend this to printing tuples as well. We will need to combine a couple of functions to make a `for_each_tuple`, which lets us call a function for each element. First, the [`by`](/include/boost/hof/by) adaptor will let us apply a function to each argument passed in, and the [`unpack`](/include/boost/hof/unpack) adaptor will unpack the elements of a tuple and apply them to the function:
We could extend this to printing tuples as well. We will need to combine a couple of functions to make a `for_each_tuple`, which lets us call a function for each element. First, the [`proj`](/include/boost/hof/by) adaptor will let us apply a function to each argument passed in, and the [`unpack`](/include/boost/hof/unpack) adaptor will unpack the elements of a tuple and apply them to the function:

BOOST_HOF_STATIC_LAMBDA_FUNCTION(for_each_tuple) = [](const auto& sequence, auto f)
{
Expand Down Expand Up @@ -166,7 +166,7 @@ Which outputs this:
Variadic
--------

We can also make this `print` function variadic, so it prints every argument passed into it. We can use the [`by`](/include/boost/hof/by) adaptor, which already calls the function on every argument passed in. First, we just rename our original `print` function to `simple_print`:
We can also make this `print` function variadic, so it prints every argument passed into it. We can use the [`proj`](/include/boost/hof/by) adaptor, which already calls the function on every argument passed in. First, we just rename our original `print` function to `simple_print`:

BOOST_HOF_STATIC_LAMBDA_FUNCTION(simple_print) = fix(conditional(
[](auto, const auto& x) -> decltype(std::cout << x, void())
Expand All @@ -183,7 +183,7 @@ We can also make this `print` function variadic, so it prints every argument pas
}
));

And then apply the [`by`](/include/boost/hof/by) adaptor to `simple_print`:
And then apply the [`proj`](/include/boost/hof/by) adaptor to `simple_print`:

BOOST_HOF_STATIC_LAMBDA_FUNCTION(print) = by(simple_print);

Expand Down
2 changes: 1 addition & 1 deletion doc/src/more_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Instead of writing the projection multiple times in algorithms:
return a.year_of_birth < b.year_of_birth;
});

We can use the [`by`](/include/boost/hof/by) adaptor to project `year_of_birth` on the comparison
We can use the [`proj`](/include/boost/hof/by) adaptor to project `year_of_birth` on the comparison
operator:

std::sort(std::begin(people), std::end(people),
Expand Down
6 changes: 3 additions & 3 deletions doc/src/point_free.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ We would write something like the following, which would recursively iterate ove
print(xs...);
}

Instead with point-free style, we can write this using the [`by`](/include/boost/hof/by) adaptor, which calls a function on each arguments. Of course, `std::cout` is not a function, but we can make it one by using `BOOST_HOF_LIFT`:
Instead with point-free style, we can write this using the [`proj`](/include/boost/hof/by) adaptor, which calls a function on each arguments. Of course, `std::cout` is not a function, but we can make it one by using `BOOST_HOF_LIFT`:

BOOST_HOF_STATIC_FUNCTION(simple_print) = BOOST_HOF_LIFT(std::ref(std::cout) << _);

This uses the [placeholders](/include/boost/hof/placeholders) to create a function that prints to `std::cout`. Then we can pass `simple_print` to the [`by`](/include/boost/hof/by) adaptor:
This uses the [placeholders](/include/boost/hof/placeholders) to create a function that prints to `std::cout`. Then we can pass `simple_print` to the [`proj`](/include/boost/hof/by) adaptor:

BOOST_HOF_STATIC_FUNCTION(print) = by(simple_print);

As the [`by`](/include/boost/hof/by) adaptor calls the function for each argument passed in, `b(f)(x, y)` is the equivalent of calling `f(x)` and then `f(y)`. In this case, it will call `simple_print(x)` and then `simple_print(y)`:
As the [`proj`](/include/boost/hof/by) adaptor calls the function for each argument passed in, `b(f)(x, y)` is the equivalent of calling `f(x)` and then `f(y)`. In this case, it will call `simple_print(x)` and then `simple_print(y)`:

print("Hello", "World");

Expand Down
12 changes: 6 additions & 6 deletions include/boost/hof/first_of.hpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
/*=============================================================================
Copyright (c) 2012 Paul Fultz II
conditional.h
first_of.h
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 BOOST_HOF_GUARD_FUNCTION_CONDITIONAL_H
#define BOOST_HOF_GUARD_FUNCTION_CONDITIONAL_H

/// conditional
/// ===========
/// first_of
/// ========
///
/// Description
/// -----------
///
/// The `conditional` function adaptor combines several functions together. If
/// The `first_of` function adaptor combines several functions together. If
/// the first function can not be called, then it will try to call the next
/// function. This can be very useful when overloading functions using
/// template constraints(such as with `enable_if`).
///
/// Note: This is different than the [`match`](match.md) function adaptor, which
/// can lead to ambiguities. Instead, `conditional` will call the first function
/// can lead to ambiguities. Instead, `first_of` will call the first function
/// that is callable, regardless if there is another function that could be
/// called as well.
///
Expand Down Expand Up @@ -67,7 +67,7 @@
///
/// This will print `Int` because the `for_floats` function object won't ever be
/// called. Due to the conversion rules in C++, the `for_ints` function can be
/// called on floats, so it is chosen by `conditional` first, even though
/// called on floats, so it is chosen by `first_of` first, even though
/// `for_floats` is a better match.
///
/// So, the order of the functions in the `first_of_adaptor` are very important
Expand Down
2 changes: 1 addition & 1 deletion include/boost/hof/match.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
///
/// The `match` function adaptor combines several functions together and
/// resolves which one should be called by using C++ overload resolution. This
/// is different than the [`conditional`](/include/boost/hof/conditional) adaptor which resolves
/// is different than the [`first_of`](/include/boost/hof/conditional) adaptor which resolves
/// them based on order.
///
/// Synopsis
Expand Down
8 changes: 4 additions & 4 deletions include/boost/hof/proj.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*=============================================================================
Copyright (c) 2014 Paul Fultz II
by.h
proj.h
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 BOOST_HOF_GUARD_FUNCTION_ON_H
#define BOOST_HOF_GUARD_FUNCTION_ON_H

/// by
/// ==
/// proj
/// ====
///
/// Description
/// -----------
///
/// The `by` function adaptor applies a projection onto the parameters of
/// The `proj` function adaptor applies a projection onto the parameters of
/// another function. This is useful, for example, to define a function for
/// sorting such that the ordering is based off of the value of one of its
/// member fields.
Expand Down

0 comments on commit 77a9538

Please sign in to comment.