test_and_native_constexpr.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright (c) 2019 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. #include <iostream
  7. #include <boost/safe_numerics/safe_integer.hpp>
  8. #include <boost/safe_numerics/native.hpp>
  9. #include "test_add_native_results.hpp"
  10. template <class T>
  11. using safe_t = boost::safe_numerics::safe<
  12. T,
  13. boost::safe_numerics::native
  14. >;
  15. #include "test_add_constexpr.hpp"
  16. using namespace boost::mp11;
  17. template<typename First, typename Second>
  18. struct test_pair {
  19. static const std::size_t i = First();
  20. static const std::size_t j = Second();
  21. constexpr static const bool value = test_add_constexpr(
  22. typename boost::mp11::mp_at_c<test_values, i>()(),
  23. typename boost::mp11::mp_at_c<test_values, j>()(),
  24. test_addition_native_result[i][j]
  25. );
  26. };
  27. #include <boost/mp11/list.hpp>
  28. #include <boost/mp11/algorithm.hpp>
  29. #include "check_symmetry.hpp"
  30. int main(){
  31. using namespace boost::mp11;
  32. // sanity check on test matrix - should be symetrical
  33. check_symmetry(test_addition_native_result);
  34. using value_indices = mp_iota_c<mp_size<test_values>::value>;
  35. static_assert(
  36. mp_all_of<
  37. mp_product<
  38. test_pair,
  39. value_indices,
  40. value_indices
  41. >,
  42. mp_to_bool
  43. >(),
  44. "all values for all integer types correctly added"
  45. );
  46. return 0;
  47. }