Skip to content

Commit b2acbd3

Browse files
acozzettecopybara-github
authored andcommitted
Use std::is_base_of_v instead of std::derived_from
Our use of `std::derived_from` reportedly fails with libc++ because we don't include the `<concepts>` header. This change should fix the problem by just using `std::is_base_of_v` instead, which has the advantage of not requiring C++20. Fixes #19364. PiperOrigin-RevId: 702351498
1 parent 873a695 commit b2acbd3

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/google/protobuf/port.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,9 @@ template <typename To, typename From>
178178
void AssertDownCast(From* from) {
179179
static_assert(std::is_base_of<From, To>::value, "illegal DownCast");
180180

181-
#if defined(__cpp_concepts)
182181
// Check that this function is not used to downcast message types.
183182
// For those we should use {Down,Dynamic}CastTo{Message,Generated}.
184-
static_assert(!requires {
185-
std::derived_from<std::remove_pointer_t<To>,
186-
typename std::remove_pointer_t<To>::MessageLite>;
187-
});
188-
#endif
183+
static_assert(!std::is_base_of_v<MessageLite, To>);
189184

190185
#if PROTOBUF_RTTI
191186
// RTTI: debug mode only!

0 commit comments

Comments
 (0)