summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/safe_numerics/test/test_equal_constexpr.hpp
blob: 61887662456d74f5e59ee1a8700191335924abf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef BOOST_TEST_EQUAL_CONSTEXPR_HPP
#define BOOST_TEST_EQUAL_CONSTEXPR_HPP

//  Copyright (c) 2015 Robert Ramey
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <boost/config.hpp> // BOOST_CLANG
#include <boost/safe_numerics/safe_integer.hpp>

#if BOOST_CLANG == 1
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-comparison"
#endif

template<class T1, class T2>
constexpr bool test_equal_constexpr(
    T1 v1,
    T2 v2,
    char expected_result
){
    using namespace boost::safe_numerics;
    // if we don't expect the operation to pass, we can't
    // check the constexpr version of the calculation so
    // just return success.
    if(expected_result == 'x')
        return true;
    safe_t<T1>(v1) == v2;
    v1 == safe_t<T2>(v2);
    safe_t<T1>(v1) == safe_t<T2>(v2);
    return true; // correct result
}

#if BOOST_CLANG == 1
#pragma GCC diagnostic pop
#endif

#endif // BOOST_TEST_EQUAL_CONSTEXPR_HPP