Skip to content

Commit

Permalink
Replace absl::IsConvertibleHelper with std::is_convertible
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 495898835
Change-Id: Id2150a0505020ac2be4487e904d167a26316260c
  • Loading branch information
Abseil Team authored and copybara-github committed Dec 16, 2022
1 parent d5240fc commit 71927b4
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions absl/types/internal/span.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,9 @@ bool LessThanImpl(SpanT<T> a, SpanT<T> b) {
return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end());
}

// The `IsConvertible` classes here are needed because of the
// `std::is_convertible` bug in libcxx when compiled with GCC. This build
// configuration is used by Android NDK toolchain. Reference link:
// https://bugs.llvm.org/show_bug.cgi?id=27538.
template <typename From, typename To>
struct IsConvertibleHelper {
private:
static std::true_type testval(To);
static std::false_type testval(...);

public:
using type = decltype(testval(std::declval<From>()));
};

template <typename From, typename To>
struct IsConvertible : IsConvertibleHelper<From, To>::type {};

// TODO(zhangxy): replace `IsConvertible` with `std::is_convertible` once the
// older version of libcxx is not supported.
template <typename From, typename To>
using EnableIfConvertibleTo =
typename std::enable_if<IsConvertible<From, To>::value>::type;
typename std::enable_if<std::is_convertible<From, To>::value>::type;

// IsView is true for types where the return type of .data() is the same for
// mutable and const instances. This isn't foolproof, but it's only used to
Expand Down

0 comments on commit 71927b4

Please sign in to comment.