|
|
|||
File indexing completed on 2025-12-15 09:53:04
0001 /*! 0002 @file 0003 Forward declares `boost::hana::product`. 0004 0005 Copyright Louis Dionne 2013-2022 0006 Distributed under the Boost Software License, Version 1.0. 0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 0008 */ 0009 0010 #ifndef BOOST_HANA_FWD_PRODUCT_HPP 0011 #define BOOST_HANA_FWD_PRODUCT_HPP 0012 0013 #include <boost/hana/config.hpp> 0014 #include <boost/hana/core/when.hpp> 0015 #include <boost/hana/fwd/integral_constant.hpp> 0016 0017 0018 namespace boost { namespace hana { 0019 //! Compute the product of the numbers of a structure. 0020 //! @ingroup group-Foldable 0021 //! 0022 //! More generally, `product` will take any foldable structure containing 0023 //! objects forming a Ring and reduce them using the Ring's binary 0024 //! operation. The initial state for folding is the identity of the 0025 //! Ring's operation. It is sometimes necessary to specify the Ring to 0026 //! use; this is possible by using `product<R>`. If no Ring is specified, 0027 //! the structure will use the Ring formed by the elements it contains 0028 //! (if it knows it), or `integral_constant_tag<int>` otherwise. 0029 //! Hence, 0030 //! @code 0031 //! product<R>(xs) = fold_left(xs, one<R or inferred Ring>(), mult) 0032 //! product<> = product<integral_constant_tag<int>> 0033 //! @endcode 0034 //! 0035 //! For numbers, this will just compute the product of the numbers in the 0036 //! `xs` structure. 0037 //! 0038 //! @note 0039 //! The elements of the structure are not actually required to be in the 0040 //! same Ring, but it must be possible to perform `mult` on any two 0041 //! adjacent elements of the structure, which requires each pair of 0042 //! adjacent element to at least have a common Ring embedding. The 0043 //! meaning of "adjacent" as used here is that two elements of the 0044 //! structure `x` and `y` are adjacent if and only if they are adjacent 0045 //! in the linearization of that structure, as documented by the Iterable 0046 //! concept. 0047 //! 0048 //! @note 0049 //! See the documentation for `sum` to understand why the Ring must 0050 //! sometimes be specified explicitly. 0051 //! 0052 //! 0053 //! Example 0054 //! ------- 0055 //! @include example/product.cpp 0056 #ifdef BOOST_HANA_DOXYGEN_INVOKED 0057 constexpr auto product = see documentation; 0058 #else 0059 template <typename T, typename = void> 0060 struct product_impl : product_impl<T, when<true>> { }; 0061 0062 template <typename R> 0063 struct product_t { 0064 template <typename Xs> 0065 constexpr decltype(auto) operator()(Xs&& xs) const; 0066 }; 0067 0068 template <typename R = integral_constant_tag<int>> 0069 BOOST_HANA_INLINE_VARIABLE constexpr product_t<R> product{}; 0070 #endif 0071 }} // end namespace boost::hana 0072 0073 #endif // !BOOST_HANA_FWD_PRODUCT_HPP
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|