Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(924)

Unified Diff: base/strings/string_piece.h

Issue 2579473002: [wip] Add LiteralStringPiece which templatizes based on character length (Closed)
Patch Set: add some usage Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/strings/string_piece_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/strings/string_piece.h
diff --git a/base/strings/string_piece.h b/base/strings/string_piece.h
index eaec14de5da788ebab2137df35015b9998ec892e..dccd109457895aa2c930cfcd8bcc1429e1a02f6f 100644
--- a/base/strings/string_piece.h
+++ b/base/strings/string_piece.h
@@ -367,6 +367,11 @@ const typename BasicStringPiece<STRING_TYPE>::size_type
BasicStringPiece<STRING_TYPE>::npos =
typename BasicStringPiece<STRING_TYPE>::size_type(-1);
+template <size_t size>
+inline StringPiece LiteralStringPiece(const char (&array)[size]) {
+ return StringPiece(array, size - 1);
+}
+
// MSVC doesn't like complex extern templates and DLLs.
#if !defined(COMPILER_MSVC)
extern template class BASE_EXPORT BasicStringPiece<std::string>;
« no previous file with comments | « no previous file | base/strings/string_piece_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698