From 028e67282241003fe9aa44cd0db54712bde2a2e7 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Sat, 30 Aug 2014 17:18:26 -0400 Subject: [PATCH] Refactor examples and fix broken links --- example/foldable.cpp | 83 ++++++++++++++++++ example/foldable/count.cpp | 36 -------- example/foldable/maximum_by.cpp | 29 ------- example/foldable/minimum_by.cpp | 29 ------- example/foldable/unpack.cpp | 30 ------- example/foldable/unpack_idiom.cpp | 25 ------ example/functor.cpp | 87 +++++++++++++++++++ example/functor/adjust.cpp | 30 ------- example/functor/fill.cpp | 23 ----- example/functor/fmap.cpp | 43 --------- example/functor/replace.cpp | 26 ------ example/list.cpp | 8 +- example/list/functor.cpp | 20 +++-- example/list/searchable.cpp | 10 ++- example/list/traversable.cpp | 43 +++++---- example/maybe/maybe.cpp | 44 ++++++---- example/traversable.cpp | 73 ++++++++++++++++ example/traversable/sequence.cpp | 35 -------- example/traversable/traverse.cpp | 50 ----------- example/type/construct.cpp | 4 +- include/boost/hana/foldable/foldable.hpp | 18 ++-- include/boost/hana/foldable/iterable_mcd.hpp | 2 +- include/boost/hana/functor/functor.hpp | 11 +-- include/boost/hana/functor/list_mcd.hpp | 7 +- include/boost/hana/lazy/functor.hpp | 2 +- include/boost/hana/list/list.hpp | 59 ++++++------- include/boost/hana/maybe/maybe.hpp | 16 ++-- include/boost/hana/searchable/list_mcd.hpp | 2 +- include/boost/hana/traversable/list_mcd.hpp | 5 +- .../boost/hana/traversable/traversable.hpp | 8 +- include/boost/hana/tuple/iterable.hpp | 2 +- 31 files changed, 370 insertions(+), 490 deletions(-) delete mode 100644 example/foldable/count.cpp delete mode 100644 example/foldable/maximum_by.cpp delete mode 100644 example/foldable/minimum_by.cpp delete mode 100644 example/foldable/unpack.cpp delete mode 100644 example/foldable/unpack_idiom.cpp create mode 100644 example/functor.cpp delete mode 100644 example/functor/adjust.cpp delete mode 100644 example/functor/fill.cpp delete mode 100644 example/functor/fmap.cpp delete mode 100644 example/functor/replace.cpp create mode 100644 example/traversable.cpp delete mode 100644 example/traversable/sequence.cpp delete mode 100644 example/traversable/traverse.cpp diff --git a/example/foldable.cpp b/example/foldable.cpp index b06c7a6c7..f6be439a4 100644 --- a/example/foldable.cpp +++ b/example/foldable.cpp @@ -5,15 +5,21 @@ Distributed under the Boost Software License, Version 1.0. */ #include +#include +#include #include +#include #include #include #include #include #include +#include +#include #include #include +#include using namespace boost::hana; @@ -135,4 +141,81 @@ int main() { ); //! [sum] } + + { + //! [unpack] + auto cheap_tie = [](auto& ...vars) { + return partial(flip(unpack), [&vars...](auto ...values) { + // Using an initializer list sequences the assignments. + int dummy[] = {((vars = values), 0)...}; + (void)dummy; + }); + }; + int a = 0; + char b = '\0'; + double c = 0; + + cheap_tie(a, b, c)(tuple(1, '2', 3.3)); + BOOST_HANA_RUNTIME_ASSERT(a == 1 && b == '2' && c == 3.3); + //! [unpack] + } + + { + //! [unpack_idiom] + BOOST_HANA_CONSTEXPR_LAMBDA auto add = [](auto x, auto y) { + return x + y; + }; + + // Would be `boost::fusion::make_fused(add)` in Boost.Fusion. + BOOST_HANA_CONSTEXPR_LAMBDA auto add_seq = partial(flip(unpack), add); + + BOOST_HANA_CONSTEXPR_ASSERT(add_seq(tuple(1, 2)) == add(1, 2)); + //! [unpack_idiom] + } + + { + //! [count] + using namespace literals; + BOOST_HANA_CONSTEXPR_LAMBDA auto odd = [](auto x) { + return x % 2_c != 0_c; + }; + + constexpr auto types = type_list; + constexpr auto ints = integer_list; + + BOOST_HANA_CONSTANT_ASSERT(count(ints, odd) == 2_c); + + BOOST_HANA_CONSTANT_ASSERT(count(types, trait) == 1_c); + BOOST_HANA_CONSTANT_ASSERT(count(types, _ == type) == 2_c); + BOOST_HANA_CONSTANT_ASSERT(count(types, _ == type) == 0_c); + //! [count] + } + + { + //! [maximum_by] + BOOST_HANA_CONSTEXPR_LAMBDA auto size = [](auto xs, auto ys) { + return length(xs) < length(ys); + }; + + BOOST_HANA_CONSTEXPR_ASSERT( + maximum_by(size, tuple(tuple(), tuple(1, '2'), tuple(3.3, nullptr, 4))) + == + tuple(3.3, nullptr, 4) + ); + //! [maximum_by] + } + + { + //! [minimum_by] + BOOST_HANA_CONSTEXPR_LAMBDA auto size = [](auto xs, auto ys) { + return length(xs) < length(ys); + }; + + BOOST_HANA_CONSTANT_ASSERT( + minimum_by(size, tuple(tuple(), tuple(1, '2'), tuple(3.3, nullptr, 4))) + == + tuple() + ); + //! [minimum_by] + } } diff --git a/example/foldable/count.cpp b/example/foldable/count.cpp deleted file mode 100644 index 5b9053ec2..000000000 --- a/example/foldable/count.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -using namespace boost::hana; -using namespace literals; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_LAMBDA auto odd = [](auto x) { - return x % 2_c != 0_c; - }; - - constexpr auto types = type_list; - constexpr auto ints = integer_list; - - BOOST_HANA_CONSTANT_ASSERT(count(ints, odd) == 2_c); - - BOOST_HANA_CONSTANT_ASSERT(count(types, trait) == 1_c); - BOOST_HANA_CONSTANT_ASSERT(count(types, _ == type) == 2_c); - BOOST_HANA_CONSTANT_ASSERT(count(types, _ == type) == 0_c); - //! [main] -} diff --git a/example/foldable/maximum_by.cpp b/example/foldable/maximum_by.cpp deleted file mode 100644 index c335e10ce..000000000 --- a/example/foldable/maximum_by.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include - -#include -using namespace boost::hana; - - -//! [main] -template -struct storage { - char c[i]; -}; - -int main() { - BOOST_HANA_CONSTEXPR_LAMBDA auto size = [](auto x, auto y) { - return bool_<(sizeof(x) < sizeof(y))>; - }; - - auto max = maximum_by(size, tuple(storage<1>{}, storage<3>{}, storage<2>{})); - static_assert(std::is_same>::value, ""); -} -//! [main] diff --git a/example/foldable/minimum_by.cpp b/example/foldable/minimum_by.cpp deleted file mode 100644 index 15a752148..000000000 --- a/example/foldable/minimum_by.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include - -#include -using namespace boost::hana; - - -//! [main] -template -struct storage { - char c[i]; -}; - -int main() { - BOOST_HANA_CONSTEXPR_LAMBDA auto size = [](auto x, auto y) { - return bool_<(sizeof(x) < sizeof(y))>; - }; - - auto min = minimum_by(size, tuple(storage<1>{}, storage<3>{}, storage<2>{})); - static_assert(std::is_same>::value, ""); -} -//! [main] diff --git a/example/foldable/unpack.cpp b/example/foldable/unpack.cpp deleted file mode 100644 index 26717248b..000000000 --- a/example/foldable/unpack.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include - -#include -using namespace boost::hana; - - -int main() { - //! [main] - auto cheap_tie = [](auto& ...vars) { - return partial(flip(unpack), [&vars...](auto ...values) { - // Using an initializer list sequences the assignments. - int dummy[] = {((vars = values), 0)...}; - (void)dummy; - }); - }; - int a = 0; - char b = '\0'; - double c = 0; - - cheap_tie(a, b, c)(tuple(1, '2', 3.3)); - assert(a == 1 && b == '2' && c == 3.3); - //! [main] -} diff --git a/example/foldable/unpack_idiom.cpp b/example/foldable/unpack_idiom.cpp deleted file mode 100644 index 053bfb126..000000000 --- a/example/foldable/unpack_idiom.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_LAMBDA auto add = [](auto x, auto y) { - return x + y; - }; - - // Would be `boost::fusion::make_fused(add)` in Boost.Fusion. - BOOST_HANA_CONSTEXPR_LAMBDA auto add_seq = partial(flip(unpack), add); - - BOOST_HANA_CONSTEXPR_ASSERT(add_seq(tuple(1, 2)) == add(1, 2)); - //! [main] -} diff --git a/example/functor.cpp b/example/functor.cpp new file mode 100644 index 000000000..e8c866f3f --- /dev/null +++ b/example/functor.cpp @@ -0,0 +1,87 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +using namespace boost::hana; + + +int main() { + { + //! [adjust] + BOOST_HANA_CONSTEXPR_LAMBDA auto negative = [](auto x) { + return x < 0; + }; + + BOOST_HANA_CONSTEXPR_LAMBDA auto negate = [](auto x) { + return -x; + }; + + BOOST_HANA_CONSTEXPR_ASSERT( + adjust(tuple(-3, -2, -1, 0, 1, 2, 3), negative, negate) + == + tuple(3, 2, 1, 0, 1, 2, 3) + ); + //! [adjust] + } + + { + //! [fill] + BOOST_HANA_CONSTEXPR_ASSERT( + fill(tuple(1, '2', 3.3, nullptr), 'x') == tuple('x', 'x', 'x', 'x') + ); + + BOOST_HANA_CONSTANT_ASSERT(fill(nothing, 'x') == nothing); + BOOST_HANA_CONSTEXPR_ASSERT(fill(just('y'), 'x') == just('x')); + //! [fill] + } + + { + //! [fmap] + auto to_string = [](auto x) { + return (std::ostringstream{} << x).str(); + }; + + BOOST_HANA_RUNTIME_ASSERT( + fmap(tuple(1, '2', "345", std::string{"67"}), to_string) + == + tuple("1", "2", "345", "67") + ); + + BOOST_HANA_CONSTANT_ASSERT(fmap(nothing, to_string) == nothing); + BOOST_HANA_RUNTIME_ASSERT(fmap(just(123), to_string) == just("123")); + + BOOST_HANA_CONSTANT_ASSERT( + fmap(type_list, template_) + == + type_list + ); + //! [fmap] + } + + { + //! [replace] + BOOST_HANA_CONSTEXPR_LAMBDA auto negative = [](auto x) { + return x < 0; + }; + + BOOST_HANA_CONSTEXPR_ASSERT( + replace(tuple(-3, -2, -1, 0, 1, 2, 3), negative, 0) + == + tuple(0, 0, 0, 0, 1, 2, 3) + ); + //! [replace] + } +} diff --git a/example/functor/adjust.cpp b/example/functor/adjust.cpp deleted file mode 100644 index 3818d8368..000000000 --- a/example/functor/adjust.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_LAMBDA auto negative = [](auto x) { - return x < 0; - }; - - BOOST_HANA_CONSTEXPR_LAMBDA auto negate = [](auto x) { - return -x; - }; - - BOOST_HANA_CONSTEXPR_ASSERT( - adjust(tuple(-3, -2, -1, 0, 1, 2, 3), negative, negate) - == - tuple(3, 2, 1, 0, 1, 2, 3) - ); - //! [main] -} diff --git a/example/functor/fill.cpp b/example/functor/fill.cpp deleted file mode 100644 index 17f5e6440..000000000 --- a/example/functor/fill.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT( - fill(tuple(1, '2', 3.3, nullptr), 'x') == tuple('x', 'x', 'x', 'x') - ); - - BOOST_HANA_CONSTANT_ASSERT(fill(nothing, 'x') == nothing); - BOOST_HANA_CONSTEXPR_ASSERT(fill(just('y'), 'x') == just('x')); - //! [main] -} diff --git a/example/functor/fmap.cpp b/example/functor/fmap.cpp deleted file mode 100644 index 7140e2774..000000000 --- a/example/functor/fmap.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -using namespace boost::hana; - - -int main() { - //! [to_string] - auto to_string = [](auto x) { - return (std::ostringstream{} << x).str(); - }; - - BOOST_HANA_RUNTIME_ASSERT( - fmap(tuple(1, '2', "345", std::string{"67"}), to_string) - == - tuple("1", "2", "345", "67") - ); - - BOOST_HANA_CONSTANT_ASSERT(fmap(nothing, to_string) == nothing); - BOOST_HANA_RUNTIME_ASSERT(fmap(just(123), to_string) == just("123")); - //! [to_string] - - //! [add_pointer] - BOOST_HANA_CONSTANT_ASSERT( - fmap(type_list, template_) - == - type_list - ); - //! [add_pointer] -} diff --git a/example/functor/replace.cpp b/example/functor/replace.cpp deleted file mode 100644 index c7635cf74..000000000 --- a/example/functor/replace.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_LAMBDA auto negative = [](auto x) { - return x < 0; - }; - - BOOST_HANA_CONSTEXPR_ASSERT( - replace(tuple(-3, -2, -1, 0, 1, 2, 3), negative, 0) - == - tuple(0, 0, 0, 0, 1, 2, 3) - ); - //! [main] -} diff --git a/example/list.cpp b/example/list.cpp index 21bd6a438..94b076b22 100644 --- a/example/list.cpp +++ b/example/list.cpp @@ -386,12 +386,10 @@ int main() { { //! [partition] - BOOST_HANA_CONSTEXPR_LAMBDA auto odd = [](auto x) { - return x % int_<2> != int_<0>; - }; - BOOST_HANA_CONSTANT_ASSERT( - partition(integer_list, odd) + partition(integer_list, [](auto x) { + return x % int_<2> != int_<0>; + }) == pair( integer_list, diff --git a/example/list/functor.cpp b/example/list/functor.cpp index 1ede1e9c3..58c0b3675 100644 --- a/example/list/functor.cpp +++ b/example/list/functor.cpp @@ -14,14 +14,16 @@ using namespace boost::hana; int main() { - //! [fmap] - auto to_string = [](auto x) { - return (std::ostringstream{} << x).str(); - }; + { + //! [fmap] + auto to_string = [](auto x) { + return (std::ostringstream{} << x).str(); + }; - BOOST_HANA_RUNTIME_ASSERT( - fmap(tuple(1, '2', "345", std::string{"67"}), to_string) == - tuple("1", "2", "345", "67") - ); - //! [fmap] + BOOST_HANA_RUNTIME_ASSERT( + fmap(tuple(1, '2', "345", std::string{"67"}), to_string) == + tuple("1", "2", "345", "67") + ); + //! [fmap] + } } diff --git a/example/list/searchable.cpp b/example/list/searchable.cpp index 5dec66130..36518fdf3 100644 --- a/example/list/searchable.cpp +++ b/example/list/searchable.cpp @@ -15,8 +15,10 @@ using namespace boost::hana; int main() { - //! [find] - BOOST_HANA_CONSTEXPR_ASSERT(find(tuple(1.0, 2, '3'), trait_) == just(2)); - BOOST_HANA_CONSTANT_ASSERT(find(tuple(1.0, 2, '3'), trait_) == nothing); - //! [find] + { + //! [find] + BOOST_HANA_CONSTEXPR_ASSERT(find(tuple(1.0, 2, '3'), trait_) == just(2)); + BOOST_HANA_CONSTANT_ASSERT(find(tuple(1.0, 2, '3'), trait_) == nothing); + //! [find] + } } diff --git a/example/list/traversable.cpp b/example/list/traversable.cpp index 05c41bc26..09168f150 100644 --- a/example/list/traversable.cpp +++ b/example/list/traversable.cpp @@ -12,11 +12,12 @@ Distributed under the Boost Software License, Version 1.0. #include using namespace boost::hana; -using namespace std::string_literals; int main() { - //! [sequence] + //! [main] + using namespace std::string_literals; + BOOST_HANA_RUNTIME_ASSERT( sequence( tuple(tuple("a1"s, "a2"s), tuple("b1"s), tuple("c1", "c2", "c3")) @@ -32,28 +33,24 @@ int main() { tuple("a2"s, "b1"s, "c3"s) ) ); - //! [sequence] - { - //! [traverse] - BOOST_HANA_CONSTEXPR_LAMBDA auto half = [](auto x) { - return if_(x % int_<2> == int_<0>, - just(x / int_<2>), - nothing - ); - }; - - BOOST_HANA_CONSTANT_ASSERT( - traverse(tuple(int_<2>, int_<4>, int_<6>), half) - == - just(tuple(int_<1>, int_<2>, int_<3>)) - ); - - BOOST_HANA_CONSTANT_ASSERT( - traverse(tuple(int_<2>, int_<3>, int_<6>), half) - == + BOOST_HANA_CONSTEXPR_LAMBDA auto half = [](auto x) { + return if_(x % int_<2> == int_<0>, + just(x / int_<2>), nothing ); - //! [traverse] - } + }; + + BOOST_HANA_CONSTANT_ASSERT( + traverse(tuple(int_<2>, int_<4>, int_<6>), half) + == + just(tuple(int_<1>, int_<2>, int_<3>)) + ); + + BOOST_HANA_CONSTANT_ASSERT( + traverse(tuple(int_<2>, int_<3>, int_<6>), half) + == + nothing + ); + //! [main] } diff --git a/example/maybe/maybe.cpp b/example/maybe/maybe.cpp index b55764a2f..067083d4b 100644 --- a/example/maybe/maybe.cpp +++ b/example/maybe/maybe.cpp @@ -21,22 +21,28 @@ int main() { //! [maybe] } - //! [is_just] - BOOST_HANA_CONSTANT_ASSERT( is_just(just('x'))); - BOOST_HANA_CONSTANT_ASSERT( is_just(just(nothing))); - BOOST_HANA_CONSTANT_ASSERT(!is_just(nothing)); - //! [is_just] + { + //! [is_just] + BOOST_HANA_CONSTANT_ASSERT( is_just(just('x'))); + BOOST_HANA_CONSTANT_ASSERT( is_just(just(nothing))); + BOOST_HANA_CONSTANT_ASSERT(!is_just(nothing)); + //! [is_just] + } - //! [is_nothing] - BOOST_HANA_CONSTANT_ASSERT( is_nothing(nothing)); - BOOST_HANA_CONSTANT_ASSERT(!is_nothing(just('x'))); - BOOST_HANA_CONSTANT_ASSERT(!is_nothing(just(nothing))); - //! [is_nothing] + { + //! [is_nothing] + BOOST_HANA_CONSTANT_ASSERT( is_nothing(nothing)); + BOOST_HANA_CONSTANT_ASSERT(!is_nothing(just('x'))); + BOOST_HANA_CONSTANT_ASSERT(!is_nothing(just(nothing))); + //! [is_nothing] + } - //! [from_maybe] - BOOST_HANA_CONSTEXPR_ASSERT(from_maybe('x', just(1)) == 1); - BOOST_HANA_CONSTEXPR_ASSERT(from_maybe('x', nothing) == 'x'); - //! [from_maybe] + { + //! [from_maybe] + BOOST_HANA_CONSTEXPR_ASSERT(from_maybe('x', just(1)) == 1); + BOOST_HANA_CONSTEXPR_ASSERT(from_maybe('x', nothing) == 'x'); + //! [from_maybe] + } { //! [only_when] @@ -53,10 +59,12 @@ int main() { //! [only_when] } - //! [from_just] - BOOST_HANA_CONSTEXPR_ASSERT(from_just(just('x')) == 'x'); - // from_just(nothing); // compile-time static assertion - // ! [from_just] + { + //! [from_just] + BOOST_HANA_CONSTEXPR_ASSERT(from_just(just('x')) == 'x'); + // from_just(nothing); // compile-time static assertion + // ! [from_just] + } { //! [nothing] diff --git a/example/traversable.cpp b/example/traversable.cpp new file mode 100644 index 000000000..b1124b2ba --- /dev/null +++ b/example/traversable.cpp @@ -0,0 +1,73 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include +#include +#include +#include +#include +using namespace boost::hana; + + +int main() { + { + //! [sequence] + BOOST_HANA_CONSTEXPR_ASSERT( + sequence(tuple(just(1), just('2'), just(3.3))) == just(tuple(1, '2', 3.3)) + ); + + BOOST_HANA_CONSTANT_ASSERT( + sequence(tuple(just(1), nothing, just(3.3))) == nothing + ); + + // This is a generalized Cartesian product. + BOOST_HANA_CONSTEXPR_ASSERT( + sequence(tuple(tuple(1, 2, 3), tuple(4), tuple(5, 6))) + == + tuple( + tuple(1, 4, 5), tuple(1, 4, 6), + tuple(2, 4, 5), tuple(2, 4, 6), + tuple(3, 4, 5), tuple(3, 4, 6) + ) + ); + //! [sequence] + } + + { + //! [traverse] + BOOST_HANA_CONSTEXPR_LAMBDA auto half = [](auto x) { + return if_(x % int_<2> == int_<0>, + just(x / int_<2>), + nothing + ); + }; + + BOOST_HANA_CONSTANT_ASSERT( + traverse(tuple(int_<2>, int_<4>, int_<6>), half) + == + just(tuple(int_<1>, int_<2>, int_<3>)) + ); + + BOOST_HANA_CONSTANT_ASSERT( + traverse(tuple(int_<2>, int_<3>, int_<6>), half) + == + nothing + ); + + BOOST_HANA_CONSTEXPR_LAMBDA auto twice = [](auto x) { + return tuple(x, x); + }; + + BOOST_HANA_CONSTEXPR_ASSERT( + traverse(just('x'), twice) == tuple(just('x'), just('x')) + ); + + BOOST_HANA_CONSTANT_ASSERT( + traverse(nothing, twice) == tuple(nothing) + ); + //! [traverse] + } +} diff --git a/example/traversable/sequence.cpp b/example/traversable/sequence.cpp deleted file mode 100644 index 42b8bf5a8..000000000 --- a/example/traversable/sequence.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT( - sequence(tuple(just(1), just('2'), just(3.3))) == just(tuple(1, '2', 3.3)) - ); - - BOOST_HANA_CONSTANT_ASSERT( - sequence(tuple(just(1), nothing, just(3.3))) == nothing - ); - - // This is a generalized Cartesian product. - BOOST_HANA_CONSTEXPR_ASSERT( - sequence(tuple(tuple(1, 2, 3), tuple(4), tuple(5, 6))) - == - tuple( - tuple(1, 4, 5), tuple(1, 4, 6), - tuple(2, 4, 5), tuple(2, 4, 6), - tuple(3, 4, 5), tuple(3, 4, 6) - ) - ); - //! [main] -} diff --git a/example/traversable/traverse.cpp b/example/traversable/traverse.cpp deleted file mode 100644 index fd99e1eed..000000000 --- a/example/traversable/traverse.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -#include -#include -using namespace boost::hana; - - -int main() { - //! [tuple] - BOOST_HANA_CONSTEXPR_LAMBDA auto half = [](auto x) { - return if_(x % int_<2> == int_<0>, - just(x / int_<2>), - nothing - ); - }; - - BOOST_HANA_CONSTANT_ASSERT( - traverse(tuple(int_<2>, int_<4>, int_<6>), half) - == - just(tuple(int_<1>, int_<2>, int_<3>)) - ); - - BOOST_HANA_CONSTANT_ASSERT( - traverse(tuple(int_<2>, int_<3>, int_<6>), half) - == - nothing - ); - //! [tuple] - - //! [maybe] - BOOST_HANA_CONSTEXPR_LAMBDA auto twice = [](auto x) { - return tuple(x, x); - }; - - BOOST_HANA_CONSTEXPR_ASSERT( - traverse(just('x'), twice) == tuple(just('x'), just('x')) - ); - - BOOST_HANA_CONSTANT_ASSERT( - traverse(nothing, twice) == tuple(nothing) - ); - //! [maybe] -} diff --git a/example/type/construct.cpp b/example/type/construct.cpp index 932502760..7272ab6e9 100644 --- a/example/type/construct.cpp +++ b/example/type/construct.cpp @@ -4,9 +4,9 @@ Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ +#include #include -#include #include using namespace boost::hana; @@ -22,6 +22,6 @@ bool operator==(Person x, Person y) int main() { Person john{"John Doe", 30}; - assert(type("John Doe", 30u) == john); + BOOST_HANA_RUNTIME_ASSERT(type("John Doe", 30u) == john); } //! [main] diff --git a/include/boost/hana/foldable/foldable.hpp b/include/boost/hana/foldable/foldable.hpp index 8b9561955..44184eb80 100644 --- a/include/boost/hana/foldable/foldable.hpp +++ b/include/boost/hana/foldable/foldable.hpp @@ -219,7 +219,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/foldable/minimum_by.cpp main + //! @snippet example/foldable.cpp minimum_by BOOST_HANA_CONSTEXPR_LAMBDA auto minimum_by = [](auto&& predicate, auto&& foldable) -> decltype(auto) { return Foldable::instance< datatype_t @@ -233,7 +233,7 @@ namespace boost { namespace hana { //! @relates Foldable //! //! ### Example - //! @snippet example/foldable/minimum.cpp main + //! @snippet example/foldable.cpp minimum BOOST_HANA_CONSTEXPR_LAMBDA auto minimum = [](auto&& foldable) -> decltype(auto) { return Foldable::instance< datatype_t @@ -255,7 +255,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/foldable/maximum_by.cpp main + //! @snippet example/foldable.cpp maximum_by BOOST_HANA_CONSTEXPR_LAMBDA auto maximum_by = [](auto&& predicate, auto&& foldable) -> decltype(auto) { return Foldable::instance< datatype_t @@ -269,7 +269,7 @@ namespace boost { namespace hana { //! @relates Foldable //! //! ### Example - //! @snippet example/foldable/maximum.cpp main + //! @snippet example/foldable.cpp maximum BOOST_HANA_CONSTEXPR_LAMBDA auto maximum = [](auto&& foldable) -> decltype(auto) { return Foldable::instance< datatype_t @@ -285,7 +285,7 @@ namespace boost { namespace hana { //! they are adjacent in `to(foldable)`. //! //! ### Example - //! @snippet example/foldable/sum.cpp main + //! @snippet example/foldable.cpp sum BOOST_HANA_CONSTEXPR_LAMBDA auto sum = [](auto&& foldable) -> decltype(auto) { return Foldable::instance< datatype_t @@ -301,7 +301,7 @@ namespace boost { namespace hana { //! they are adjacent in `to(foldable)`. //! //! ### Example - //! @snippet example/foldable/product.cpp main + //! @snippet example/foldable.cpp product BOOST_HANA_CONSTEXPR_LAMBDA auto product = [](auto&& foldable) -> decltype(auto) { return Foldable::instance< datatype_t @@ -323,7 +323,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/foldable/count.cpp main + //! @snippet example/foldable.cpp count BOOST_HANA_CONSTEXPR_LAMBDA auto count = [](auto&& foldable, auto&& predicate) -> decltype(auto) { return Foldable::instance< datatype_t @@ -348,13 +348,13 @@ namespace boost { namespace hana { //! @note //! This can be used to transform a function taking multiple arguments //! to a function taking a `Foldable` by partially applying `unpack`: - //! @snippet example/foldable/unpack_idiom.cpp main + //! @snippet example/foldable.cpp unpack_idiom //! This idiom serves the role of `boost::fusion::make_fused` and //! related utilities in the Boost.Fusion library. //! //! //! ### Example - //! @snippet example/foldable/unpack.cpp main + //! @snippet example/foldable.cpp unpack BOOST_HANA_CONSTEXPR_LAMBDA auto unpack = [](auto&& foldable, auto&& f) -> decltype(auto) { return Foldable::instance< datatype_t diff --git a/include/boost/hana/foldable/iterable_mcd.hpp b/include/boost/hana/foldable/iterable_mcd.hpp index fde1e05fe..ab3085b96 100644 --- a/include/boost/hana/foldable/iterable_mcd.hpp +++ b/include/boost/hana/foldable/iterable_mcd.hpp @@ -85,7 +85,7 @@ namespace boost { namespace hana { //! initial state are implemented in an analogous way. //! //! ### Example 1 - //! @snippet example/list/foldable/foldl.cpp main + //! @snippet example/list/foldable.cpp foldl //! //! ### Example 2 //! @snippet example/integer_list/foldable.cpp foldr diff --git a/include/boost/hana/functor/functor.hpp b/include/boost/hana/functor/functor.hpp index fd4c30cc7..59d558b1b 100644 --- a/include/boost/hana/functor/functor.hpp +++ b/include/boost/hana/functor/functor.hpp @@ -48,10 +48,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/functor/fmap.cpp to_string - //! - //! ### Example - //! @snippet example/functor/fmap.cpp add_pointer + //! @snippet example/functor.cpp fmap BOOST_HANA_CONSTEXPR_LAMBDA auto fmap = [](auto&& functor, auto&& f) -> decltype(auto) { return Functor::instance< datatype_t @@ -80,7 +77,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/functor/adjust.cpp main + //! @snippet example/functor.cpp adjust BOOST_HANA_CONSTEXPR_LAMBDA auto adjust = [](auto&& functor, auto&& predicate, auto&& f) -> decltype(auto) { return Functor::instance< datatype_t @@ -110,7 +107,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/functor/replace.cpp main + //! @snippet example/functor.cpp replace BOOST_HANA_CONSTEXPR_LAMBDA auto replace = [](auto&& functor, auto&& predicate, auto&& value) -> decltype(auto) { return Functor::instance< datatype_t @@ -134,7 +131,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/functor/fill.cpp main + //! @snippet example/functor.cpp fill BOOST_HANA_CONSTEXPR_LAMBDA auto fill = [](auto&& functor, auto&& value) -> decltype(auto) { return Functor::instance< datatype_t diff --git a/include/boost/hana/functor/list_mcd.hpp b/include/boost/hana/functor/list_mcd.hpp index 7d1b962f2..ea514abab 100644 --- a/include/boost/hana/functor/list_mcd.hpp +++ b/include/boost/hana/functor/list_mcd.hpp @@ -35,11 +35,8 @@ namespace boost { namespace hana { //! Mapping a function over an empty list returns an empty list and never //! applies the function. //! - //! ### Example 1 - //! @snippet example/list/functor/fmap.cpp main - //! - //! ### Example 2 - //! @snippet example/type_list/functor.cpp fmap + //! ### Example + //! @snippet example/list/functor.cpp fmap template struct Functor::instance()>> : Functor::list_mcd diff --git a/include/boost/hana/lazy/functor.hpp b/include/boost/hana/lazy/functor.hpp index 3368f9ad5..638034ed6 100644 --- a/include/boost/hana/lazy/functor.hpp +++ b/include/boost/hana/lazy/functor.hpp @@ -21,7 +21,7 @@ namespace boost { namespace hana { //! the function as a lazy value. //! //! ### Example - //! @snippet example/lazy/functor/fmap.cpp main + //! @snippet example/lazy/functor.cpp fmap template <> struct Functor::instance : Functor::fmap_mcd { template diff --git a/include/boost/hana/list/list.hpp b/include/boost/hana/list/list.hpp index ab3041146..e35fb8fee 100644 --- a/include/boost/hana/list/list.hpp +++ b/include/boost/hana/list/list.hpp @@ -64,7 +64,7 @@ namespace boost { namespace hana { //! Two instances of `List` with _the same data type_. //! //! ### Example - //! @snippet example/list/concat.cpp main + //! @snippet example/list.cpp concat BOOST_HANA_CONSTEXPR_LAMBDA auto concat = [](auto&& xs, auto&& ys) -> decltype(auto) { static_assert(detail::std::is_same< datatype_t, datatype_t @@ -90,7 +90,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/cons.cpp main + //! @snippet example/list.cpp cons BOOST_HANA_CONSTEXPR_LAMBDA auto cons = [](auto&& x, auto&& xs) -> decltype(auto) { return List::instance< datatype_t @@ -116,7 +116,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/filter.cpp main + //! @snippet example/list.cpp filter BOOST_HANA_CONSTEXPR_LAMBDA auto filter = [](auto&& xs, auto&& predicate) -> decltype(auto) { return List::instance< datatype_t @@ -150,7 +150,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/group_by.cpp main + //! @snippet example/list.cpp group_by BOOST_HANA_CONSTEXPR_LAMBDA auto group_by = [](auto&& predicate, auto&& xs) -> decltype(auto) { return List::instance< datatype_t @@ -171,7 +171,7 @@ namespace boost { namespace hana { //! The list to split into groups. //! //! ### Example - //! @snippet example/list/group.cpp main + //! @snippet example/list.cpp group BOOST_HANA_CONSTEXPR_LAMBDA auto group = [](auto&& xs) -> decltype(auto) { return List::instance< datatype_t @@ -182,7 +182,7 @@ namespace boost { namespace hana { //! @relates List //! //! ### Example - //! @snippet example/list/init.cpp main + //! @snippet example/list.cpp init BOOST_HANA_CONSTEXPR_LAMBDA auto init = [](auto&& xs) -> decltype(auto) { return List::instance< datatype_t @@ -215,7 +215,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/make.cpp main + //! @snippet example/list.cpp make #ifdef BOOST_HANA_DOXYGEN_INVOKED template constexpr auto make()>> = [](auto&& ...xs) -> decltype(auto) { @@ -237,7 +237,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/nil.cpp main + //! @snippet example/list.cpp nil template BOOST_HANA_CONSTEXPR_LAMBDA auto nil = List::instance::nil_impl(); @@ -262,10 +262,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/partition.cpp ints - //! - //! ### Example - //! @snippet example/list/partition.cpp types + //! @snippet example/list.cpp partition BOOST_HANA_CONSTEXPR_LAMBDA auto partition = [](auto&& xs, auto&& predicate) -> decltype(auto) { return List::instance< datatype_t @@ -284,7 +281,7 @@ namespace boost { namespace hana { //! Implementation taken from http://stackoverflow.com/a/2184129/627587. //! //! ### Example - //! @snippet example/list/permutations.cpp main + //! @snippet example/list.cpp permutations //! //! ### Benchmarks //! @image html benchmark.list.permutations.time.png @@ -302,7 +299,7 @@ namespace boost { namespace hana { //! @relates List //! //! ### Example - //! @snippet example/list/reverse.cpp main + //! @snippet example/list.cpp reverse BOOST_HANA_CONSTEXPR_LAMBDA auto reverse = [](auto&& xs) -> decltype(auto) { return List::instance< datatype_t @@ -326,7 +323,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/scanl.cpp main + //! @snippet example/list.cpp scanl //! //! ### Benchmarks //! @image html benchmark.list.scanl.time.png @@ -357,7 +354,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/scanl1.cpp main + //! @snippet example/list.cpp scanl1 //! //! ### Benchmarks //! @image html benchmark.list.scanl1.time.png @@ -387,7 +384,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/scanr.cpp main + //! @snippet example/list.cpp scanr //! //! ### Benchmarks //! @image html benchmark.list.scanr.time.png @@ -418,7 +415,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/scanr1.cpp main + //! @snippet example/list.cpp scanr1 //! //! ### Benchmarks //! @image html benchmark.list.scanr1.time.png @@ -454,7 +451,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/slice.cpp main + //! @snippet example/list.cpp slice //! //! @todo //! Should this be `slice(xs, from, length)` instead? @@ -509,7 +506,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/snoc.cpp main + //! @snippet example/list.cpp snoc BOOST_HANA_CONSTEXPR_LAMBDA auto snoc = [](auto&& xs, auto&& x) -> decltype(auto) { return List::instance< datatype_t @@ -528,7 +525,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/sort.cpp main + //! @snippet example/list.cpp sort BOOST_HANA_CONSTEXPR_LAMBDA auto sort = [](auto&& xs) -> decltype(auto) { return List::instance< datatype_t @@ -555,7 +552,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/sort_by.cpp main + //! @snippet example/list.cpp sort_by BOOST_HANA_CONSTEXPR_LAMBDA auto sort_by = [](auto&& predicate, auto&& xs) -> decltype(auto) { return List::instance< datatype_t @@ -594,7 +591,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/span.cpp main + //! @snippet example/list.cpp span BOOST_HANA_CONSTEXPR_LAMBDA auto span = [](auto&& xs, auto&& predicate) -> decltype(auto) { return List::instance< datatype_t @@ -618,7 +615,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/take.cpp main + //! @snippet example/list.cpp take BOOST_HANA_CONSTEXPR_LAMBDA auto take = [](auto&& n, auto&& xs) -> decltype(auto) { return List::instance< datatype_t @@ -673,7 +670,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/take_until.cpp main + //! @snippet example/list.cpp take_until BOOST_HANA_CONSTEXPR_LAMBDA auto take_until = [](auto&& xs, auto&& predicate) -> decltype(auto) { return List::instance< datatype_t @@ -702,7 +699,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/take_while.cpp main + //! @snippet example/list.cpp take_while BOOST_HANA_CONSTEXPR_LAMBDA auto take_while = [](auto&& xs, auto&& predicate) -> decltype(auto) { return List::instance< datatype_t @@ -768,7 +765,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/unfoldl.cpp main + //! @snippet example/list.cpp unfoldl #ifdef BOOST_HANA_DOXYGEN_INVOKED template constexpr auto unfoldl = [](auto&& f, auto&& init) -> decltype(auto) { @@ -814,7 +811,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/unfoldr.cpp main + //! @snippet example/list.cpp unfoldr #ifdef BOOST_HANA_DOXYGEN_INVOKED template constexpr auto unfoldr = [](auto&& f, auto&& init) -> decltype(auto) { @@ -845,7 +842,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/unzip.cpp main + //! @snippet example/list.cpp unzip BOOST_HANA_CONSTEXPR_LAMBDA auto unzip = [](auto&& xs) -> decltype(auto) { return List::instance< datatype_t @@ -862,7 +859,7 @@ namespace boost { namespace hana { //! The lists to zip together. //! //! ### Example - //! @snippet example/list/zip.cpp main + //! @snippet example/list.cpp zip BOOST_HANA_CONSTEXPR_LAMBDA auto zip = [](auto&& xs, auto&& ...ys) -> decltype(auto) { return List::instance< datatype_t @@ -899,7 +896,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/list/zip_with.cpp main + //! @snippet example/list.cpp zip_with //! //! @todo //! Consider allowing only two lists and achieving the variadic behavior diff --git a/include/boost/hana/maybe/maybe.hpp b/include/boost/hana/maybe/maybe.hpp index 000590603..20351ceb0 100644 --- a/include/boost/hana/maybe/maybe.hpp +++ b/include/boost/hana/maybe/maybe.hpp @@ -60,7 +60,7 @@ namespace boost { namespace hana { //! @relates Maybe //! //! ### Example - //! @snippet example/maybe/just.cpp main + //! @snippet example/maybe/maybe.cpp just constexpr auto just = [](auto x) { return unspecified; }; @@ -69,7 +69,7 @@ namespace boost { namespace hana { //! @relates Maybe //! //! ### Example - //! @snippet example/maybe/nothing.cpp main + //! @snippet example/maybe/maybe.cpp nothing constexpr unspecified nothing{}; #else BOOST_HANA_CONSTEXPR_LAMBDA auto just = [](auto x) { @@ -105,7 +105,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/maybe/only_when.cpp main + //! @snippet example/maybe/maybe.cpp only_when BOOST_HANA_CONSTEXPR_LAMBDA auto only_when = [](auto predicate, auto f, auto x) { return eval_if(predicate(x), [=](auto _) { return just(_(f)(x)); }, @@ -136,7 +136,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/maybe/maybe.cpp main + //! @snippet example/maybe/maybe.cpp maybe #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto maybe = [](auto default_, auto f, auto m) { unspecified; @@ -155,7 +155,7 @@ namespace boost { namespace hana { //! and a false-valued one otherwise. //! //! ### Example - //! @snippet example/maybe/is_just.cpp main + //! @snippet example/maybe/maybe.cpp is_just BOOST_HANA_CONSTEXPR_LAMBDA auto is_just = [](auto m) { return maybe(false_, [](auto) { return true_; }, m); }; @@ -168,7 +168,7 @@ namespace boost { namespace hana { //! false-valued one otherwise. //! //! ### Example - //! @snippet example/maybe/is_nothing.cpp main + //! @snippet example/maybe/maybe.cpp is_nothing BOOST_HANA_CONSTEXPR_LAMBDA auto is_nothing = [](auto m) { return maybe(true_, [](auto) { return false_; }, m); }; @@ -188,7 +188,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/maybe/from_maybe.cpp main + //! @snippet example/maybe/maybe.cpp from_maybe BOOST_HANA_CONSTEXPR_LAMBDA auto from_maybe = [](auto default_, auto m) { return maybe(default_, [](auto x) { return x; }, m); }; @@ -200,7 +200,7 @@ namespace boost { namespace hana { //! `just(x)`, and triggers a static assertion otherwise. //! //! ### Example - //! @snippet example/maybe/from_just.cpp main + //! @snippet example/maybe/maybe.cpp from_just BOOST_HANA_CONSTEXPR_LAMBDA auto from_just = [](auto m) { auto err = [](auto ...dum) { constexpr bool always_false = sizeof...(dum) != 0; diff --git a/include/boost/hana/searchable/list_mcd.hpp b/include/boost/hana/searchable/list_mcd.hpp index 464fa4bd5..05f4bf571 100644 --- a/include/boost/hana/searchable/list_mcd.hpp +++ b/include/boost/hana/searchable/list_mcd.hpp @@ -55,7 +55,7 @@ namespace boost { namespace hana { //! Technically, this can be implemented in `Iterable`. Should it? //! //! ### Example - //! @snippet example/list/searchable/find.cpp main + //! @snippet example/list/searchable.cpp find template struct Searchable::instance()>> : Searchable::list_mcd diff --git a/include/boost/hana/traversable/list_mcd.hpp b/include/boost/hana/traversable/list_mcd.hpp index 5c50d7a3d..ddbe5c36d 100644 --- a/include/boost/hana/traversable/list_mcd.hpp +++ b/include/boost/hana/traversable/list_mcd.hpp @@ -36,10 +36,7 @@ namespace boost { namespace hana { //! `Traversable` instance for `List` instances. //! //! ### Example - //! @snippet example/list/traversable/traverse.cpp main - //! - //! ### Example - //! @snippet example/list/traversable/sequence.cpp main + //! @snippet example/list/traversable.cpp main template struct Traversable::instance()>> : Traversable::list_mcd diff --git a/include/boost/hana/traversable/traversable.hpp b/include/boost/hana/traversable/traversable.hpp index 3b8b3a0bc..6dda00d32 100644 --- a/include/boost/hana/traversable/traversable.hpp +++ b/include/boost/hana/traversable/traversable.hpp @@ -90,7 +90,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/traversable/sequence.cpp main + //! @snippet example/traversable.cpp sequence #ifdef BOOST_HANA_DOXYGEN_INVOKED template constexpr auto sequence = [](auto&& traversable) -> decltype(auto) { @@ -107,6 +107,7 @@ namespace boost { namespace hana { //! the same as `sequence`. //! @relates Traversable //! + //! //! @tparam A //! The data type (an `Applicative`) of an object returned by `f` when //! called with an element of the structure. We must specify this data @@ -123,10 +124,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/traversable/traverse.cpp tuple - //! - //! ### Example - //! @snippet example/traversable/traverse.cpp maybe + //! @snippet example/traversable.cpp traverse #ifdef BOOST_HANA_DOXYGEN_INVOKED template constexpr auto traverse = [](auto&& traversable, auto&& f) -> decltype(auto) { diff --git a/include/boost/hana/tuple/iterable.hpp b/include/boost/hana/tuple/iterable.hpp index 16d7ef377..c103ddd3f 100644 --- a/include/boost/hana/tuple/iterable.hpp +++ b/include/boost/hana/tuple/iterable.hpp @@ -25,7 +25,7 @@ namespace boost { namespace hana { //! it has no elements in it. //! //! ### Example - //! @snippet example/list/iterable/overview.cpp main + //! @snippet example/list/iterable.cpp main template <> struct Iterable::instance : Iterable::mcd { template