From: Hannes Roth Date: Thu, 27 Mar 2014 21:47:00 +0000 (-0700) Subject: (Folly/FBString) Use a lambda to throw an exception for NULL input X-Git-Tag: v0.22.0~629 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=72c2a0d3b47de74dd56b6750922e54ef333b4cbd;p=folly.git (Folly/FBString) Use a lambda to throw an exception for NULL input Summary: This should be standard compliant. `__PRETTY_FUNCTION__` seems unnecessary, it just prints `basic_fbstring`, might as well use that and simplify the code. Test Plan: `fbconfig --platform-all=gcc-4.8.1-glibc-2.17-fb folly/test` `fbmake runtests_dbg` `fbmake runtests_opt` `fbconfig --platform-all=gcc-4.7.1-glibc-2.14.1 folly/test` `fbmake runtests_dbg` `fbmake runtests_opt` `fbconfig --clang folly/test` `...` Reviewed By: andrei.alexandrescu@fb.com FB internal diff: D1243670 --- diff --git a/folly/FBString.h b/folly/FBString.h index b9d45a98..a768dec3 100644 --- a/folly/FBString.h +++ b/folly/FBString.h @@ -1054,12 +1054,13 @@ public: } /* implicit */ basic_fbstring(const value_type* s, const A& a = A()) - : store_(s, s ? traits_type::length(s) : ({ - basic_fbstring err = __PRETTY_FUNCTION__; - err += ": null pointer initializer not valid"; - std::__throw_logic_error(err.c_str()); - 0; - })) { + : store_(s, s + ? traits_type::length(s) + : [] { + std::__throw_logic_error( + "basic_fbstring: null pointer initializer not valid"); + return 0; + }()) { } basic_fbstring(const value_type* s, size_type n, const A& a = A())