summaryrefslogtreecommitdiffstats
path: root/Source/cmListFileCache.h
diff options
context:
space:
mode:
authorJustin Goshi <jgoshi@microsoft.com>2020-07-02 17:48:37 (GMT)
committerJustin Goshi <jgoshi@microsoft.com>2020-07-06 18:31:09 (GMT)
commitcc96fb617b65ffa9db8dd3f242ee3b9319b4c4c4 (patch)
tree60919d83dda26a3552a5184838ca798e38cac66b /Source/cmListFileCache.h
parent26c12711598cd7b1eadaf8261773255599e10a29 (diff)
downloadCMake-cc96fb617b65ffa9db8dd3f242ee3b9319b4c4c4.zip
CMake-cc96fb617b65ffa9db8dd3f242ee3b9319b4c4c4.tar.gz
CMake-cc96fb617b65ffa9db8dd3f242ee3b9319b4c4c4.tar.bz2
Add BTs helper to support multiple backtraces
Diffstat (limited to 'Source/cmListFileCache.h')
-rw-r--r--Source/cmListFileCache.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 89902ff..0b4414d 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -175,6 +175,32 @@ public:
std::ostream& operator<<(std::ostream& os, BT<std::string> const& s);
+// Wrap type T as a value with potentially multiple backtraces. For purposes
+// of ordering and equality comparison, only the original value is used. The
+// backtrace is considered incidental.
+template <typename T>
+class BTs
+{
+public:
+ BTs(T v = T(), cmListFileBacktrace bt = cmListFileBacktrace())
+ : Value(std::move(v))
+ {
+ Backtraces.emplace_back(std::move(bt));
+ }
+ T Value;
+ std::vector<cmListFileBacktrace> Backtraces;
+ friend bool operator==(BTs<T> const& l, BTs<T> const& r)
+ {
+ return l.Value == r.Value;
+ }
+ friend bool operator<(BTs<T> const& l, BTs<T> const& r)
+ {
+ return l.Value < r.Value;
+ }
+ friend bool operator==(BTs<T> const& l, T const& r) { return l.Value == r; }
+ friend bool operator==(T const& l, BTs<T> const& r) { return l == r.Value; }
+};
+
std::vector<BT<std::string>> ExpandListWithBacktrace(
std::string const& list,
cmListFileBacktrace const& bt = cmListFileBacktrace());