add additional formatChecked() and vformatChecked() wrappers
authorAdam Simpkins <simpkins@fb.com>
Thu, 30 Jan 2014 21:25:08 +0000 (13:25 -0800)
committerSara Golemon <sgolemon@fb.com>
Thu, 6 Feb 2014 19:50:14 +0000 (11:50 -0800)
Summary:
Add wrapper functions for directly appending to a string, similar to the
existing format() and vformat() wrappers.

Test Plan:
Converted some existing code using these format() and vformat() wrappers
to use formatChecked() and vformatChecked().

Reviewed By: jon.coens@fb.com

FB internal diff: D1151496

@override-unit-failures

folly/Format.h

index a270b43b36e0a6c6f961afc4984336c84de62659..11e2462a01f0e0fe81b47d8b504c5f19f6565f1c 100644 (file)
@@ -271,6 +271,12 @@ format(Str* out, StringPiece fmt, Args&&... args) {
   format(fmt, std::forward<Args>(args)...).appendTo(*out);
 }
 
+template <class Str, class... Args>
+typename std::enable_if<IsSomeString<Str>::value>::type
+formatChecked(Str* out, StringPiece fmt, Args&&... args) {
+  formatChecked(fmt, std::forward<Args>(args)...).appendTo(*out);
+}
+
 /**
  * Append vformatted output to a string.
  */
@@ -280,6 +286,12 @@ vformat(Str* out, StringPiece fmt, Container&& container) {
   vformat(fmt, std::forward<Container>(container)).appendTo(*out);
 }
 
+template <class Str, class Container>
+typename std::enable_if<IsSomeString<Str>::value>::type
+vformatChecked(Str* out, StringPiece fmt, Container&& container) {
+  vformatChecked(fmt, std::forward<Container>(container)).appendTo(*out);
+}
+
 /**
  * Utilities for all format value specializations.
  */