power.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*!
  2. @file
  3. Forward declares `boost::hana::power`.
  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_POWER_HPP
  9. #define BOOST_HANA_FWD_POWER_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Elevate a ring element to its `n`th power.
  14. //! @ingroup group-Ring
  15. //!
  16. //! Specifically, `power(x, n)`, is equivalent to multiplying `x` with
  17. //! itself `n` times using the Ring's multiplication. If the power is
  18. //! equal to `zero`, the Ring's identity (`one`) is returned.
  19. //!
  20. //! @param x
  21. //! A `Ring` element that is elevated to its `n`th power.
  22. //!
  23. //! @param n
  24. //! A non-negative `IntegralConstant` representing the power to which `x`
  25. //! is elevated.
  26. //!
  27. //!
  28. //! @note
  29. //! Only the tag of `x` is used for tag-dispatching.
  30. //!
  31. //! Example
  32. //! -------
  33. //! @include example/power.cpp
  34. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  35. constexpr auto power = [](auto&& x, auto const& n) -> decltype(auto) {
  36. return tag-dispatched;
  37. };
  38. #else
  39. template <typename R, typename = void>
  40. struct power_impl : power_impl<R, when<true>> { };
  41. struct power_t {
  42. template <typename X, typename N>
  43. constexpr decltype(auto) operator()(X&& x, N const& n) const;
  44. };
  45. constexpr power_t power{};
  46. #endif
  47. BOOST_HANA_NAMESPACE_END
  48. #endif // !BOOST_HANA_FWD_POWER_HPP