or.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*!
  2. @file
  3. Forward declares `boost::hana::or_`.
  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_OR_HPP
  9. #define BOOST_HANA_FWD_OR_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Return whether any of the arguments is true-valued.
  14. //! @ingroup group-Logical
  15. //!
  16. //! `or_` can be called with one argument or more. When called with
  17. //! two arguments, `or_` uses tag-dispatching to find the right
  18. //! implementation. Otherwise,
  19. //! @code
  20. //! or_(x) == x
  21. //! or_(x, y, ...z) == or_(or_(x, y), z...)
  22. //! @endcode
  23. //!
  24. //!
  25. //! Example
  26. //! -------
  27. //! @include example/or.cpp
  28. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  29. constexpr auto or_ = [](auto&& x, auto&& ...y) -> decltype(auto) {
  30. return tag-dispatched;
  31. };
  32. #else
  33. template <typename L, typename = void>
  34. struct or_impl : or_impl<L, when<true>> { };
  35. struct or_t {
  36. template <typename X, typename Y>
  37. constexpr decltype(auto) operator()(X&& x, Y&& y) const;
  38. template <typename X, typename ...Y>
  39. constexpr decltype(auto) operator()(X&& x, Y&& ...y) const;
  40. };
  41. constexpr or_t or_{};
  42. #endif
  43. BOOST_HANA_NAMESPACE_END
  44. #endif // !BOOST_HANA_FWD_OR_HPP