mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 14:21:09 +01:00
Prevent ostream << for pointers to printable types. (#837)
Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
committed by
GitHub
co-authored by
Geoff Romer
parent
15434320e6
commit
7beaabc934
@@ -18,6 +18,14 @@ auto operator<<(llvm::raw_ostream& out, const T& obj) -> llvm::raw_ostream& {
|
||||
return out;
|
||||
}
|
||||
|
||||
// Prevents ostream << for pointers to printable types.
|
||||
template <typename T, typename std::enable_if<std::is_member_function_pointer<
|
||||
decltype(&T::Print)>::value>::type* = nullptr>
|
||||
__attribute__((unavailable(
|
||||
"Received a pointer to a printable type, are you missing a `*`? "
|
||||
"To print as a pointer, cast to void*."))) auto
|
||||
operator<<(llvm::raw_ostream& out, const T* /*obj*/) -> llvm::raw_ostream&;
|
||||
|
||||
} // namespace Carbon
|
||||
|
||||
#endif // COMMON_OSTREAM_H_
|
||||
|
||||
Reference in New Issue
Block a user