lift.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*!
  2. @file
  3. Forward declares `boost::hana::lift`.
  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_LIFT_HPP
  9. #define BOOST_HANA_FWD_LIFT_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Lift a value into an `Applicative` structure.
  14. //! @ingroup group-Applicative
  15. //!
  16. //! `lift<A>` takes a normal value and embeds it into a structure whose
  17. //! shape is represented by the `A` `Applicative`. Note that the value
  18. //! may be a function, in which case the created structure may be
  19. //! `ap`plied to another `Applicative` structure containing values.
  20. //!
  21. //!
  22. //! Signature
  23. //! ---------
  24. //! Given an Applicative `A`, the signature is
  25. //! @f$ \mathtt{lift}_A : T \to A(T) @f$.
  26. //!
  27. //! @tparam A
  28. //! A tag representing the `Applicative` into which the value is lifted.
  29. //!
  30. //! @param x
  31. //! The value to lift into the applicative.
  32. //!
  33. //!
  34. //! Example
  35. //! -------
  36. //! @include example/lift.cpp
  37. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  38. template <typename A>
  39. constexpr auto lift = [](auto&& x) {
  40. return tag-dispatched;
  41. };
  42. #else
  43. template <typename A, typename = void>
  44. struct lift_impl : lift_impl<A, when<true>> { };
  45. template <typename A>
  46. struct lift_t {
  47. template <typename X>
  48. constexpr auto operator()(X&& x) const;
  49. };
  50. template <typename A>
  51. constexpr lift_t<A> lift{};
  52. #endif
  53. BOOST_HANA_NAMESPACE_END
  54. #endif // !BOOST_HANA_FWD_LIFT_HPP