nested_by.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*!
  2. @file
  3. Defines `boost::hana::detail::nested_by`.
  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_DETAIL_NESTED_BY_HPP
  9. #define BOOST_HANA_DETAIL_NESTED_BY_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/detail/nested_by_fwd.hpp>
  12. #include <boost/hana/functional/flip.hpp>
  13. #include <boost/hana/functional/partial.hpp>
  14. BOOST_HANA_NAMESPACE_BEGIN namespace detail {
  15. //! @cond
  16. template <typename Algorithm>
  17. template <typename Predicate, typename Object>
  18. constexpr decltype(auto) nested_by_t<Algorithm>::
  19. operator()(Predicate&& predicate, Object&& object) const {
  20. return Algorithm{}(static_cast<Object&&>(object),
  21. static_cast<Predicate&&>(predicate));
  22. }
  23. template <typename Algorithm>
  24. template <typename Predicate>
  25. constexpr decltype(auto)
  26. nested_by_t<Algorithm>::operator()(Predicate&& predicate) const {
  27. return hana::partial(hana::flip(Algorithm{}),
  28. static_cast<Predicate&&>(predicate));
  29. }
  30. //! @endcond
  31. } BOOST_HANA_NAMESPACE_END
  32. #endif // !BOOST_HANA_DETAIL_NESTED_BY_HPP