From a66c22590a240cc609d55e6097af8eb60dd9a730 Mon Sep 17 00:00:00 2001 From: Adam Simpkins Date: Thu, 30 Jan 2014 13:25:08 -0800 Subject: [PATCH] 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 --- folly/Format.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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. */ -- 2.34.1