Imported Upstream version 1.64.0
[platform/upstream/boost.git] / boost / hana / fwd / power.hpp
1 /*!
2 @file
3 Forward declares `boost::hana::power`.
4
5 @copyright Louis Dionne 2013-2017
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
8  */
9
10 #ifndef BOOST_HANA_FWD_POWER_HPP
11 #define BOOST_HANA_FWD_POWER_HPP
12
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
15
16
17 BOOST_HANA_NAMESPACE_BEGIN
18     //! Elevate a ring element to its `n`th power.
19     //! @ingroup group-Ring
20     //!
21     //! Specifically, `power(x, n)`, is equivalent to multiplying `x` with
22     //! itself `n` times using the Ring's multiplication. If the power is
23     //! equal to `zero`, the Ring's identity (`one`) is returned.
24     //!
25     //! @param x
26     //! A `Ring` element that is elevated to its `n`th power.
27     //!
28     //! @param n
29     //! A non-negative `IntegralConstant` representing the power to which `x`
30     //! is elevated.
31     //!
32     //!
33     //! @note
34     //! Only the tag of `x` is used for tag-dispatching.
35     //!
36     //! Example
37     //! -------
38     //! @include example/power.cpp
39 #ifdef BOOST_HANA_DOXYGEN_INVOKED
40     constexpr auto power = [](auto&& x, auto const& n) -> decltype(auto) {
41         return tag-dispatched;
42     };
43 #else
44     template <typename R, typename = void>
45     struct power_impl : power_impl<R, when<true>> { };
46
47     struct power_t {
48         template <typename X, typename N>
49         constexpr decltype(auto) operator()(X&& x, N const& n) const;
50     };
51
52     constexpr power_t power{};
53 #endif
54 BOOST_HANA_NAMESPACE_END
55
56 #endif // !BOOST_HANA_FWD_POWER_HPP