If cute::gcd returns auto instead of common_type_t , then GCC 7.5 reports the following error; ... /include/cute/numeric/math.hpp:103:26: error: inconsistent deduction for auto return type: ‘int’ and then ‘bool’ if (u == 0) { return t; } ^ Note that common_type_t , C<1>>::value_type might still be bool.
| 47 | // ^ |
| 48 | // Note that common_type_t<C<42>, C<1>>::value_type might still be bool. |
| 49 | TEST(CuTe_core, gcd_returns_common_type) |
| 50 | { |
| 51 | using cute::C; |
| 52 | |
| 53 | constexpr auto fifteen = C<3 * 5>{}; |
| 54 | static_assert(cute::is_same_v<decltype(fifteen)::value_type, int>); |
| 55 | static_assert(int(fifteen) == 15); |
| 56 | |
| 57 | constexpr auto forty_two = C<2 * 3 * 7>{}; |
| 58 | static_assert(cute::is_same_v<decltype(forty_two)::value_type, int>); |
| 59 | static_assert(int(forty_two) == 42); |
| 60 | |
| 61 | // C<1>::value_type (as well as C<0>::value_type) may be bool. |
| 62 | constexpr auto one = C<1>{}; |
| 63 | |
| 64 | // Both inputs have value_type int. |
| 65 | { |
| 66 | constexpr auto result = cute::gcd(fifteen, forty_two); |
| 67 | static_assert(cute::is_same_v<decltype(result)::value_type, int>); |
| 68 | static_assert(int(result) == 3); |
| 69 | } |
| 70 | |
| 71 | // One input has value_type int, and the other may have value_type bool. |
| 72 | { |
| 73 | constexpr auto result = cute::gcd(one, forty_two); |
| 74 | static_assert(int(result) == 1); |
| 75 | } |
| 76 | { |
| 77 | constexpr auto result = cute::gcd(forty_two, one); |
| 78 | static_assert(int(result) == 1); |
| 79 | } |
| 80 | |
| 81 | // Both inputs may have value_type bool. |
| 82 | { |
| 83 | constexpr auto result = cute::gcd(one, one); |
| 84 | static_assert(int(result) == 1); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | TEST(CuTe_core, lcm_returns_common_type) |
| 89 | { |
nothing calls this directly
no test coverage detected