Add utility function for loading certificates from a buffer
[folly.git] / folly / IPAddressException.h
index 8aa4a9b647ab130b53936bf68ce6426e8064cdba..37a163efd82f17d8739ea90865a8f2752135370f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 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.
@@ -18,9 +18,9 @@
 
 #include <exception>
 #include <string>
+#include <utility>
 
-#include "folly/Conv.h"
-#include "folly/detail/IPAddress.h"
+#include <folly/detail/IPAddress.h>
 
 namespace folly {
 
@@ -29,36 +29,37 @@ namespace folly {
  */
 class IPAddressFormatException : public std::exception {
  public:
-  explicit IPAddressFormatException(const std::string& msg)
-      : msg_(msg) {}
-  IPAddressFormatException(
-    const IPAddressFormatException& exception_) = default;
-  template<typename... Args>
-  explicit IPAddressFormatException(Args&&... args)
-      : msg_(to<std::string>(std::forward<Args>(args)...)) {}
+  explicit IPAddressFormatException(std::string msg) noexcept
+      : msg_(std::move(msg)) {}
+  IPAddressFormatException(const IPAddressFormatException&) = default;
+  IPAddressFormatException(IPAddressFormatException&&) = default;
+  IPAddressFormatException& operator=(const IPAddressFormatException&) =
+      default;
+  IPAddressFormatException& operator=(IPAddressFormatException&&) = default;
 
-  virtual ~IPAddressFormatException() noexcept {}
-  virtual const char *what(void) const noexcept {
+  ~IPAddressFormatException() noexcept override {}
+  const char* what() const noexcept override {
     return msg_.c_str();
   }
 
  private:
-  const std::string msg_;
+  std::string msg_;
 };
 
 class InvalidAddressFamilyException : public IPAddressFormatException {
  public:
-  explicit InvalidAddressFamilyException(const std::string& msg)
-      : IPAddressFormatException(msg) {}
-  InvalidAddressFamilyException(
-    const InvalidAddressFamilyException& ex) = default;
-  explicit InvalidAddressFamilyException(sa_family_t family)
-      : IPAddressFormatException("Address family " +
-                                 detail::familyNameStr(family) +
-                                 " is not AF_INET or AF_INET6") {}
-  template<typename... Args>
-  explicit InvalidAddressFamilyException(Args&&... args)
-      : IPAddressFormatException(std::forward<Args>(args)...) {}
+  explicit InvalidAddressFamilyException(std::string msg) noexcept
+      : IPAddressFormatException(std::move(msg)) {}
+  explicit InvalidAddressFamilyException(sa_family_t family) noexcept
+      : InvalidAddressFamilyException(
+            "Address family " + detail::familyNameStr(family) +
+            " is not AF_INET or AF_INET6") {}
+  InvalidAddressFamilyException(const InvalidAddressFamilyException&) = default;
+  InvalidAddressFamilyException(InvalidAddressFamilyException&&) = default;
+  InvalidAddressFamilyException& operator=(
+      const InvalidAddressFamilyException&) = default;
+  InvalidAddressFamilyException& operator=(InvalidAddressFamilyException&&) =
+      default;
 };
 
-}  // folly
+} // namespace folly