[PATCH] D139290: [ADT, Support] Move operator<< to raw_ostream.h (NFC)
Kazu Hirata via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 6 09:10:31 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG227078b7136c: [ADT, Support] Move operator<< to raw_ostream.h (NFC) (authored by kazu).
Changed prior to commit:
https://reviews.llvm.org/D139290?vs=479981&id=480515#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139290/new/
https://reviews.llvm.org/D139290
Files:
llvm/include/llvm/ADT/Optional.h
llvm/include/llvm/Support/raw_ostream.h
Index: llvm/include/llvm/Support/raw_ostream.h
===================================================================
--- llvm/include/llvm/Support/raw_ostream.h
+++ llvm/include/llvm/Support/raw_ostream.h
@@ -13,6 +13,7 @@
#ifndef LLVM_SUPPORT_RAW_OSTREAM_H
#define LLVM_SUPPORT_RAW_OSTREAM_H
+#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/DataTypes.h"
@@ -740,6 +741,28 @@
Error writeToOutput(StringRef OutputFileName,
std::function<Error(raw_ostream &)> Write);
+raw_ostream &operator<<(raw_ostream &OS, std::nullopt_t);
+
+template <typename T, typename = decltype(std::declval<raw_ostream &>()
+ << std::declval<const T &>())>
+raw_ostream &operator<<(raw_ostream &OS, const Optional<T> &O) {
+ if (O)
+ OS << *O;
+ else
+ OS << std::nullopt;
+ return OS;
+}
+
+template <typename T, typename = decltype(std::declval<raw_ostream &>()
+ << std::declval<const T &>())>
+raw_ostream &operator<<(raw_ostream &OS, const std::optional<T> &O) {
+ if (O)
+ OS << *O;
+ else
+ OS << std::nullopt;
+ return OS;
+}
+
} // end namespace llvm
#endif // LLVM_SUPPORT_RAW_OSTREAM_H
Index: llvm/include/llvm/ADT/Optional.h
===================================================================
--- llvm/include/llvm/ADT/Optional.h
+++ llvm/include/llvm/ADT/Optional.h
@@ -23,13 +23,10 @@
#include "llvm/Support/type_traits.h"
#include <cassert>
#include <new>
-#include <optional>
#include <utility>
namespace llvm {
-class raw_ostream;
-
namespace optional_detail {
/// Storage for any type.
@@ -479,28 +476,6 @@
return !(X < Y);
}
-raw_ostream &operator<<(raw_ostream &OS, std::nullopt_t);
-
-template <typename T, typename = decltype(std::declval<raw_ostream &>()
- << std::declval<const T &>())>
-raw_ostream &operator<<(raw_ostream &OS, const Optional<T> &O) {
- if (O)
- OS << *O;
- else
- OS << std::nullopt;
- return OS;
-}
-
-template <typename T, typename = decltype(std::declval<raw_ostream &>()
- << std::declval<const T &>())>
-raw_ostream &operator<<(raw_ostream &OS, const std::optional<T> &O) {
- if (O)
- OS << *O;
- else
- OS << std::nullopt;
- return OS;
-}
-
} // end namespace llvm
#endif // LLVM_ADT_OPTIONAL_H
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139290.480515.patch
Type: text/x-patch
Size: 2448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221206/c11ca37a/attachment.bin>
More information about the llvm-commits
mailing list