]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/safe_numerics/test/test_modulus_constexpr.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / safe_numerics / test / test_modulus_constexpr.hpp
1 #ifndef BOOST_TEST_ADD_CONSTEXPR_HPP
2 #define BOOST_TEST_ADD_CONSTEXPR_HPP
3
4 // Copyright (c) 2015 Robert Ramey
5 //
6 // Distributed under the Boost Software License, Version 1.0. (See
7 // accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9
10 #include <boost/safe_numerics/safe_integer.hpp>
11
12 template<class T1, class T2>
13 constexpr bool test_modulus_constexpr(
14 T1 v1,
15 T2 v2,
16 char expected_result
17 ){
18 using namespace boost::safe_numerics;
19 // if we don't expect the operation to pass, we can't
20 // check the constexpr version of the calculation so
21 // just return success.
22 if(expected_result == 'x')
23 return true;
24 safe_t<T1>(v1) % v2;
25 v1 % safe_t<T2>(v2);
26 safe_t<T1>(v1) % safe_t<T2>(v2);
27 return true; // correct result
28 }
29
30 #endif // BOOST_TEST_ADD_CONSTEXPR_HPP