X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FIPAddressException.h;h=37a163efd82f17d8739ea90865a8f2752135370f;hb=b82902de6f5002cb46b4c0ae88f5cc7ae11b2585;hp=9ef8ca85c51050b95d412b2cc8ae20e30857012b;hpb=321542683a01c3f334047531e9b487f047129775;p=folly.git diff --git a/folly/IPAddressException.h b/folly/IPAddressException.h index 9ef8ca85..37a163ef 100644 --- a/folly/IPAddressException.h +++ b/folly/IPAddressException.h @@ -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. @@ -18,8 +18,8 @@ #include #include +#include -#include #include 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&) = default; - template - explicit IPAddressFormatException(Args&&... args) - : msg_(to(std::forward(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&) = default; - explicit InvalidAddressFamilyException(sa_family_t family) - : IPAddressFormatException("Address family " + - detail::familyNameStr(family) + - " is not AF_INET or AF_INET6") {} - template - explicit InvalidAddressFamilyException(Args&&... args) - : IPAddressFormatException(std::forward(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