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^0 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b02d434889ac7e937aaf01b1e601c76aa119640e;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. */