about summary refs log tree commit diff
path: root/absl/types/compare.h
diff options
context:
space:
mode:
Diffstat (limited to 'absl/types/compare.h')
-rw-r--r--absl/types/compare.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/absl/types/compare.h b/absl/types/compare.h
index 7fed30814050..50361d623025 100644
--- a/absl/types/compare.h
+++ b/absl/types/compare.h
@@ -452,8 +452,10 @@ namespace compare_internal {
 
 // Helper functions to do a boolean comparison of two keys given a boolean
 // or three-way comparator.
-constexpr bool compare_result_as_less_than(const bool r) { return r; }
-constexpr bool compare_result_as_less_than(const int r) { return r < 0; }
+// SFINAE prevents implicit conversions to bool (such as from int).
+template <typename Bool,
+          absl::enable_if_t<std::is_same<bool, Bool>::value, int> = 0>
+constexpr bool compare_result_as_less_than(const Bool r) { return r; }
 constexpr bool compare_result_as_less_than(const absl::weak_ordering r) {
   return r < 0;
 }