From cc96fb617b65ffa9db8dd3f242ee3b9319b4c4c4 Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Thu, 2 Jul 2020 10:48:37 -0700 Subject: Add BTs helper to support multiple backtraces --- Source/cmListFileCache.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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 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 +class BTs +{ +public: + BTs(T v = T(), cmListFileBacktrace bt = cmListFileBacktrace()) + : Value(std::move(v)) + { + Backtraces.emplace_back(std::move(bt)); + } + T Value; + std::vector Backtraces; + friend bool operator==(BTs const& l, BTs const& r) + { + return l.Value == r.Value; + } + friend bool operator<(BTs const& l, BTs const& r) + { + return l.Value < r.Value; + } + friend bool operator==(BTs const& l, T const& r) { return l.Value == r; } + friend bool operator==(T const& l, BTs const& r) { return l == r.Value; } +}; + std::vector> ExpandListWithBacktrace( std::string const& list, cmListFileBacktrace const& bt = cmListFileBacktrace()); -- cgit v0.12