Fix the last issues with exception_wrapper under MSVC
[folly.git] / folly / Try.h
index e6b6ebad3298450c5f4fa6f001fd751fd79c849b..230c658cac1bd6acc38a75fef78d01006b981a6b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 #pragma once
 
-#include <type_traits>
-#include <exception>
-#include <algorithm>
 #include <folly/ExceptionWrapper.h>
 #include <folly/Likely.h>
 #include <folly/Memory.h>
 #include <folly/Portability.h>
 #include <folly/Unit.h>
+#include <exception>
+#include <stdexcept>
+#include <type_traits>
+#include <utility>
 
 namespace folly {
 
-class TryException : public std::exception {
+class TryException : public std::logic_error {
  public:
-  explicit TryException(std::string message_arg) noexcept
-      : message(std::move(message_arg)) {}
-
-  const char* what() const noexcept override {
-    return message.c_str();
-  }
-
-  bool operator==(const TryException& other) const noexcept {
-    return other.message == this->message;
-  }
-
-  bool operator!=(const TryException& other) const noexcept {
-    return !(*this == other);
-  }
-
- protected:
-  std::string message;
+  using std::logic_error::logic_error;
 };
 
 class UsingUninitializedTry : public TryException {
  public:
-  UsingUninitializedTry() noexcept : TryException("Using unitialized try") {}
+  UsingUninitializedTry() : TryException("Using uninitialized try") {}
 };
 
 /*