not.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*!
  2. @file
  3. Forward declares `boost::hana::not_`.
  4. @copyright Louis Dionne 2013-2017
  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_HPP
  9. #define BOOST_HANA_FWD_NOT_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Negates a `Logical`.
  14. //! @ingroup group-Logical
  15. //!
  16. //! This method returns a `Logical` with the same tag, but whose
  17. //! truth-value is negated. Specifically, `not_(x)` returns a false-valued
  18. //! `Logical` if `x` is a true-valued `Logical`, and a true-valued one
  19. //! otherwise.
  20. //!
  21. //!
  22. //! Example
  23. //! -------
  24. //! @include example/not.cpp
  25. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  26. constexpr auto not_ = [](auto&& x) -> decltype(auto) {
  27. return tag-dispatched;
  28. };
  29. #else
  30. template <typename L, typename = void>
  31. struct not_impl : not_impl<L, when<true>> { };
  32. struct not_t {
  33. template <typename X>
  34. constexpr decltype(auto) operator()(X&& x) const;
  35. };
  36. constexpr not_t not_{};
  37. #endif
  38. BOOST_HANA_NAMESPACE_END
  39. #endif // !BOOST_HANA_FWD_NOT_HPP