test_or_native_constexpr.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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/native.hpp>
  8. template <class T>
  9. using safe_t = boost::safe_numerics::safe<
  10. T,
  11. boost::safe_numerics::native
  12. >;
  13. #include "test_or_constexpr.hpp"
  14. #include "test_values.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_or_constexpr(
  21. mp_at_c<test_values, i>()(),
  22. mp_at_c<test_values, j>()(),
  23. '.'
  24. );
  25. };
  26. #include <boost/mp11/list.hpp>
  27. #include <boost/mp11/algorithm.hpp>
  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 or'ed"
  41. );
  42. return 0;
  43. }