From: Adam Simpkins Date: Thu, 30 Jan 2014 21:25:08 +0000 (-0800) Subject: add additional formatChecked() and vformatChecked() wrappers X-Git-Tag: v0.22.0~712 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a66c22590a240cc609d55e6097af8eb60dd9a730;p=folly.git add additional formatChecked() and vformatChecked() wrappers 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 --- diff --git a/folly/Format.h b/folly/Format.h index a270b43b..11e2462a 100644 --- a/folly/Format.h +++ b/folly/Format.h @@ -271,6 +271,12 @@ format(Str* out, StringPiece fmt, Args&&... args) { format(fmt, std::forward(args)...).appendTo(*out); } +template +typename std::enable_if::value>::type +formatChecked(Str* out, StringPiece fmt, Args&&... args) { + formatChecked(fmt, std::forward(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)).appendTo(*out); } +template +typename std::enable_if::value>::type +vformatChecked(Str* out, StringPiece fmt, Container&& container) { + vformatChecked(fmt, std::forward(container)).appendTo(*out); +} + /** * Utilities for all format value specializations. */