diff options
Diffstat (limited to 'boost/hana/fwd')
-rw-r--r-- | boost/hana/fwd/adjust_if.hpp | 2 | ||||
-rw-r--r-- | boost/hana/fwd/core/tag_of.hpp | 2 | ||||
-rw-r--r-- | boost/hana/fwd/difference.hpp | 40 | ||||
-rw-r--r-- | boost/hana/fwd/index_if.hpp | 60 | ||||
-rw-r--r-- | boost/hana/fwd/intersection.hpp | 29 | ||||
-rw-r--r-- | boost/hana/fwd/map.hpp | 120 | ||||
-rw-r--r-- | boost/hana/fwd/replace_if.hpp | 2 | ||||
-rw-r--r-- | boost/hana/fwd/set.hpp | 107 | ||||
-rw-r--r-- | boost/hana/fwd/symmetric_difference.hpp | 30 | ||||
-rw-r--r-- | boost/hana/fwd/union.hpp | 33 |
10 files changed, 308 insertions, 117 deletions
diff --git a/boost/hana/fwd/adjust_if.hpp b/boost/hana/fwd/adjust_if.hpp index 017ac03972..3042dc72c9 100644 --- a/boost/hana/fwd/adjust_if.hpp +++ b/boost/hana/fwd/adjust_if.hpp @@ -31,7 +31,7 @@ BOOST_HANA_NAMESPACE_BEGIN //! --------- //! Given a `Functor` `F` and a `Logical` `Bool`, the signature is //! \f$ - //! \mathtt{adjust_if} : F(T) \times (T \to Bool) \times (T \to T) \to F(T) + //! \mathtt{adjust\_if} : F(T) \times (T \to Bool) \times (T \to T) \to F(T) //! \f$ //! //! @param xs diff --git a/boost/hana/fwd/core/tag_of.hpp b/boost/hana/fwd/core/tag_of.hpp index bcc4ef8e53..5d490dd717 100644 --- a/boost/hana/fwd/core/tag_of.hpp +++ b/boost/hana/fwd/core/tag_of.hpp @@ -57,7 +57,7 @@ BOOST_HANA_NAMESPACE_BEGIN //! std::is_same< //! typename fusion::traits::tag_of<T>::type, //! fusion::traits::tag_of<fusion::vector<>>::type - //! >{} + //! >::value //! >> { //! using type = BoostFusionVector; //! }; diff --git a/boost/hana/fwd/difference.hpp b/boost/hana/fwd/difference.hpp index 3702f075e0..d96142b5b9 100644 --- a/boost/hana/fwd/difference.hpp +++ b/boost/hana/fwd/difference.hpp @@ -15,50 +15,18 @@ Distributed under the Boost Software License, Version 1.0. BOOST_HANA_NAMESPACE_BEGIN - //! Returns the set-theoretic difference of two sets. - //! @relates hana::set - //! - //! Given two sets `xs` and `ys`, `difference(xs, ys)` is a new set - //! containing all the elements of `xs` that are _not_ contained in `ys`. - //! For any object `x`, the following holds: - //! @code - //! x ^in^ difference(xs, ys) if and only if x ^in^ xs && !(x ^in^ ys) - //! @endcode - //! - //! - //! @note - //! This operation is not commutative, i.e. `difference(xs, ys)` is not - //! necessarily the same as `difference(ys, xs)`. Indeed, consider the - //! case where `xs` is empty and `ys` isn't. Then, `difference(xs, ys)` - //! is empty but `difference(ys, xs)` is equal to `ys`. For the symmetric - //! version of this operation, see `symmetric_difference`. - //! - //! - //! @param xs - //! A set to remove values from. - //! - //! @param ys - //! The set whose values are removed from `xs`. - //! - //! - //! Example - //! ------- - //! @include example/difference.cpp -#ifdef BOOST_HANA_DOXYGEN_INVOKED - constexpr auto difference = [](auto&& xs, auto&& ys) { - return tag-dispatched; - }; -#else + // Note: This function is documented per datatype/concept only. + //! @cond template <typename S, typename = void> struct difference_impl : difference_impl<S, when<true>> { }; + //! @endcond struct difference_t { template <typename Xs, typename Ys> - constexpr auto operator()(Xs&& xs, Ys&& ys) const; + constexpr auto operator()(Xs&&, Ys&&) const; }; constexpr difference_t difference{}; -#endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_DIFFERENCE_HPP diff --git a/boost/hana/fwd/index_if.hpp b/boost/hana/fwd/index_if.hpp new file mode 100644 index 0000000000..59f98f59fa --- /dev/null +++ b/boost/hana/fwd/index_if.hpp @@ -0,0 +1,60 @@ +/*! +@file +Forward declares `boost::hana::index_if`. + +@copyright Louis Dionne 2013-2017 +@copyright Jason Rice 2017 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#ifndef BOOST_HANA_FWD_INDEX_IF_HPP +#define BOOST_HANA_FWD_INDEX_IF_HPP + +#include <boost/hana/config.hpp> +#include <boost/hana/core/when.hpp> + + +BOOST_HANA_NAMESPACE_BEGIN + //! Finds the value associated to the first key satisfying a predicate. + //! @ingroup group-Iterable + //! + //! Given an `Iterable` structure `xs` and a predicate `pred`, + //! `index_if(xs, pred)` returns a `hana::optional` containing an `IntegralConstant` + //! of the index of the first element that satisfies the predicate or nothing + //! if no element satisfies the predicate. + //! + //! + //! @param xs + //! The structure to be searched. + //! + //! @param predicate + //! A function called as `predicate(x)`, where `x` is an element of the + //! `Iterable` structure and returning whether `x` is the element being + //! searched for. In the current version of the library, the predicate + //! has to return an `IntegralConstant` holding a value that can be + //! converted to `bool`. + //! + //! + //! Example + //! ------- + //! @include example/index_if.cpp +#ifdef BOOST_HANA_DOXYGEN_INVOKED + constexpr auto index_if = [](auto&& xs, auto&& predicate) { + return tag-dispatched; + }; +#else + template <typename S, typename = void> + struct index_if_impl : index_if_impl<S, when<true>> { }; + + struct index_if_t { + template <typename Xs, typename Pred> + constexpr auto operator()(Xs&& xs, Pred&& pred) const; + }; + + constexpr index_if_t index_if{}; +#endif +BOOST_HANA_NAMESPACE_END + +#endif // !BOOST_HANA_FWD_INDEX_IF_HPP + diff --git a/boost/hana/fwd/intersection.hpp b/boost/hana/fwd/intersection.hpp index ec9b1daad2..f289dd03fa 100644 --- a/boost/hana/fwd/intersection.hpp +++ b/boost/hana/fwd/intersection.hpp @@ -15,39 +15,18 @@ Distributed under the Boost Software License, Version 1.0. BOOST_HANA_NAMESPACE_BEGIN - //! Returns the intersection of two sets. - //! @relates hana::set - //! - //! Given two sets `xs` and `ys`, `intersection(xs, ys)` is a new set - //! containing exactly those elements that are present both in `xs` and - //! in `ys`. In other words, the following holds for any object `x`: - //! @code - //! x ^in^ intersection(xs, ys) if and only if x ^in^ xs && x ^in^ ys - //! @endcode - //! - //! - //! @param xs, ys - //! Two sets to intersect. - //! - //! - //! Example - //! ------- - //! @include example/intersection.cpp -#ifdef BOOST_HANA_DOXYGEN_INVOKED - constexpr auto intersection = [](auto&& xs, auto&& ys) { - return tag-dispatched; - }; -#else + // Note: This function is documented per datatype/concept only. + //! @cond template <typename S, typename = void> struct intersection_impl : intersection_impl<S, when<true>> { }; + //! @endcond struct intersection_t { template <typename Xs, typename Ys> - constexpr auto operator()(Xs&& xs, Ys&& ys) const; + constexpr auto operator()(Xs&&, Ys&&) const; }; constexpr intersection_t intersection{}; -#endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_INTERSECTION_HPP diff --git a/boost/hana/fwd/map.hpp b/boost/hana/fwd/map.hpp index bff0b012f0..c00f57195f 100644 --- a/boost/hana/fwd/map.hpp +++ b/boost/hana/fwd/map.hpp @@ -255,6 +255,126 @@ BOOST_HANA_NAMESPACE_BEGIN return tag-dispatched; }; #endif + + //! Returns the union of two maps. + //! @relates hana::map + //! + //! Given two maps `xs` and `ys`, `hana::union_(xs, ys)` is a new map + //! containing all the elements of `xs` and all the elements of `ys`, + //! without duplicates. If both `xs` and `ys` contain an element with the + //! same `key`, the one in `ys` is taken. Functionally, + //! `hana::union_(xs, ys)` is equivalent to + //! @code + //! hana::fold_left(xs, ys, hana::insert) + //! @endcode + //! + //! @param xs, ys + //! The two maps to compute the union of. + //! + //! + //! Example + //! ------- + //! @include example/map/union.cpp +#ifdef BOOST_HANA_DOXYGEN_INVOKED + constexpr auto union_ = [](auto&& xs, auto&& ys) { + return tag-dispatched; + }; +#endif + + //! Returns the intersection of two maps. + //! @relates hana::map + //! + //! Given two maps `xs` and `ys`, `intersection(xs, ys)` is a new map + //! containing exactly those (key, value) pairs from xs, for which key + //! is present in `ys`. + //! In other words, the following holds for any object `pair(k, v)`: + //! @code + //! pair(k, v) ^in^ intersection(xs, ys) if and only if (k, v) ^in^ xs && k ^in^ keys(ys) + //! @endcode + //! + //! + //! @note + //! This function is not commutative, i.e. `intersection(xs, ys)` is not + //! necessarily the same as `intersection(ys, xs)`. Indeed, the set of keys + //! in `intersection(xs, ys)` is always the same as the set of keys in + //! `intersection(ys, xs)`, but the value associated to each key may be + //! different. `intersection(xs, ys)` contains values present in `xs`, and + //! `intersection(ys, xs)` contains values present in `ys`. + //! + //! + //! @param xs, ys + //! Two maps to intersect. + //! + //! + //! Example + //! ------- + //! @include example/map/intersection.cpp +#ifdef BOOST_HANA_DOXYGEN_INVOKED + constexpr auto intersection = [](auto&& xs, auto&& ys) { + return tag-dispatched; + }; +#endif + + //! Returns the difference of two maps. + //! @relates hana::map + //! + //! Given two maps `xs` and `ys`, `difference(xs, ys)` is a new map + //! containing exactly those (key, value) pairs from xs, for which key + //! is not present in `keys(ys)`. + //! In other words, the following holds for any object `pair(k, v)`: + //! @code + //! pair(k, v) ^in^ difference(xs, ys) if and only if (k, v) ^in^ xs && k ^not in^ keys(ys) + //! @endcode + //! + //! + //! @note + //! This function is not commutative, i.e. `difference(xs, ys)` is not + //! necessarily the same as `difference(ys, xs)`. + //! Indeed, consider the case where `xs` is empty and `ys` isn't. + //! In that case, `difference(xs, ys)` is empty, but `difference(ys, xs)` + //! is equal to `ys`. + //! For symmetric version of this operation, see `symmetric_difference`. + //! + //! + //! @param xs, ys + //! Two maps to compute the difference of. + //! + //! + //! Example + //! ------- + //! @include example/map/intersection.cpp +#ifdef BOOST_HANA_DOXYGEN_INVOKED + constexpr auto difference = [](auto&& xs, auto&& ys) { + return tag-dispatched; + }; +#endif + + //! Returns the symmetric set-theoretic difference of two maps. + //! @relates hana::map + //! + //! Given two sets `xs` and `ys`, `symmetric_difference(xs, ys)` is a new + //! map containing all the elements of `xs` whose keys are not contained in `keys(ys)`, + //! and all the elements of `ys` whose keys are not contained in `keys(xs)`. The + //! symmetric difference of two maps satisfies the following: + //! @code + //! symmetric_difference(xs, ys) == union_(difference(xs, ys), difference(ys, xs)) + //! @endcode + //! + //! + //! @param xs, ys + //! Two maps to compute the symmetric difference of. + //! + //! + //! Example + //! ------- + //! @include example/map/symmetric_difference.cpp +#ifdef BOOST_HANA_DOXYGEN_INVOKED +constexpr auto symmetric_difference = [](auto&& xs, auto&& ys) { + return tag-dispatched; + }; +#endif + + BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_MAP_HPP diff --git a/boost/hana/fwd/replace_if.hpp b/boost/hana/fwd/replace_if.hpp index e3fe882125..48d5b4c15c 100644 --- a/boost/hana/fwd/replace_if.hpp +++ b/boost/hana/fwd/replace_if.hpp @@ -24,7 +24,7 @@ BOOST_HANA_NAMESPACE_BEGIN //! --------- //! Given `F` a Functor and `Bool` a Logical, the signature is //! \f$ - //! \mathtt{replace_if} : F(T) \times (T \to Bool) \times T \to F(T) + //! \mathtt{replace\_if} : F(T) \times (T \to Bool) \times T \to F(T) //! \f$ //! //! @param xs diff --git a/boost/hana/fwd/set.hpp b/boost/hana/fwd/set.hpp index 55bd72d248..7312854782 100644 --- a/boost/hana/fwd/set.hpp +++ b/boost/hana/fwd/set.hpp @@ -182,9 +182,116 @@ BOOST_HANA_NAMESPACE_BEGIN }; #endif + //! Returns the union of two sets. + //! @relates hana::set + //! + //! Given two sets `xs` and `ys`, `union_(xs, ys)` is a new set containing + //! all the elements of `xs` and all the elements of `ys`, without + //! duplicates. For any object `x`, the following holds: `x` is in + //! `hana::union_(xs, ys)` if and only if `x` is in `xs` or `x` is in `ys`. + //! + //! + //! @param xs, ys + //! Two sets to compute the union of. + //! + //! + //! Example + //! ------- + //! @include example/set/union.cpp +#ifdef BOOST_HANA_DOXYGEN_INVOKED + constexpr auto union_ = [](auto&& xs, auto&& ys) { + return tag-dispatched; + }; +#endif + + //! Returns the intersection of two sets. + //! @relates hana::set + //! + //! Given two sets `xs` and `ys`, `intersection(xs, ys)` is a new set + //! containing exactly those elements that are present both in `xs` and + //! in `ys`. + //! In other words, the following holds for any object `x`: + //! @code + //! x ^in^ intersection(xs, ys) if and only if x ^in^ xs && x ^in^ ys + //! @endcode + //! + //! + //! @param xs, ys + //! Two sets to intersect. + //! + //! + //! Example + //! ------- + //! @include example/set/intersection.cpp +#ifdef BOOST_HANA_DOXYGEN_INVOKED + constexpr auto intersection = [](auto&& xs, auto&& ys) { + return tag-dispatched; + }; +#endif //! Equivalent to `to<set_tag>`; provided for convenience. //! @relates hana::set constexpr auto to_set = to<set_tag>; + + //! Returns the set-theoretic difference of two sets. + //! @relates hana::set + //! + //! Given two sets `xs` and `ys`, `difference(xs, ys)` is a new set + //! containing all the elements of `xs` that are _not_ contained in `ys`. + //! For any object `x`, the following holds: + //! @code + //! x ^in^ difference(xs, ys) if and only if x ^in^ xs && !(x ^in^ ys) + //! @endcode + //! + //! + //! This operation is not commutative, i.e. `difference(xs, ys)` is not + //! necessarily the same as `difference(ys, xs)`. Indeed, consider the + //! case where `xs` is empty and `ys` isn't. Then, `difference(xs, ys)` + //! is empty but `difference(ys, xs)` is equal to `ys`. For the symmetric + //! version of this operation, see `symmetric_difference`. + //! + //! + //! @param xs + //! A set param to remove values from. + //! + //! @param ys + //! The set whose values are removed from `xs`. + //! + //! + //! Example + //! ------- + //! @include example/set/difference.cpp +#ifdef BOOST_HANA_DOXYGEN_INVOKED + constexpr auto difference = [](auto&& xs, auto&& ys) { + return tag-dispatched; +}; +#endif + + //! Returns the symmetric set-theoretic difference of two sets. + //! @relates hana::set + //! + //! Given two sets `xs` and `ys`, `symmetric_difference(xs, ys)` is a new + //! set containing all the elements of `xs` that are not contained in `ys`, + //! and all the elements of `ys` that are not contained in `xs`. The + //! symmetric difference of two sets satisfies the following: + //! @code + //! symmetric_difference(xs, ys) == union_(difference(xs, ys), difference(ys, xs)) + //! @endcode + //! + //! + //! @param xs, ys + //! Two sets to compute the symmetric difference of. + //! + //! + //! Example + //! ------- + //! @include example/set/symmetric_difference.cpp +#ifdef BOOST_HANA_DOXYGEN_INVOKED +constexpr auto symmetric_difference = [](auto&& xs, auto&& ys) { + return tag-dispatched; + }; +#endif + + BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_SET_HPP diff --git a/boost/hana/fwd/symmetric_difference.hpp b/boost/hana/fwd/symmetric_difference.hpp index 2908daaeee..2253f167eb 100644 --- a/boost/hana/fwd/symmetric_difference.hpp +++ b/boost/hana/fwd/symmetric_difference.hpp @@ -15,40 +15,18 @@ Distributed under the Boost Software License, Version 1.0. BOOST_HANA_NAMESPACE_BEGIN - //! Returns the symmetric set-theoretic difference of two sets. - //! @relates hana::set - //! - //! Given two sets `xs` and `ys`, `symmetric_difference(xs, ys)` is a new - //! set containing all the elements of `xs` that are not contained in `ys`, - //! and all the elements of `ys` that are not contained in `xs`. The - //! symmetric difference of two sets satisfies the following: - //! @code - //! symmetric_difference(xs, ys) == union_(difference(xs, ys), difference(ys, xs)) - //! @endcode - //! - //! - //! @param xs, ys - //! Two sets to compute the symmetric difference of. - //! - //! - //! Example - //! ------- - //! @include example/symmetric_difference.cpp -#ifdef BOOST_HANA_DOXYGEN_INVOKED - constexpr auto symmetric_difference = [](auto&& xs, auto&& ys) { - return tag-dispatched; - }; -#else + // Note: This function is documented per datatype/concept only. + //! @cond template <typename S, typename = void> struct symmetric_difference_impl : symmetric_difference_impl<S, when<true>> { }; + //! @endcond struct symmetric_difference_t { template <typename Xs, typename Ys> - constexpr auto operator()(Xs&& xs, Ys&& ys) const; + constexpr auto operator()(Xs&&, Ys&&) const; }; constexpr symmetric_difference_t symmetric_difference{}; -#endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_SYMMETRIC_DIFFERENCE_HPP diff --git a/boost/hana/fwd/union.hpp b/boost/hana/fwd/union.hpp index ccf539221f..5775151888 100644 --- a/boost/hana/fwd/union.hpp +++ b/boost/hana/fwd/union.hpp @@ -15,39 +15,18 @@ Distributed under the Boost Software License, Version 1.0. BOOST_HANA_NAMESPACE_BEGIN - //! Returns the union of two sets. - //! @relates hana::set - //! - //! Given two sets `xs` and `ys`, `union_(xs, ys)` is a new set containing - //! all the elements of `xs` and all the elements of `ys`, without - //! duplicates. For any object `x`, the following holds: - //! @code - //! x ^in^ union_(xs, ys) if and only if x ^in^ xs || x ^in^ ys - //! @endcode - //! - //! - //! @param xs, ys - //! Two sets to compute the union of. - //! - //! - //! Example - //! ------- - //! @include example/union.cpp -#ifdef BOOST_HANA_DOXYGEN_INVOKED - constexpr auto union_ = [](auto&& xs, auto&& ys) { - return tag-dispatched; - }; -#else - template <typename S, typename = void> - struct union_impl : union_impl<S, when<true>> { }; + // Note: This function is documented per datatype/concept only. + //! @cond + template <typename T, typename = void> + struct union_impl : union_impl<T, when<true>> { }; + //! @endcond struct union_t { template <typename Xs, typename Ys> - constexpr auto operator()(Xs&& xs, Ys&& ys) const; + constexpr auto operator()(Xs&&, Ys&&) const; }; constexpr union_t union_{}; -#endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_UNION_HPP |