1// Copyright (c) 2021 Robert Ramey
2//
3// Distributed under the Boost Software License, Version 1.0. (See
4// accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6
7// test Numeric concept - compile only test
8
9#include <boost/safe_numerics/utility.hpp>
10#include <boost/safe_numerics/concept/numeric.hpp>
11#include "test_checked_values.hpp"
12
13// test that all intrinsic signed integers are detected as Numeric
14using namespace boost::mp11;
15static_assert(
16 mp_all_of<
17 signed_test_types,
18 boost::safe_numerics::Numeric
19 >(),
20 "Numeric concept fails on at least one signed integer type"
21);
22// test that all intrinsic unigned integers are detected as Numeric
23static_assert(
24 mp_all_of<
25 unsigned_test_types,
26 boost::safe_numerics::Numeric
27 >(),
28 "Numeric concept fails on at least one unsigned integer type"
29);
30
31// test types without a std::numeric_limits entry are NOT detected as Numeric
32struct X {};
33
34static_assert(
35 ! boost::safe_numerics::Numeric<X>(),
36 "Type w/o std::numeric_limits entry erroneously detected as Numeric"
37);
38
39#include <iostream>
40#include <boost/safe_numerics/safe_integer.hpp>
41
42int main(){
43 boost::safe_numerics::safe<int> s;
44 std::cout << s;
45 return 0;
46}
47

source code of boost/libs/safe_numerics/test/test_concept_numeric.cpp