and.hpp 1.4 KB

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