+/**
+ * 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.
+ *
+ * This is identical to vformat(), but throws an exception if the format string
+ * is invalid, rather than aborting the program. This allows it to be used
+ * with user-specified format strings which are not guaranteed to be well
+ * formed.
+ */
+template <class Container>
+Formatter<true, Container> vformatChecked(StringPiece fmt,
+ Container&& container) {
+ Formatter<true, Container> f(fmt, std::forward<Container>(container));
+ f.setCrashOnError(false);
+ 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.
+ *
+ * Usage:
+ * format("[no_such_key"], defaulted(map, 42)) -> 42
+ */
+namespace detail {
+template <class Container, class Value> struct DefaultValueWrapper {
+ DefaultValueWrapper(const Container& container, const Value& defaultValue)
+ : container(container),
+ defaultValue(defaultValue) {
+ }
+
+ const Container& container;
+ const Value& defaultValue;
+};
+} // namespace
+
+template <class Container, class Value>
+detail::DefaultValueWrapper<Container, Value>
+defaulted(const Container& c, const Value& v) {
+ return detail::DefaultValueWrapper<Container, Value>(c, v);
+}
+