blob: d085d3fafcd68f7873ce94a54c4c1dfbd327e7f1 [file] [log] [blame]
#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_