|
|
|||
File indexing completed on 2025-12-15 09:53:04
0001 /*! 0002 @file 0003 Forward declares `boost::hana::mod`. 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_MOD_HPP 0011 #define BOOST_HANA_FWD_MOD_HPP 0012 0013 #include <boost/hana/config.hpp> 0014 #include <boost/hana/core/when.hpp> 0015 0016 0017 namespace boost { namespace hana { 0018 //! Generalized integer modulus. 0019 //! @ingroup group-EuclideanRing 0020 //! 0021 //! Given two elements of an EuclideanRing `x` and `y`, with `y` 0022 //! nonzero, `mod` returns the modulus of the division of `x` by `y`. 0023 //! In other words, `mod` can be seen as an equivalent to `%`. 0024 //! 0025 //! Cross-type version of the method 0026 //! -------------------------------- 0027 //! The `mod` method is "overloaded" to handle distinct data types 0028 //! with certain properties. Specifically, `mod` is defined for 0029 //! _distinct_ data types `A` and `B` such that 0030 //! 1. `A` and `B` share a common data type `C`, as determined by the 0031 //! `common` metafunction 0032 //! 2. `A`, `B` and `C` are all `EuclideanRing`s when taken individually 0033 //! 3. `to<C> : A -> B` and `to<C> : B -> C` are `Ring`-embeddings, as 0034 //! determined by the `is_embedding` metafunction. 0035 //! 0036 //! In that case, `mod` is defined as 0037 //! @code 0038 //! mod(x, y) = mod(to<C>(x), to<C>(y)) 0039 //! @endcode 0040 //! 0041 //! 0042 //! Example 0043 //! ------- 0044 //! @include example/mod.cpp 0045 #ifdef BOOST_HANA_DOXYGEN_INVOKED 0046 constexpr auto mod = [](auto&& x, auto&& y) -> decltype(auto) { 0047 return tag-dispatched; 0048 }; 0049 #else 0050 template <typename T, typename U, typename = void> 0051 struct mod_impl : mod_impl<T, U, when<true>> { }; 0052 0053 struct mod_t { 0054 template <typename X, typename Y> 0055 constexpr decltype(auto) operator()(X&& x, Y&& y) const; 0056 }; 0057 0058 BOOST_HANA_INLINE_VARIABLE constexpr mod_t mod{}; 0059 #endif 0060 }} // end namespace boost::hana 0061 0062 #endif // !BOOST_HANA_FWD_MOD_HPP
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|