summaryrefslogtreecommitdiff
path: root/Source/cmListFileCache.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-09-24 10:54:18 -0400
committerBrad King <brad.king@kitware.com>2018-10-17 14:20:34 -0400
commitf1dd0eeaaf264ebb35b048f423c66296e6967d16 (patch)
tree3d483427df4dec4336ade1a2ed648a3c9d7565b4 /Source/cmListFileCache.h
parent4fc8e8b023c4ebce94a8baacbc086b72ec399aba (diff)
downloadcmake-f1dd0eeaaf264ebb35b048f423c66296e6967d16.tar.gz
cmListFileCache: Add wrapper template for values with a backtrace
Diffstat (limited to 'Source/cmListFileCache.h')
-rw-r--r--Source/cmListFileCache.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 3d3afdf9bb..9f16b1667f 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -9,6 +9,7 @@
#include <memory> // IWYU pragma: keep
#include <stddef.h>
#include <string>
+#include <utility>
#include <vector>
#include "cmStateSnapshot.h"
@@ -169,6 +170,34 @@ private:
cmListFileBacktrace(std::shared_ptr<Entry const> top);
};
+// Wrap type T as a value with a backtrace. For purposes of
+// ordering and equality comparison, only the original value is
+// used. The backtrace is considered incidental.
+template <typename T>
+class BT
+{
+public:
+ BT(T v = T(), cmListFileBacktrace bt = cmListFileBacktrace())
+ : Value(std::move(v))
+ , Backtrace(std::move(bt))
+ {
+ }
+ T Value;
+ cmListFileBacktrace Backtrace;
+ friend bool operator==(BT<T> const& l, BT<T> const& r)
+ {
+ return l.Value == r.Value;
+ }
+ friend bool operator<(BT<T> const& l, BT<T> const& r)
+ {
+ return l.Value < r.Value;
+ }
+ friend bool operator==(BT<T> const& l, T const& r) { return l.Value == r; }
+ friend bool operator==(T const& l, BT<T> const& r) { return l == r.Value; }
+};
+
+std::ostream& operator<<(std::ostream& os, BT<std::string> const& s);
+
struct cmListFile
{
bool ParseFile(const char* path, cmMessenger* messenger,