#include <folly/portability/Windows.h>
// Ignore -Wformat-nonliteral warnings within this file
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+FOLLY_PUSH_WARNING
+FOLLY_GCC_DISABLE_WARNING("-Wformat-nonliteral")
namespace folly {
BaseFormatter<Derived, containerMode, Args...>::BaseFormatter(
StringPiece str,
Args&&... args)
- : str_(str),
- values_(FormatValue<typename std::decay<Args>::type>(
- std::forward<Args>(args))...) {
- static_assert(
- !containerMode || sizeof...(Args) == 1,
- "Exactly one argument required in container mode");
-}
+ : str_(str), values_(std::forward<Args>(args)...) {}
template <class Derived, bool containerMode, class... Args>
template <class Output>
arg.widthIndex == FormatArg::kNoIndex,
"cannot provide width arg index without value arg index");
int sizeArg = nextArg++;
- arg.width = getSizeArg(size_t(sizeArg), arg);
+ arg.width = asDerived().getSizeArg(size_t(sizeArg), arg);
}
argIndex = nextArg++;
arg.enforce(
arg.widthIndex != FormatArg::kNoIndex,
"cannot provide value arg index without width arg index");
- arg.width = getSizeArg(size_t(arg.widthIndex), arg);
+ arg.width = asDerived().getSizeArg(size_t(arg.widthIndex), arg);
}
try {
"folly::format: may not have both default and explicit arg indexes");
}
- doFormat(size_t(argIndex), arg, out);
+ asDerived().doFormat(size_t(argIndex), arg, out);
}
}
throw BadFormatArg("folly::format: invalid precision");
}
- // XXX: clang should be smart enough to not need the two static_cast<size_t>
- // uses below given the above checks. If clang ever becomes that smart, we
- // should remove the otherwise unnecessary warts.
-
if (arg.precision != FormatArg::kDefaultPrecision &&
val.size() > static_cast<size_t>(arg.precision)) {
- val.reset(val.data(), size_t(arg.precision));
+ val.reset(val.data(), static_cast<size_t>(arg.precision));
}
constexpr int padBufSize = 128;
float val_;
};
-// Sring-y types (implicitly convertible to StringPiece, except char*)
+// String-y types (implicitly convertible to StringPiece, except char*)
template <class T>
class FormatValue<
T,
} // namespace folly
-#pragma GCC diagnostic pop
+FOLLY_POP_WARNING