]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Forward declares `boost::hana::difference`. | |
4 | ||
5 | @copyright Louis Dionne 2013-2016 | |
6 | Distributed under the Boost Software License, Version 1.0. | |
7 | (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | |
8 | */ | |
9 | ||
10 | #ifndef BOOST_HANA_FWD_DIFFERENCE_HPP | |
11 | #define BOOST_HANA_FWD_DIFFERENCE_HPP | |
12 | ||
13 | #include <boost/hana/config.hpp> | |
14 | #include <boost/hana/core/when.hpp> | |
15 | ||
16 | ||
17 | BOOST_HANA_NAMESPACE_BEGIN | |
18 | //! Returns the set-theoretic difference of two sets. | |
19 | //! @relates hana::set | |
20 | //! | |
21 | //! Given two sets `xs` and `ys`, `difference(xs, ys)` is a new set | |
22 | //! containing all the elements of `xs` that are _not_ contained in `ys`. | |
23 | //! For any object `x`, the following holds: | |
24 | //! @code | |
25 | //! x ^in^ difference(xs, ys) if and only if x ^in^ xs && !(x ^in^ ys) | |
26 | //! @endcode | |
27 | //! | |
28 | //! | |
29 | //! @note | |
30 | //! This operation is not commutative, i.e. `difference(xs, ys)` is not | |
31 | //! necessarily the same as `difference(ys, xs)`. Indeed, consider the | |
32 | //! case where `xs` is empty and `ys` isn't. Then, `difference(xs, ys)` | |
33 | //! is empty but `difference(ys, xs)` is equal to `ys`. For the symmetric | |
34 | //! version of this operation, see `symmetric_difference`. | |
35 | //! | |
36 | //! | |
37 | //! @param xs | |
38 | //! A set to remove values from. | |
39 | //! | |
40 | //! @param ys | |
41 | //! The set whose values are removed from `xs`. | |
42 | //! | |
43 | //! | |
44 | //! Example | |
45 | //! ------- | |
46 | //! @include example/difference.cpp | |
47 | #ifdef BOOST_HANA_DOXYGEN_INVOKED | |
48 | constexpr auto difference = [](auto&& xs, auto&& ys) { | |
49 | return tag-dispatched; | |
50 | }; | |
51 | #else | |
52 | template <typename S, typename = void> | |
53 | struct difference_impl : difference_impl<S, when<true>> { }; | |
54 | ||
55 | struct difference_t { | |
56 | template <typename Xs, typename Ys> | |
57 | constexpr auto operator()(Xs&& xs, Ys&& ys) const; | |
58 | }; | |
59 | ||
60 | constexpr difference_t difference{}; | |
61 | #endif | |
62 | BOOST_HANA_NAMESPACE_END | |
63 | ||
64 | #endif // !BOOST_HANA_FWD_DIFFERENCE_HPP |