test_subtract_native_constexpr.cpp 1.3 KB

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