not_equal.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*!
  2. @file
  3. Forward declares `boost::hana::not_equal`.
  4. Copyright Louis Dionne 2013-2022
  5. Distributed under the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef BOOST_HANA_FWD_NOT_EQUAL_HPP
  9. #define BOOST_HANA_FWD_NOT_EQUAL_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. #include <boost/hana/detail/nested_to_fwd.hpp>
  13. namespace boost { namespace hana {
  14. //! Returns a `Logical` representing whether `x` is not equal to `y`.
  15. //! @ingroup group-Comparable
  16. //!
  17. //! The `not_equal` function can be called in two different ways. First,
  18. //! it can be called like a normal function:
  19. //! @code
  20. //! not_equal(x, y)
  21. //! @endcode
  22. //!
  23. //! However, it may also be partially applied to an argument by using
  24. //! `not_equal.to`:
  25. //! @code
  26. //! not_equal.to(x)(y) == not_equal(x, y)
  27. //! @endcode
  28. //!
  29. //! In other words, `not_equal.to(x)` is a function object that is
  30. //! equivalent to `partial(not_equal, x)`. This is provided to enhance
  31. //! the readability of some constructs, especially when using higher
  32. //! order algorithms.
  33. //!
  34. //!
  35. //! Signature
  36. //! ---------
  37. //! Given a Logical `Bool` and two Comparables `A` and `B` that
  38. //! share a common embedding, the signature is
  39. //! @f$ \mathtt{not\_equal} : A \times B \to Bool @f$.
  40. //!
  41. //! @param x, y
  42. //! Two objects to compare for inequality.
  43. //!
  44. //!
  45. //! Example
  46. //! -------
  47. //! @include example/not_equal.cpp
  48. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  49. constexpr auto not_equal = [](auto&& x, auto&& y) {
  50. return tag-dispatched;
  51. };
  52. #else
  53. template <typename T, typename U, typename = void>
  54. struct not_equal_impl : not_equal_impl<T, U, when<true>> { };
  55. struct not_equal_t : detail::nested_to<not_equal_t> {
  56. template <typename X, typename Y>
  57. constexpr auto operator()(X&& x, Y&& y) const;
  58. };
  59. BOOST_HANA_INLINE_VARIABLE constexpr not_equal_t not_equal{};
  60. #endif
  61. }} // end namespace boost::hana
  62. #endif // !BOOST_HANA_FWD_NOT_EQUAL_HPP