Protocol Buffers - Google's data interchange format (grpc依赖)
https://developers.google.com/protocol-buffers/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
503 B
18 lines
503 B
5 months ago
|
#ifndef PROTOBUF_HPB_REQUIRES_H_
|
||
|
#define PROTOBUF_HPB_REQUIRES_H_
|
||
|
|
||
|
#include <type_traits>
|
||
|
namespace protos::internal {
|
||
|
// Ports C++20 `requires` to C++17.
|
||
|
// C++20 ideal:
|
||
|
// if constexpr (requires { t.foo(); }) { ... }
|
||
|
// Our C++17 stopgap solution:
|
||
|
// if constexpr (Requires<T>([](auto x) -> decltype(x.foo()) {})) { ... }
|
||
|
template <typename... T, typename F>
|
||
|
constexpr bool Requires(F) {
|
||
|
return std::is_invocable_v<F, T...>;
|
||
|
}
|
||
|
} // namespace protos::internal
|
||
|
|
||
|
#endif // PROTOBUF_HPB_REQUIRES_H_
|