diff options
Diffstat (limited to 'boost/hana/fwd/map.hpp')
-rw-r--r-- | boost/hana/fwd/map.hpp | 120 |
1 files changed, 120 insertions, 0 deletions
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 |