min.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*!
  2. @file
  3. Forward declares `boost::hana::min`.
  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_MIN_HPP
  9. #define BOOST_HANA_FWD_MIN_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Returns the smallest of its arguments according to the `less` ordering.
  14. //! @ingroup group-Orderable
  15. //!
  16. //!
  17. //! @todo
  18. //! We can't specify the signature right now, because the tag of the
  19. //! returned object depends on whether `x < y` or not. If we wanted to be
  20. //! mathematically correct, we should probably ask that `if_(cond, x, y)`
  21. //! returns a common data type of `x` and `y`, and then the behavior
  22. //! of `min` would follow naturally. However, I'm unsure whether this
  23. //! is desirable because that's a big requirement.
  24. //!
  25. //!
  26. //! Example
  27. //! -------
  28. //! @include example/min.cpp
  29. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  30. constexpr auto min = [](auto&& x, auto&& y) -> decltype(auto) {
  31. return tag-dispatched;
  32. };
  33. #else
  34. template <typename T, typename U, typename = void>
  35. struct min_impl : min_impl<T, U, when<true>> { };
  36. struct min_t {
  37. template <typename X, typename Y>
  38. constexpr decltype(auto) operator()(X&& x, Y&& y) const;
  39. };
  40. constexpr min_t min{};
  41. #endif
  42. BOOST_HANA_NAMESPACE_END
  43. #endif // !BOOST_HANA_FWD_MIN_HPP