[PATCH] D24713: Add a full-featured compile-time string implementation

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 18 16:26:15 PDT 2016


zturner created this revision.
zturner added a reviewer: chandlerc.
zturner added a subscriber: llvm-commits.
Herald added subscribers: mgorny, beanz.

The original idea for this came from Scott Schurr's talk at cppcon 2015. That implementation had only 2 methods though.  An `operator[]` and a `size()` method.

I wanted to see how far I could take this.  I didn't think I would be able to get a pretty much completely functional compile time string class, but I did :)

I don't know if people would find this useful.  The big question I have is compiler support.  This works on MSVC 2015, which usually lags behind other compilers, especially when it comes to `constexpr`.  So given that it works on VS2015, I'm inclined to believe that it works everywhere else.

In my spare time I've been working on a compile time printf implementation using variadic templates that can tokenize the format string at compile time to do argument matching, and this class is the foundation of that implementation.  When it's more complete I plan to upload that as well.

In the meantime, let me know if this looks useful enough to be in LLVM.

https://reviews.llvm.org/D24713

Files:
  include/llvm/ADT/StringLiteral.h
  unittests/ADT/CMakeLists.txt
  unittests/ADT/StringLiteralTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24713.71762.patch
Type: text/x-patch
Size: 40245 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160918/4e94e4b1/attachment.bin>


More information about the llvm-commits mailing list