summaryrefslogtreecommitdiffstats
path: root/lldb/include
diff options
context:
space:
mode:
authorTatyana Krasnukha <tatyana@synopsys.com>2018-08-09 11:42:28 +0000
committerTatyana Krasnukha <tatyana@synopsys.com>2018-08-09 11:42:28 +0000
commit14dc66539845d8662e2a694356ddd5ea82157f2a (patch)
tree9f4c507ae15952bf7b6540c2bec33561617181b3 /lldb/include
parentb89367ac467446e0ed9d8612662b6118832285e8 (diff)
downloadbcm5719-llvm-14dc66539845d8662e2a694356ddd5ea82157f2a.tar.gz
bcm5719-llvm-14dc66539845d8662e2a694356ddd5ea82157f2a.zip
Remove unused type Either from Utility library.
llvm-svn: 339328
Diffstat (limited to 'lldb/include')
-rw-r--r--lldb/include/lldb/Utility/Either.h162
1 files changed, 54 insertions, 108 deletions
diff --git a/lldb/include/lldb/Utility/Either.h b/lldb/include/lldb/Utility/Either.h
index 0dc340b64e8..ec683096859 100644
--- a/lldb/include/lldb/Utility/Either.h
+++ b/lldb/include/lldb/Utility/Either.h
@@ -12,115 +12,61 @@
#include "llvm/ADT/Optional.h"
-#include <functional>
-
namespace lldb_utility {
-template <typename T1, typename T2> class Either {
-private:
- enum class Selected { One, Two };
-
- Selected m_selected;
- union {
- T1 m_t1;
- T2 m_t2;
- };
-
-public:
- Either(const T1 &t1) {
- m_t1 = t1;
- m_selected = Selected::One;
- }
-
- Either(const T2 &t2) {
- m_t2 = t2;
- m_selected = Selected::Two;
- }
-
- Either(const Either<T1, T2> &rhs) {
- switch (rhs.m_selected) {
- case Selected::One:
- m_t1 = rhs.GetAs<T1>().getValue();
- m_selected = Selected::One;
- break;
- case Selected::Two:
- m_t2 = rhs.GetAs<T2>().getValue();
- m_selected = Selected::Two;
- break;
- }
- }
-
- template <class X, typename std::enable_if<std::is_same<T1, X>::value>::type
- * = nullptr>
- llvm::Optional<T1> GetAs() const {
- switch (m_selected) {
- case Selected::One:
- return m_t1;
- default:
- return llvm::Optional<T1>();
- }
- }
-
- template <class X, typename std::enable_if<std::is_same<T2, X>::value>::type
- * = nullptr>
- llvm::Optional<T2> GetAs() const {
- switch (m_selected) {
- case Selected::Two:
- return m_t2;
- default:
- return llvm::Optional<T2>();
- }
- }
-
- template <class ResultType>
- ResultType Apply(std::function<ResultType(T1)> if_T1,
- std::function<ResultType(T2)> if_T2) const {
- switch (m_selected) {
- case Selected::One:
- return if_T1(m_t1);
- case Selected::Two:
- return if_T2(m_t2);
- }
- }
-
- bool operator==(const Either<T1, T2> &rhs) {
- return (GetAs<T1>() == rhs.GetAs<T1>()) && (GetAs<T2>() == rhs.GetAs<T2>());
- }
-
- explicit operator bool() {
- switch (m_selected) {
- case Selected::One:
- return (bool)m_t1;
- case Selected::Two:
- return (bool)m_t2;
- }
- }
-
- Either<T1, T2> &operator=(const Either<T1, T2> &rhs) {
- switch (rhs.m_selected) {
- case Selected::One:
- m_t1 = rhs.GetAs<T1>().getValue();
- m_selected = Selected::One;
- break;
- case Selected::Two:
- m_t2 = rhs.GetAs<T2>().getValue();
- m_selected = Selected::Two;
- break;
- }
- return *this;
- }
-
- ~Either() {
- switch (m_selected) {
- case Selected::One:
- m_t1.T1::~T1();
- break;
- case Selected::Two:
- m_t2.T2::~T2();
- break;
- }
- }
-};
-
+ template <typename T1, typename T2>
+ class Either {
+ private:
+ enum class Selected {
+ One, Two
+ };
+
+ Selected m_selected;
+ union {
+ T1 m_t1;
+ T2 m_t2;
+ };
+
+ public:
+ Either(const T1& t1)
+ {
+ m_t1 = t1;
+ m_selected = Selected::One;
+ }
+
+ Either(const T2& t2)
+ {
+ m_t2 = t2;
+ m_selected = Selected::Two;
+ }
+
+ template <class X, typename std::enable_if<std::is_same<T1,X>::value>::type * = nullptr >
+ llvm::Optional<T1>
+ GetAs()
+ {
+ switch (m_selected)
+ {
+ case Selected::One:
+ return m_t1;
+ default:
+ return llvm::Optional<T1>();
+ }
+ }
+
+ template <class X, typename std::enable_if<std::is_same<T2,X>::value>::type * = nullptr >
+ llvm::Optional<T2>
+ GetAs()
+ {
+ switch (m_selected)
+ {
+ case Selected::Two:
+ return m_t2;
+ default:
+ return llvm::Optional<T2>();
+ }
+ }
+ };
+
} // namespace lldb_utility
#endif // #ifndef liblldb_Either_h_
+
OpenPOWER on IntegriCloud