#include <double-conversion/double-conversion.h>
-#include "folly/FBVector.h"
-#include "folly/Conv.h"
-#include "folly/Range.h"
-#include "folly/Traits.h"
-#include "folly/Likely.h"
-#include "folly/String.h"
-#include "folly/small_vector.h"
-#include "folly/FormatArg.h"
+#include <folly/FBVector.h>
+#include <folly/Conv.h>
+#include <folly/Range.h>
+#include <folly/Traits.h>
+#include <folly/Likely.h>
+#include <folly/String.h>
+#include <folly/small_vector.h>
+#include <folly/FormatArg.h>
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
#pragma GCC diagnostic push
fmt, std::forward<Args>(args)...);
}
+/**
+ * Like format(), but immediately returns the formatted string instead of an
+ * intermediate format object.
+ */
+template <class... Args>
+inline std::string sformat(StringPiece fmt, Args&&... args) {
+ return format(fmt, std::forward<Args>(args)...).str();
+}
+
/**
* Create a formatter object from a dynamic format string.
*
return f;
}
+/**
+ * Like formatChecked(), but immediately returns the formatted string instead of
+ * an intermediate format object.
+ */
+template <class... Args>
+inline std::string sformatChecked(StringPiece fmt, Args&&... args) {
+ return formatChecked(fmt, std::forward<Args>(args)...).str();
+}
+
/**
* Create a formatter object that takes one argument (of container type)
* and uses that container to get argument values from.
fmt, std::forward<Container>(container));
}
+/**
+ * Like vformat(), but immediately returns the formatted string instead of an
+ * intermediate format object.
+ */
+template <class Container>
+inline std::string svformat(StringPiece fmt, Container&& container) {
+ return vformat(fmt, std::forward<Container>(container)).str();
+}
+
/**
* Create a formatter object from a dynamic format string.
*
return f;
}
+/**
+ * Like vformatChecked(), but immediately returns the formatted string instead
+ * of an intermediate format object.
+ */
+template <class Container>
+inline std::string svformatChecked(StringPiece fmt, Container&& container) {
+ return vformatChecked(fmt, std::forward<Container>(container)).str();
+}
+
/**
* Wrap a sequence or associative container so that out-of-range lookups
* return a default value rather than throwing an exception.
} // namespace folly
-#include "folly/Format-inl.h"
+#include <folly/Format-inl.h>
#pragma GCC diagnostic pop