]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/hana/product.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / hana / product.hpp
CommitLineData
7c673cae
FG
1/*!
2@file
3Defines `boost::hana::product`.
4
b32b8144 5@copyright Louis Dionne 2013-2017
7c673cae
FG
6Distributed 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_PRODUCT_HPP
11#define BOOST_HANA_PRODUCT_HPP
12
13#include <boost/hana/fwd/product.hpp>
14
15#include <boost/hana/concept/foldable.hpp>
16#include <boost/hana/concept/ring.hpp>
17#include <boost/hana/config.hpp>
18#include <boost/hana/core/dispatch.hpp>
19#include <boost/hana/fold_left.hpp>
20#include <boost/hana/integral_constant.hpp> // required by fwd decl
21#include <boost/hana/mult.hpp>
22#include <boost/hana/one.hpp>
23
24
25BOOST_HANA_NAMESPACE_BEGIN
92f5a8d4 26 //! @cond
7c673cae 27 template <typename R>
92f5a8d4
TL
28 template <typename Xs>
29 constexpr decltype(auto) product_t<R>::operator()(Xs&& xs) const {
30 using S = typename hana::tag_of<Xs>::type;
31 using Product = BOOST_HANA_DISPATCH_IF(product_impl<S>,
32 hana::Foldable<S>::value
33 );
34
7c673cae
FG
35 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
36 static_assert(hana::Ring<R>::value,
37 "hana::product<R> requires 'R' to be a Ring");
7c673cae 38
92f5a8d4
TL
39 static_assert(hana::Foldable<S>::value,
40 "hana::product<R>(xs) requires 'xs' to be Foldable");
41 #endif
7c673cae 42
92f5a8d4
TL
43 return Product::template apply<R>(static_cast<Xs&&>(xs));
44 }
45 //! @endcond
7c673cae
FG
46
47 template <typename T, bool condition>
48 struct product_impl<T, when<condition>> : default_ {
49 template <typename R, typename Xs>
50 static constexpr decltype(auto) apply(Xs&& xs) {
51 return hana::fold_left(static_cast<Xs&&>(xs), hana::one<R>(), hana::mult);
52 }
53 };
54BOOST_HANA_NAMESPACE_END
55
56#endif // !BOOST_HANA_PRODUCT_HPP