3 Forward declares `boost::hana::mod`.
5 @copyright Louis Dionne 2013-2016
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)
10 #ifndef BOOST_HANA_FWD_MOD_HPP
11 #define BOOST_HANA_FWD_MOD_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Generalized integer modulus.
19 //! @ingroup group-EuclideanRing
21 //! Given two elements of an EuclideanRing `x` and `y`, with `y`
22 //! nonzero, `mod` returns the modulus of the division of `x` by `y`.
23 //! In other words, `mod` can be seen as an equivalent to `%`.
25 //! Cross-type version of the method
26 //! --------------------------------
27 //! The `mod` method is "overloaded" to handle distinct data types
28 //! with certain properties. Specifically, `mod` is defined for
29 //! _distinct_ data types `A` and `B` such that
30 //! 1. `A` and `B` share a common data type `C`, as determined by the
31 //! `common` metafunction
32 //! 2. `A`, `B` and `C` are all `EuclideanRing`s when taken individually
33 //! 3. `to<C> : A -> B` and `to<C> : B -> C` are `Ring`-embeddings, as
34 //! determined by the `is_embedding` metafunction.
36 //! In that case, `mod` is defined as
38 //! mod(x, y) = mod(to<C>(x), to<C>(y))
44 //! @include example/mod.cpp
45 #ifdef BOOST_HANA_DOXYGEN_INVOKED
46 constexpr auto mod = [](auto&& x, auto&& y) -> decltype(auto) {
47 return tag-dispatched;
50 template <typename T, typename U, typename = void>
51 struct mod_impl : mod_impl<T, U, when<true>> { };
54 template <typename X, typename Y>
55 constexpr decltype(auto) operator()(X&& x, Y&& y) const;
58 constexpr mod_t mod{};
60 BOOST_HANA_NAMESPACE_END
62 #endif // !BOOST_HANA_FWD_MOD_HPP