test_add_automatic_constexpr.cpp 1.4 KB

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