From: Andrew Krieger Date: Mon, 16 Oct 2017 04:30:56 +0000 (-0700) Subject: constexpr estimateSpaceNeeded for string literals. X-Git-Tag: v2017.10.16.00 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=a71bd481da2314af8eaefa05cea50b9bada7319d;p=folly.git constexpr estimateSpaceNeeded for string literals. Summary: Partially inspired by WillerZ's investigation into faster compiling StringPiece work, I thought this would be an easy drop in that short circuits some compilation logic (or possibly is strictly better, since the StringPiece conversion method isn't constexpr). Reviewed By: yfeldblum Differential Revision: D6059537 fbshipit-source-id: 072f56e58aa47db10b54825cac8a05dc035b295c --- diff --git a/folly/Conv.h b/folly/Conv.h index be0d3d0d..ce30765c 100644 --- a/folly/Conv.h +++ b/folly/Conv.h @@ -408,6 +408,11 @@ estimateSpaceNeeded(T) { return 1; } +template +constexpr size_t estimateSpaceNeeded(const char (&)[N]) { + return N; +} + /** * Everything implicitly convertible to const char* gets appended. */