diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:38:45 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:39:52 +0900 |
commit | 5cde13f21d36c7224b0e13d11c4b49379ae5210d (patch) | |
tree | e8269ac85a4b0f7d416e2565fa4f451b5cb41351 /boost/hana/fwd/equal.hpp | |
parent | d9ec475d945d3035377a0d89ed42e382d8988891 (diff) | |
download | boost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.tar.gz boost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.tar.bz2 boost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.zip |
Imported Upstream version 1.61.0
Change-Id: I96a1f878d1e6164f01e9aadd5147f38fca448d90
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/hana/fwd/equal.hpp')
-rw-r--r-- | boost/hana/fwd/equal.hpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/boost/hana/fwd/equal.hpp b/boost/hana/fwd/equal.hpp new file mode 100644 index 0000000000..e72614407d --- /dev/null +++ b/boost/hana/fwd/equal.hpp @@ -0,0 +1,80 @@ +/*! +@file +Forward declares `boost::hana::equal`. + +@copyright Louis Dionne 2013-2016 +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_EQUAL_HPP +#define BOOST_HANA_FWD_EQUAL_HPP + +#include <boost/hana/config.hpp> +#include <boost/hana/core/when.hpp> +#include <boost/hana/detail/nested_to_fwd.hpp> + + +BOOST_HANA_NAMESPACE_BEGIN + //! Returns a `Logical` representing whether `x` is equal to `y`. + //! @ingroup group-Comparable + //! + //! The `equal` function can be called in two different ways. First, it + //! can be called like a normal function: + //! @code + //! equal(x, y) + //! @endcode + //! + //! However, it may also be partially applied to an argument by using + //! `equal.to`: + //! @code + //! equal.to(x)(y) == equal(x, y) + //! @endcode + //! + //! In other words, `equal.to(x)` is a function object that is equivalent + //! to `partial(equal, x)`. This is provided to enhance the readability of + //! some constructs, especially when using higher order algorithms. + //! + //! + //! Signature + //! --------- + //! Given a Logical `Bool` and two Comparables `A` and `B` that + //! share a common embedding, the signature is + //! @f$ \mathtt{equal} : A \times B \to Bool @f$. + //! + //! @param x, y + //! Two objects to compare for equality. + //! + //! + //! Example + //! ------- + //! @include example/equal.cpp + //! + //! + //! > #### Rationale for the arity of `equal` + //! > It is a valid question whether `equal` should accept more than 2 + //! > arguments and have semantics matching those of Python's `==`. This + //! > is not supported right now for the following reasons: + //! > - It was implemented in the MPL11, but it was not shown to be useful + //! > so far. + //! > - It does not make sense for `not_equal` to have an arity of more + //! > than 2, only `equal` could maybe have those semantics, which would + //! > break symmetry. +#ifdef BOOST_HANA_DOXYGEN_INVOKED + constexpr auto equal = [](auto&& x, auto&& y) { + return tag-dispatched; + }; +#else + template <typename T, typename U, typename = void> + struct equal_impl : equal_impl<T, U, when<true>> { }; + + struct equal_t : detail::nested_to<equal_t> { + template <typename X, typename Y> + constexpr auto operator()(X&& x, Y&& y) const; + }; + + constexpr equal_t equal{}; +#endif +BOOST_HANA_NAMESPACE_END + +#endif // !BOOST_HANA_FWD_EQUAL_HPP |