X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2FFormatArg.h;h=62c9705c4eedbcbb98402eabd3638c5c186d85dc;hp=5257285c00a23332cdeb5f00f1281a3c2bf96fed;hb=20808864dfde991fd740e6caefe632d4bf244d69;hpb=ed8c80a0e0988e4ce687f51ca832a00e4a6b7930 diff --git a/folly/FormatArg.h b/folly/FormatArg.h index 5257285c..62c9705c 100644 --- a/folly/FormatArg.h +++ b/folly/FormatArg.h @@ -1,5 +1,5 @@ /* - * Copyright 2017 Facebook, Inc. + * Copyright 2012-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,8 @@ #pragma once #include + +#include #include #include #include @@ -24,12 +26,13 @@ namespace folly { -class BadFormatArg : public std::invalid_argument { - public: - explicit BadFormatArg(const std::string& msg) - : std::invalid_argument(msg) {} +class FOLLY_EXPORT BadFormatArg : public std::invalid_argument { + using invalid_argument::invalid_argument; }; +[[noreturn]] void throwBadFormatArg(char const* msg); +[[noreturn]] void throwBadFormatArg(std::string const& msg); + /** * Parsed format argument. */ @@ -212,7 +215,7 @@ inline std::string FormatArg::errorStr(Args&&... args) const { template [[noreturn]] inline void FormatArg::error(Args&&... args) const { - throw BadFormatArg(errorStr(std::forward(args)...)); + throwBadFormatArg(errorStr(std::forward(args)...)); } template @@ -244,7 +247,7 @@ inline StringPiece FormatArg::doSplitKey() { if (e[-1] == ']') { --e; p = static_cast(memchr(b, '[', size_t(e - b))); - enforce(p, "unmatched ']'"); + enforce(p != nullptr, "unmatched ']'"); } else { p = static_cast(memchr(b, '.', size_t(e - b))); } @@ -273,4 +276,4 @@ inline int FormatArg::splitIntKey() { } } -} // namespace folly +} // namespace folly