1
Description: qualify all uses of string_view, it is in the experimental
2
namespace with libstdc++ 5, which is the version available in xenial
3
Author: Olivier Tilloy <olivier.tilloy@canonical.com>
5
--- a/tools/gn/src/base/command_line.h
6
+++ b/tools/gn/src/base/command_line.h
11
-#include <string_view>
12
+#include <experimental/string_view>
15
#include "util/build_config.h"
16
@@ -163,16 +163,16 @@ class CommandLine {
17
// Switch names must be lowercase.
18
// The second override provides an optimized version to avoid inlining codegen
19
// at every callsite to find the length of the constant and construct a
20
- // std::string_view.
21
- bool HasSwitch(const std::string_view& switch_string) const;
22
+ // std::experimental::string_view.
23
+ bool HasSwitch(const std::experimental::string_view& switch_string) const;
24
bool HasSwitch(const char switch_constant[]) const;
26
// Returns the value associated with the given switch. If the switch has no
27
// value or isn't present, this method returns the empty string.
28
// Switch names must be lowercase.
29
- std::string GetSwitchValueASCII(const std::string_view& switch_string) const;
30
- FilePath GetSwitchValuePath(const std::string_view& switch_string) const;
31
- StringType GetSwitchValueNative(const std::string_view& switch_string) const;
32
+ std::string GetSwitchValueASCII(const std::experimental::string_view& switch_string) const;
33
+ FilePath GetSwitchValuePath(const std::experimental::string_view& switch_string) const;
34
+ StringType GetSwitchValueNative(const std::experimental::string_view& switch_string) const;
36
// Get a copy of all switches, along with their values.
37
const SwitchMap& GetSwitches() const { return switches_; }
38
--- a/tools/gn/src/base/environment.h
39
+++ b/tools/gn/src/base/environment.h
44
-#include <string_view>
45
+#include <experimental/string_view>
47
#include "util/build_config.h"
49
@@ -31,17 +31,17 @@ class Environment {
51
// Gets an environment variable's value and stores it in |result|.
52
// Returns false if the key is unset.
53
- virtual bool GetVar(std::string_view variable_name, std::string* result) = 0;
54
+ virtual bool GetVar(std::experimental::string_view variable_name, std::string* result) = 0;
56
// Syntactic sugar for GetVar(variable_name, nullptr);
57
- virtual bool HasVar(std::string_view variable_name);
58
+ virtual bool HasVar(std::experimental::string_view variable_name);
60
// Returns true on success, otherwise returns false.
61
- virtual bool SetVar(std::string_view variable_name,
62
+ virtual bool SetVar(std::experimental::string_view variable_name,
63
const std::string& new_value) = 0;
65
// Returns true on success, otherwise returns false.
66
- virtual bool UnSetVar(std::string_view variable_name) = 0;
67
+ virtual bool UnSetVar(std::experimental::string_view variable_name) = 0;
71
--- a/tools/gn/src/base/files/file_path.h
72
+++ b/tools/gn/src/base/files/file_path.h
77
-#include <string_view>
78
+#include <experimental/string_view>
81
#include "base/compiler_specific.h"
82
@@ -154,7 +154,7 @@ class FilePath {
85
using CharType = StringType::value_type;
86
- using StringViewType = std::basic_string_view<CharType>;
87
+ using StringViewType = std::experimental::basic_string_view<CharType>;
89
// Null-terminated array of separators used to separate components in
90
// hierarchical paths. Each character in this array is a valid separator,
91
@@ -285,7 +285,7 @@ class FilePath {
92
// path == "C:\pics.old\jojo" suffix == " (1)", returns "C:\pics.old\jojo (1)"
93
FilePath InsertBeforeExtension(StringViewType suffix) const
95
- FilePath InsertBeforeExtensionASCII(std::string_view suffix) const
96
+ FilePath InsertBeforeExtensionASCII(std::experimental::string_view suffix) const
99
// Adds |extension| to |file_name|. Returns the current FilePath if
100
@@ -313,7 +313,7 @@ class FilePath {
101
// Linux, although it can use any 8-bit encoding for paths, we assume that
102
// ASCII is a valid subset, regardless of the encoding, since many operating
103
// system paths will always be ASCII.
104
- FilePath AppendASCII(std::string_view component) const WARN_UNUSED_RESULT;
105
+ FilePath AppendASCII(std::experimental::string_view component) const WARN_UNUSED_RESULT;
107
// Returns true if this FilePath contains an absolute path. On Windows, an
108
// absolute path begins with either a drive letter specification followed by
109
--- a/tools/gn/src/base/logging.h
110
+++ b/tools/gn/src/base/logging.h
115
-#include <string_view>
116
+#include <experimental/string_view>
117
#include <type_traits>
120
--- a/tools/gn/src/gn/token.h
121
+++ b/tools/gn/src/gn/token.h
123
#ifndef TOOLS_GN_TOKEN_H_
124
#define TOOLS_GN_TOKEN_H_
126
-#include <string_view>
127
+#include <experimental/string_view>
129
#include "gn/location.h"
131
@@ -58,10 +58,10 @@ class Token {
135
- Token(const Location& location, Type t, const std::string_view& v);
136
+ Token(const Location& location, Type t, const std::experimental::string_view& v);
138
Type type() const { return type_; }
139
- const std::string_view& value() const { return value_; }
140
+ const std::experimental::string_view& value() const { return value_; }
141
const Location& location() const { return location_; }
142
void set_location(Location location) { location_ = location; }
143
LocationRange range() const {
144
@@ -78,7 +78,7 @@ class Token {
148
- std::string_view value_;
149
+ std::experimental::string_view value_;
153
--- a/tools/gn/src/base/command_line.cc
154
+++ b/tools/gn/src/base/command_line.cc
159
-#include <string_view>
160
+#include <experimental/string_view>
162
#include "base/files/file_path.h"
163
#include "base/logging.h"
164
@@ -187,8 +187,8 @@ CommandLine::~CommandLine() = default;
166
void CommandLine::set_slash_is_not_a_switch() {
167
// The last switch prefix should be slash, so adjust the size to skip it.
168
- DCHECK(std::u16string_view(kSwitchPrefixes[std::size(kSwitchPrefixes) - 1]) ==
169
- std::u16string_view(u"/"));
170
+ DCHECK(std::experimental::u16string_view(kSwitchPrefixes[std::size(kSwitchPrefixes) - 1]) ==
171
+ std::experimental::u16string_view(u"/"));
172
switch_prefix_count = std::size(kSwitchPrefixes) - 1;
175
@@ -283,17 +283,17 @@ void CommandLine::SetProgram(const FileP
179
-bool CommandLine::HasSwitch(const std::string_view& switch_string) const {
180
+bool CommandLine::HasSwitch(const std::experimental::string_view& switch_string) const {
181
DCHECK_EQ(ToLowerASCII(switch_string), switch_string);
182
return ContainsKey(switches_, switch_string);
185
bool CommandLine::HasSwitch(const char switch_constant[]) const {
186
- return HasSwitch(std::string_view(switch_constant));
187
+ return HasSwitch(std::experimental::string_view(switch_constant));
190
std::string CommandLine::GetSwitchValueASCII(
191
- const std::string_view& switch_string) const {
192
+ const std::experimental::string_view& switch_string) const {
193
StringType value = GetSwitchValueNative(switch_string);
194
if (!IsStringASCII(value)) {
195
DLOG(WARNING) << "Value of switch (" << switch_string << ") must be ASCII.";
196
@@ -307,12 +307,12 @@ std::string CommandLine::GetSwitchValueA
199
FilePath CommandLine::GetSwitchValuePath(
200
- const std::string_view& switch_string) const {
201
+ const std::experimental::string_view& switch_string) const {
202
return FilePath(GetSwitchValueNative(switch_string));
205
CommandLine::StringType CommandLine::GetSwitchValueNative(
206
- const std::string_view& switch_string) const {
207
+ const std::experimental::string_view& switch_string) const {
208
DCHECK_EQ(ToLowerASCII(switch_string), switch_string);
209
auto result = switches_.find(switch_string);
210
return result == switches_.end() ? StringType() : result->second;
211
--- a/tools/gn/src/base/environment.cc
212
+++ b/tools/gn/src/base/environment.cc
217
-#include <string_view>
218
+#include <experimental/string_view>
221
#include "base/memory/ptr_util.h"
222
@@ -26,7 +26,7 @@ namespace {
224
class EnvironmentImpl : public Environment {
226
- bool GetVar(std::string_view variable_name, std::string* result) override {
227
+ bool GetVar(std::experimental::string_view variable_name, std::string* result) override {
228
if (GetVarImpl(variable_name, result))
231
@@ -45,17 +45,17 @@ class EnvironmentImpl : public Environme
232
return GetVarImpl(alternate_case_var, result);
235
- bool SetVar(std::string_view variable_name,
236
+ bool SetVar(std::experimental::string_view variable_name,
237
const std::string& new_value) override {
238
return SetVarImpl(variable_name, new_value);
241
- bool UnSetVar(std::string_view variable_name) override {
242
+ bool UnSetVar(std::experimental::string_view variable_name) override {
243
return UnSetVarImpl(variable_name);
247
- bool GetVarImpl(std::string_view variable_name, std::string* result) {
248
+ bool GetVarImpl(std::experimental::string_view variable_name, std::string* result) {
250
DWORD value_length = ::GetEnvironmentVariable(
251
reinterpret_cast<LPCWSTR>(UTF8ToUTF16(variable_name).c_str()), nullptr,
252
@@ -81,7 +81,7 @@ class EnvironmentImpl : public Environme
256
- bool SetVarImpl(std::string_view variable_name,
257
+ bool SetVarImpl(std::experimental::string_view variable_name,
258
const std::string& new_value) {
260
// On success, a nonzero value is returned.
261
@@ -94,7 +94,7 @@ class EnvironmentImpl : public Environme
265
- bool UnSetVarImpl(std::string_view variable_name) {
266
+ bool UnSetVarImpl(std::experimental::string_view variable_name) {
268
// On success, a nonzero value is returned.
269
return !!SetEnvironmentVariable(
270
@@ -142,7 +142,7 @@ std::unique_ptr<Environment> Environment
271
return std::make_unique<EnvironmentImpl>();
274
-bool Environment::HasVar(std::string_view variable_name) {
275
+bool Environment::HasVar(std::experimental::string_view variable_name) {
276
return GetVar(variable_name, nullptr);
279
--- a/tools/gn/src/base/files/file_path.cc
280
+++ b/tools/gn/src/base/files/file_path.cc
285
-#include <string_view>
286
+#include <experimental/string_view>
288
#include "base/logging.h"
289
#include "base/macros.h"
290
@@ -173,7 +173,7 @@ FilePath::FilePath(const FilePath& that)
291
FilePath::FilePath(FilePath&& that) noexcept = default;
293
FilePath::FilePath(StringViewType path) {
294
- path_.assign(path);
295
+ path_.assign(path.data(), path.size());
296
StringType::size_type nul_pos = path_.find(kStringTerminator);
297
if (nul_pos != StringType::npos)
298
path_.erase(nul_pos, StringType::npos);
299
@@ -403,12 +403,12 @@ FilePath FilePath::InsertBeforeExtension
301
StringType ext = Extension();
302
StringType ret = RemoveExtension().value();
303
- ret.append(suffix);
304
+ ret.append(suffix.data(), suffix.size());
306
return FilePath(ret);
309
-FilePath FilePath::InsertBeforeExtensionASCII(std::string_view suffix) const {
310
+FilePath FilePath::InsertBeforeExtensionASCII(std::experimental::string_view suffix) const {
311
DCHECK(IsStringASCII(suffix));
313
return InsertBeforeExtension(ASCIIToUTF16(suffix));
314
@@ -431,7 +431,7 @@ FilePath FilePath::AddExtension(StringVi
315
*(str.end() - 1) != kExtensionSeparator) {
316
str.append(1, kExtensionSeparator);
318
- str.append(extension);
319
+ str.append(extension.data(), extension.size());
320
return FilePath(str);
323
@@ -448,7 +448,7 @@ FilePath FilePath::ReplaceExtension(Stri
324
StringType str = no_ext.value();
325
if (extension[0] != kExtensionSeparator)
326
str.append(1, kExtensionSeparator);
327
- str.append(extension);
328
+ str.append(extension.data(), extension.size());
329
return FilePath(str);
332
@@ -458,7 +458,7 @@ FilePath FilePath::Append(StringViewType
334
StringType::size_type nul_pos = component.find(kStringTerminator);
335
if (nul_pos != StringViewType::npos) {
336
- without_nuls.assign(component.substr(0, nul_pos));
337
+ without_nuls.assign(component.substr(0, nul_pos).data(), nul_pos);
338
appended = StringViewType(without_nuls);
341
@@ -492,7 +492,7 @@ FilePath FilePath::Append(StringViewType
345
- new_path.path_.append(appended);
346
+ new_path.path_.append(appended.data(), appended.size());
350
@@ -500,7 +500,7 @@ FilePath FilePath::Append(const FilePath
351
return Append(component.value());
354
-FilePath FilePath::AppendASCII(std::string_view component) const {
355
+FilePath FilePath::AppendASCII(std::experimental::string_view component) const {
356
DCHECK(base::IsStringASCII(component));
358
return Append(ASCIIToUTF16(component));
359
--- a/tools/gn/src/base/files/file_util.cc
360
+++ b/tools/gn/src/base/files/file_util.cc
365
-#include <string_view>
366
+#include <experimental/string_view>
368
#include "base/files/file_enumerator.h"
369
#include "base/files/file_path.h"
370
--- a/tools/gn/src/base/files/file_util_win.cc
371
+++ b/tools/gn/src/base/files/file_util_win.cc
376
-#include <string_view>
377
+#include <experimental/string_view>
379
#include "base/files/file_enumerator.h"
380
#include "base/files/file_path.h"
381
@@ -199,7 +199,7 @@ FilePath MakeAbsoluteFilePath(const File
382
bool DeleteFile(const FilePath& path, bool recursive) {
383
static constexpr char kRecursive[] = "DeleteFile.Recursive";
384
static constexpr char kNonRecursive[] = "DeleteFile.NonRecursive";
385
- const std::string_view operation(recursive ? kRecursive : kNonRecursive);
386
+ const std::experimental::string_view operation(recursive ? kRecursive : kNonRecursive);
388
// Metrics for delete failures tracked in https://crbug.com/599084. Delete may
389
// fail for a number of reasons. Log some metrics relating to failures in the
390
--- a/tools/gn/src/base/json/json_parser.cc
391
+++ b/tools/gn/src/base/json/json_parser.cc
393
#include "base/json/json_parser.h"
396
-#include <string_view>
397
+#include <experimental/string_view>
401
@@ -68,7 +68,7 @@ JSONParser::JSONParser(int options, int
403
JSONParser::~JSONParser() = default;
405
-std::optional<Value> JSONParser::Parse(std::string_view input) {
406
+std::optional<Value> JSONParser::Parse(std::experimental::string_view input) {
410
@@ -163,30 +163,30 @@ std::string JSONParser::StringBuilder::D
412
// JSONParser private //////////////////////////////////////////////////////////
414
-std::optional<std::string_view> JSONParser::PeekChars(int count) {
415
+std::optional<std::experimental::string_view> JSONParser::PeekChars(int count) {
416
if (static_cast<size_t>(index_) + count > input_.length())
418
- // Using std::string_view::substr() is significantly slower (according to
419
+ // Using std::experimental::string_view::substr() is significantly slower (according to
420
// base_perftests) than constructing a substring manually.
421
- return std::string_view(input_.data() + index_, count);
422
+ return std::experimental::string_view(input_.data() + index_, count);
425
std::optional<char> JSONParser::PeekChar() {
426
- std::optional<std::string_view> chars = PeekChars(1);
427
+ std::optional<std::experimental::string_view> chars = PeekChars(1);
433
-std::optional<std::string_view> JSONParser::ConsumeChars(int count) {
434
- std::optional<std::string_view> chars = PeekChars(count);
435
+std::optional<std::experimental::string_view> JSONParser::ConsumeChars(int count) {
436
+ std::optional<std::experimental::string_view> chars = PeekChars(count);
442
std::optional<char> JSONParser::ConsumeChar() {
443
- std::optional<std::string_view> chars = ConsumeChars(1);
444
+ std::optional<std::experimental::string_view> chars = ConsumeChars(1);
448
@@ -268,7 +268,7 @@ void JSONParser::EatWhitespaceAndComment
451
bool JSONParser::EatComment() {
452
- std::optional<std::string_view> comment_start = ConsumeChars(2);
453
+ std::optional<std::experimental::string_view> comment_start = ConsumeChars(2);
457
@@ -444,7 +444,7 @@ bool JSONParser::ConsumeStringRaw(String
461
- // StringBuilder will internally build a std::string_view unless a UTF-16
462
+ // StringBuilder will internally build a std::experimental::string_view unless a UTF-16
463
// conversion occurs, at which point it will perform a copy into a
465
StringBuilder string(pos());
466
@@ -475,12 +475,12 @@ bool JSONParser::ConsumeStringRaw(String
468
// And if it is an escape sequence, the input string will be adjusted
469
// (either by combining the two characters of an encoded escape sequence,
470
- // or with a UTF conversion), so using std::string_view isn't possible --
471
+ // or with a UTF conversion), so using std::experimental::string_view isn't possible --
472
// force a conversion.
475
// Read past the escape '\' and ensure there's a character following.
476
- std::optional<std::string_view> escape_sequence = ConsumeChars(2);
477
+ std::optional<std::experimental::string_view> escape_sequence = ConsumeChars(2);
478
if (!escape_sequence) {
479
ReportError(JSONReader::JSON_INVALID_ESCAPE, 0);
481
@@ -558,7 +558,7 @@ bool JSONParser::ConsumeStringRaw(String
483
// Entry is at the first X in \uXXXX.
484
bool JSONParser::DecodeUTF16(uint32_t* out_code_point) {
485
- std::optional<std::string_view> escape_sequence = ConsumeChars(4);
486
+ std::optional<std::experimental::string_view> escape_sequence = ConsumeChars(4);
487
if (!escape_sequence)
490
@@ -671,7 +671,7 @@ std::optional<Value> JSONParser::Consume
494
- std::string_view num_string(num_start, end_index - start_index);
495
+ std::experimental::string_view num_string(num_start, end_index - start_index);
498
if (StringToInt(num_string, &num_int))
499
@@ -717,7 +717,7 @@ std::optional<Value> JSONParser::Consume
503
-bool JSONParser::ConsumeIfMatch(std::string_view match) {
504
+bool JSONParser::ConsumeIfMatch(std::experimental::string_view match) {
505
if (match == PeekChars(match.size())) {
506
ConsumeChars(match.size());
508
--- a/tools/gn/src/base/json/json_parser.h
509
+++ b/tools/gn/src/base/json/json_parser.h
514
-#include <string_view>
515
+#include <experimental/string_view>
517
#include "base/compiler_specific.h"
518
#include "base/gtest_prod_util.h"
519
@@ -49,7 +49,7 @@ class JSONParser {
520
// result as a Value.
521
// Wrap this in base::FooValue::From() to check the Value is of type Foo and
522
// convert to a FooValue at the same time.
523
- std::optional<Value> Parse(std::string_view input);
524
+ std::optional<Value> Parse(std::experimental::string_view input);
526
// Returns the error code.
527
JSONReader::JsonParseError error_code() const;
528
@@ -83,7 +83,7 @@ class JSONParser {
531
// A helper class used for parsing strings. One optimization performed is to
532
- // create base::Value with a std::string_view to avoid unnecessary std::string
533
+ // create base::Value with a std::experimental::string_view to avoid unnecessary std::string
534
// copies. This is not possible if the input string needs to be decoded from
535
// UTF-16 to UTF-8, or if an escape sequence causes characters to be skipped.
536
// This class centralizes that logic.
537
@@ -104,9 +104,9 @@ class JSONParser {
538
// converted, or by appending the UTF8 bytes for the code point.
539
void Append(uint32_t point);
541
- // Converts the builder from its default std::string_view to a full
542
+ // Converts the builder from its default std::experimental::string_view to a full
543
// std::string, performing a copy. Once a builder is converted, it cannot be
544
- // made a std::string_view again.
545
+ // made a std::experimental::string_view again.
548
// Returns the builder as a string, invalidating all state. This allows
549
@@ -128,14 +128,14 @@ class JSONParser {
551
// Returns the next |count| bytes of the input stream, or nullopt if fewer
552
// than |count| bytes remain.
553
- std::optional<std::string_view> PeekChars(int count);
554
+ std::optional<std::experimental::string_view> PeekChars(int count);
556
// Calls PeekChars() with a |count| of 1.
557
std::optional<char> PeekChar();
559
// Returns the next |count| bytes of the input stream, or nullopt if fewer
560
// than |count| bytes remain, and advances the parser position by |count|.
561
- std::optional<std::string_view> ConsumeChars(int count);
562
+ std::optional<std::experimental::string_view> ConsumeChars(int count);
564
// Calls ConsumeChars() with a |count| of 1.
565
std::optional<char> ConsumeChar();
566
@@ -198,7 +198,7 @@ class JSONParser {
567
// consumed at the current parser position. Returns false if there are fewer
568
// than |match|-length bytes or if the sequence does not match, and the
569
// parser state is unchanged.
570
- bool ConsumeIfMatch(std::string_view match);
571
+ bool ConsumeIfMatch(std::experimental::string_view match);
573
// Sets the error information to |code| at the current column, based on
574
// |index_| and |index_last_line_|, with an optional positive/negative
575
@@ -218,7 +218,7 @@ class JSONParser {
576
const int max_depth_;
578
// The input stream being parsed. Note: Not guaranteed to NUL-terminated.
579
- std::string_view input_;
580
+ std::experimental::string_view input_;
582
// The index in the input stream to which the parser is wound.
584
--- a/tools/gn/src/base/json/json_reader.h
585
+++ b/tools/gn/src/base/json/json_reader.h
590
-#include <string_view>
591
+#include <experimental/string_view>
595
@@ -93,7 +93,7 @@ class JSONReader {
596
// If |json| is not a properly formed JSON string, returns nullptr.
597
// Wrap this in base::FooValue::From() to check the Value is of type Foo and
598
// convert to a FooValue at the same time.
599
- static std::unique_ptr<Value> Read(std::string_view json,
600
+ static std::unique_ptr<Value> Read(std::experimental::string_view json,
601
int options = JSON_PARSE_RFC,
602
int max_depth = kStackMaxDepth);
604
@@ -102,7 +102,7 @@ class JSONReader {
605
// an error code and a formatted error message (including error location if
606
// appropriate). Otherwise, they will be unmodified.
607
static std::unique_ptr<Value> ReadAndReturnError(
608
- std::string_view json,
609
+ std::experimental::string_view json,
610
int options, // JSONParserOptions
612
std::string* error_msg_out,
613
@@ -114,7 +114,7 @@ class JSONReader {
614
static std::string ErrorCodeToString(JsonParseError error_code);
616
// Non-static version of Read() above.
617
- std::unique_ptr<Value> ReadToValue(std::string_view json);
618
+ std::unique_ptr<Value> ReadToValue(std::experimental::string_view json);
620
// Returns the error code if the last call to ReadToValue() failed.
621
// Returns JSON_NO_ERROR otherwise.
622
--- a/tools/gn/src/base/json/json_value_converter.h
623
+++ b/tools/gn/src/base/json/json_value_converter.h
628
-#include <string_view>
629
+#include <experimental/string_view>
632
#include "base/logging.h"
635
// Sometimes JSON format uses string representations for other types such
636
// like enum, timestamp, or URL. You can use RegisterCustomField method
637
-// and specify a function to convert a std::string_view to your type.
638
-// bool ConvertFunc(std::string_view s, YourEnum* result) {
639
+// and specify a function to convert a std::experimental::string_view to your type.
640
+// bool ConvertFunc(std::experimental::string_view s, YourEnum* result) {
641
// // do something and return true if succeed...
644
@@ -211,7 +211,7 @@ class ValueFieldConverter : public Value
645
template <typename FieldType>
646
class CustomFieldConverter : public ValueConverter<FieldType> {
648
- typedef bool (*ConvertFunc)(std::string_view value, FieldType* field);
649
+ typedef bool (*ConvertFunc)(std::experimental::string_view value, FieldType* field);
651
explicit CustomFieldConverter(ConvertFunc convert_func)
652
: convert_func_(convert_func) {}
653
@@ -399,7 +399,7 @@ class JSONValueConverter {
654
template <typename FieldType>
655
void RegisterCustomField(const std::string& field_name,
656
FieldType StructType::*field,
657
- bool (*convert_func)(std::string_view, FieldType*)) {
658
+ bool (*convert_func)(std::experimental::string_view, FieldType*)) {
660
std::make_unique<internal::FieldConverter<StructType, FieldType>>(
662
--- a/tools/gn/src/base/json/string_escape.h
663
+++ b/tools/gn/src/base/json/string_escape.h
665
#define BASE_JSON_STRING_ESCAPE_H_
668
-#include <string_view>
669
+#include <experimental/string_view>
673
@@ -24,21 +24,21 @@ namespace base {
675
// If |put_in_quotes| is true, then a leading and trailing double-quote mark
676
// will be appended to |dest| as well.
677
-bool EscapeJSONString(std::string_view str,
678
+bool EscapeJSONString(std::experimental::string_view str,
682
-// Performs a similar function to the UTF-8 std::string_view version above,
683
+// Performs a similar function to the UTF-8 std::experimental::string_view version above,
684
// converting UTF-16 code units to UTF-8 code units and escaping non-printing
685
// control characters. On return, |dest| will contain a valid UTF-8 JSON string.
686
-bool EscapeJSONString(std::u16string_view str,
687
+bool EscapeJSONString(std::experimental::u16string_view str,
691
// Helper functions that wrap the above two functions but return the value
692
// instead of appending. |put_in_quotes| is always true.
693
-std::string GetQuotedJSONString(std::string_view str);
694
-std::string GetQuotedJSONString(std::u16string_view str);
695
+std::string GetQuotedJSONString(std::experimental::string_view str);
696
+std::string GetQuotedJSONString(std::experimental::u16string_view str);
698
// Given an arbitrary byte string |str|, this will escape all non-ASCII bytes
699
// as \uXXXX escape sequences. This function is *NOT* meant to be used with
700
@@ -51,7 +51,7 @@ std::string GetQuotedJSONString(std::u16
702
// The output of this function takes the *appearance* of JSON but is not in
703
// fact valid according to RFC 4627.
704
-std::string EscapeBytesAsInvalidJSONString(std::string_view str,
705
+std::string EscapeBytesAsInvalidJSONString(std::experimental::string_view str,
709
--- a/tools/gn/src/base/logging.cc
710
+++ b/tools/gn/src/base/logging.cc
715
-#include <string_view>
716
+#include <experimental/string_view>
719
#include "base/posix/eintr_wrapper.h"
720
@@ -187,9 +187,9 @@ LogMessage::~LogMessage() {
722
// writes the common header info to the stream
723
void LogMessage::Init(const char* file, int line) {
724
- std::string_view filename(file);
725
+ std::experimental::string_view filename(file);
726
size_t last_slash_pos = filename.find_last_of("\\/");
727
- if (last_slash_pos != std::string_view::npos)
728
+ if (last_slash_pos != std::experimental::string_view::npos)
729
filename.remove_prefix(last_slash_pos + 1);
731
// TODO(darin): It might be nice if the columns were fixed width.
732
--- a/tools/gn/src/base/md5.h
733
+++ b/tools/gn/src/base/md5.h
738
-#include <string_view>
739
+#include <experimental/string_view>
743
@@ -49,10 +49,10 @@ typedef char MD5Context[88];
745
void MD5Init(MD5Context* context);
747
-// For the given buffer of |data| as a std::string_view, updates the given MD5
748
+// For the given buffer of |data| as a std::experimental::string_view, updates the given MD5
749
// context with the sum of the data. You can call this any number of times
750
// during the computation, except that MD5Init() must have been called first.
751
-void MD5Update(MD5Context* context, const std::string_view& data);
752
+void MD5Update(MD5Context* context, const std::experimental::string_view& data);
754
// Finalizes the MD5 operation and fills the buffer with the digest.
755
void MD5Final(MD5Digest* digest, MD5Context* context);
756
@@ -70,7 +70,7 @@ std::string MD5DigestToBase16(const MD5D
757
void MD5Sum(const void* data, size_t length, MD5Digest* digest);
759
// Returns the MD5 (in hexadecimal) of a string.
760
-std::string MD5String(const std::string_view& str);
761
+std::string MD5String(const std::experimental::string_view& str);
765
--- a/tools/gn/src/base/strings/string_number_conversions.h
766
+++ b/tools/gn/src/base/strings/string_number_conversions.h
771
-#include <string_view>
772
+#include <experimental/string_view>
775
#include "util/build_config.h"
776
@@ -73,20 +73,20 @@ inline std::u16string Int64ToString16(in
777
// - Empty string. |*output| will be set to 0.
778
// WARNING: Will write to |output| even when returning false.
779
// Read the comments above carefully.
780
-bool StringToInt(std::string_view input, int* output);
781
-bool StringToInt(std::u16string_view input, int* output);
782
+bool StringToInt(std::experimental::string_view input, int* output);
783
+bool StringToInt(std::experimental::u16string_view input, int* output);
785
-bool StringToUint(std::string_view input, unsigned* output);
786
-bool StringToUint(std::u16string_view input, unsigned* output);
787
+bool StringToUint(std::experimental::string_view input, unsigned* output);
788
+bool StringToUint(std::experimental::u16string_view input, unsigned* output);
790
-bool StringToInt64(std::string_view input, int64_t* output);
791
-bool StringToInt64(std::u16string_view input, int64_t* output);
792
+bool StringToInt64(std::experimental::string_view input, int64_t* output);
793
+bool StringToInt64(std::experimental::u16string_view input, int64_t* output);
795
-bool StringToUint64(std::string_view input, uint64_t* output);
796
-bool StringToUint64(std::u16string_view input, uint64_t* output);
797
+bool StringToUint64(std::experimental::string_view input, uint64_t* output);
798
+bool StringToUint64(std::experimental::u16string_view input, uint64_t* output);
800
-bool StringToSizeT(std::string_view input, size_t* output);
801
-bool StringToSizeT(std::u16string_view input, size_t* output);
802
+bool StringToSizeT(std::experimental::string_view input, size_t* output);
803
+bool StringToSizeT(std::experimental::u16string_view input, size_t* output);
805
// Hex encoding ----------------------------------------------------------------
807
@@ -101,30 +101,30 @@ std::string HexEncode(const void* bytes,
808
// Best effort conversion, see StringToInt above for restrictions.
809
// Will only successful parse hex values that will fit into |output|, i.e.
810
// -0x80000000 < |input| < 0x7FFFFFFF.
811
-bool HexStringToInt(std::string_view input, int* output);
812
+bool HexStringToInt(std::experimental::string_view input, int* output);
814
// Best effort conversion, see StringToInt above for restrictions.
815
// Will only successful parse hex values that will fit into |output|, i.e.
816
// 0x00000000 < |input| < 0xFFFFFFFF.
817
// The string is not required to start with 0x.
818
-bool HexStringToUInt(std::string_view input, uint32_t* output);
819
+bool HexStringToUInt(std::experimental::string_view input, uint32_t* output);
821
// Best effort conversion, see StringToInt above for restrictions.
822
// Will only successful parse hex values that will fit into |output|, i.e.
823
// -0x8000000000000000 < |input| < 0x7FFFFFFFFFFFFFFF.
824
-bool HexStringToInt64(std::string_view input, int64_t* output);
825
+bool HexStringToInt64(std::experimental::string_view input, int64_t* output);
827
// Best effort conversion, see StringToInt above for restrictions.
828
// Will only successful parse hex values that will fit into |output|, i.e.
829
// 0x0000000000000000 < |input| < 0xFFFFFFFFFFFFFFFF.
830
// The string is not required to start with 0x.
831
-bool HexStringToUInt64(std::string_view input, uint64_t* output);
832
+bool HexStringToUInt64(std::experimental::string_view input, uint64_t* output);
834
// Similar to the previous functions, except that output is a vector of bytes.
835
// |*output| will contain as many bytes as were successfully parsed prior to the
836
// error. There is no overflow, but input.size() must be evenly divisible by 2.
837
// Leading 0x or +/- are not allowed.
838
-bool HexStringToBytes(std::string_view input, std::vector<uint8_t>* output);
839
+bool HexStringToBytes(std::experimental::string_view input, std::vector<uint8_t>* output);
843
--- a/tools/gn/src/base/strings/string_split.h
844
+++ b/tools/gn/src/base/strings/string_split.h
846
#define BASE_STRINGS_STRING_SPLIT_H_
849
-#include <string_view>
850
+#include <experimental/string_view>
854
@@ -40,12 +40,12 @@ enum SplitResult {
856
// std::vector<std::string> tokens = base::SplitString(
857
// input, ",;", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
858
-std::vector<std::string> SplitString(std::string_view input,
859
- std::string_view separators,
860
+std::vector<std::string> SplitString(std::experimental::string_view input,
861
+ std::experimental::string_view separators,
862
WhitespaceHandling whitespace,
863
SplitResult result_type);
864
-std::vector<std::u16string> SplitString(std::u16string_view input,
865
- std::u16string_view separators,
866
+std::vector<std::u16string> SplitString(std::experimental::u16string_view input,
867
+ std::experimental::u16string_view separators,
868
WhitespaceHandling whitespace,
869
SplitResult result_type);
871
@@ -61,13 +61,13 @@ std::vector<std::u16string> SplitString(
872
// base::KEEP_WHITESPACE,
873
// base::SPLIT_WANT_NONEMPTY)) {
875
-std::vector<std::string_view> SplitStringPiece(std::string_view input,
876
- std::string_view separators,
877
+std::vector<std::experimental::string_view> SplitStringPiece(std::experimental::string_view input,
878
+ std::experimental::string_view separators,
879
WhitespaceHandling whitespace,
880
SplitResult result_type);
881
-std::vector<std::u16string_view> SplitStringPiece(
882
- std::u16string_view input,
883
- std::u16string_view separators,
884
+std::vector<std::experimental::u16string_view> SplitStringPiece(
885
+ std::experimental::u16string_view input,
886
+ std::experimental::u16string_view separators,
887
WhitespaceHandling whitespace,
888
SplitResult result_type);
890
@@ -77,7 +77,7 @@ using StringPairs = std::vector<std::pai
891
// removes whitespace leading each key and trailing each value. Returns true
892
// only if each pair has a non-empty key and value. |key_value_pairs| will
893
// include ("","") pairs for entries without |key_value_delimiter|.
894
-bool SplitStringIntoKeyValuePairs(std::string_view input,
895
+bool SplitStringIntoKeyValuePairs(std::experimental::string_view input,
896
char key_value_delimiter,
897
char key_value_pair_delimiter,
898
StringPairs* key_value_pairs);
899
@@ -85,12 +85,12 @@ bool SplitStringIntoKeyValuePairs(std::s
900
// Similar to SplitString, but use a substring delimiter instead of a list of
901
// characters that are all possible delimiters.
902
std::vector<std::u16string> SplitStringUsingSubstr(
903
- std::u16string_view input,
904
- std::u16string_view delimiter,
905
+ std::experimental::u16string_view input,
906
+ std::experimental::u16string_view delimiter,
907
WhitespaceHandling whitespace,
908
SplitResult result_type);
909
-std::vector<std::string> SplitStringUsingSubstr(std::string_view input,
910
- std::string_view delimiter,
911
+std::vector<std::string> SplitStringUsingSubstr(std::experimental::string_view input,
912
+ std::experimental::string_view delimiter,
913
WhitespaceHandling whitespace,
914
SplitResult result_type);
916
@@ -106,14 +106,14 @@ std::vector<std::string> SplitStringUsin
917
// base::KEEP_WHITESPACE,
918
// base::SPLIT_WANT_NONEMPTY)) {
920
-std::vector<std::u16string_view> SplitStringPieceUsingSubstr(
921
- std::u16string_view input,
922
- std::u16string_view delimiter,
923
+std::vector<std::experimental::u16string_view> SplitStringPieceUsingSubstr(
924
+ std::experimental::u16string_view input,
925
+ std::experimental::u16string_view delimiter,
926
WhitespaceHandling whitespace,
927
SplitResult result_type);
928
-std::vector<std::string_view> SplitStringPieceUsingSubstr(
929
- std::string_view input,
930
- std::string_view delimiter,
931
+std::vector<std::experimental::string_view> SplitStringPieceUsingSubstr(
932
+ std::experimental::string_view input,
933
+ std::experimental::string_view delimiter,
934
WhitespaceHandling whitespace,
935
SplitResult result_type);
937
--- a/tools/gn/src/base/strings/string_tokenizer.h
938
+++ b/tools/gn/src/base/strings/string_tokenizer.h
943
-#include <string_view>
944
+#include <experimental/string_view>
948
@@ -141,8 +141,8 @@ class StringTokenizerT {
949
const_iterator token_begin() const { return token_begin_; }
950
const_iterator token_end() const { return token_end_; }
951
str token() const { return str(token_begin_, token_end_); }
952
- std::basic_string_view<typename str::value_type> token_piece() const {
953
- return std::basic_string_view<typename str::value_type>(
954
+ std::experimental::basic_string_view<typename str::value_type> token_piece() const {
955
+ return std::experimental::basic_string_view<typename str::value_type>(
956
&*token_begin_, std::distance(token_begin_, token_end_));
959
--- a/tools/gn/src/base/strings/string_util.h
960
+++ b/tools/gn/src/base/strings/string_util.h
963
#include <initializer_list>
965
-#include <string_view>
966
+#include <experimental/string_view>
969
#include "base/compiler_specific.h"
970
@@ -71,12 +71,12 @@ inline char16_t ToUpperASCII(char16_t c)
973
// Converts the given string to it's ASCII-lowercase equivalent.
974
-std::string ToLowerASCII(std::string_view str);
975
-std::u16string ToLowerASCII(std::u16string_view str);
976
+std::string ToLowerASCII(std::experimental::string_view str);
977
+std::u16string ToLowerASCII(std::experimental::u16string_view str);
979
// Converts the given string to it's ASCII-uppercase equivalent.
980
-std::string ToUpperASCII(std::string_view str);
981
-std::u16string ToUpperASCII(std::u16string_view str);
982
+std::string ToUpperASCII(std::experimental::string_view str);
983
+std::u16string ToUpperASCII(std::experimental::u16string_view str);
985
// Functor for case-insensitive ASCII comparisons for STL algorithms like
987
@@ -101,14 +101,14 @@ struct CaseInsensitiveCompareASCII {
988
// (unlike strcasecmp which can return values greater or less than 1/-1). For
989
// full Unicode support, use base::i18n::ToLower or base::i18h::FoldCase
990
// and then just call the normal string operators on the result.
991
-int CompareCaseInsensitiveASCII(std::string_view a, std::string_view b);
992
-int CompareCaseInsensitiveASCII(std::u16string_view a, std::u16string_view b);
993
+int CompareCaseInsensitiveASCII(std::experimental::string_view a, std::experimental::string_view b);
994
+int CompareCaseInsensitiveASCII(std::experimental::u16string_view a, std::experimental::u16string_view b);
996
// Equality for ASCII case-insensitive comparisons. For full Unicode support,
997
// use base::i18n::ToLower or base::i18h::FoldCase and then compare with either
999
-bool EqualsCaseInsensitiveASCII(std::string_view a, std::string_view b);
1000
-bool EqualsCaseInsensitiveASCII(std::u16string_view a, std::u16string_view b);
1001
+bool EqualsCaseInsensitiveASCII(std::experimental::string_view a, std::experimental::string_view b);
1002
+bool EqualsCaseInsensitiveASCII(std::experimental::u16string_view a, std::experimental::u16string_view b);
1004
// Contains the set of characters representing whitespace in the corresponding
1005
// encoding. Null-terminated. The ASCII versions are the whitespaces as defined
1006
@@ -124,10 +124,10 @@ extern const char kUtf8ByteOrderMark[];
1007
// if any characters were removed. |remove_chars| must be null-terminated.
1008
// NOTE: Safe to use the same variable for both |input| and |output|.
1009
bool RemoveChars(const std::u16string& input,
1010
- std::u16string_view remove_chars,
1011
+ std::experimental::u16string_view remove_chars,
1012
std::u16string* output);
1013
bool RemoveChars(const std::string& input,
1014
- std::string_view remove_chars,
1015
+ std::experimental::string_view remove_chars,
1016
std::string* output);
1018
// Replaces characters in |replace_chars| from anywhere in |input| with
1019
@@ -136,11 +136,11 @@ bool RemoveChars(const std::string& inpu
1020
// |replace_chars| must be null-terminated.
1021
// NOTE: Safe to use the same variable for both |input| and |output|.
1022
bool ReplaceChars(const std::u16string& input,
1023
- std::u16string_view replace_chars,
1024
+ std::experimental::u16string_view replace_chars,
1025
const std::u16string& replace_with,
1026
std::u16string* output);
1027
bool ReplaceChars(const std::string& input,
1028
- std::string_view replace_chars,
1029
+ std::experimental::string_view replace_chars,
1030
const std::string& replace_with,
1031
std::string* output);
1033
@@ -158,19 +158,19 @@ enum TrimPositions {
1034
// It is safe to use the same variable for both |input| and |output| (this is
1035
// the normal usage to trim in-place).
1036
bool TrimString(const std::u16string& input,
1037
- std::u16string_view trim_chars,
1038
+ std::experimental::u16string_view trim_chars,
1039
std::u16string* output);
1040
bool TrimString(const std::string& input,
1041
- std::string_view trim_chars,
1042
+ std::experimental::string_view trim_chars,
1043
std::string* output);
1045
-// std::string_view versions of the above. The returned pieces refer to the
1046
+// std::experimental::string_view versions of the above. The returned pieces refer to the
1048
-std::u16string_view TrimString(std::u16string_view input,
1049
- std::u16string_view trim_chars,
1050
+std::experimental::u16string_view TrimString(std::experimental::u16string_view input,
1051
+ std::experimental::u16string_view trim_chars,
1052
TrimPositions positions);
1053
-std::string_view TrimString(std::string_view input,
1054
- std::string_view trim_chars,
1055
+std::experimental::string_view TrimString(std::experimental::string_view input,
1056
+ std::experimental::string_view trim_chars,
1057
TrimPositions positions);
1059
// Truncates a string to the nearest UTF-8 character that will leave
1060
@@ -181,7 +181,7 @@ void TruncateUTF8ToByteSize(const std::s
1062
// Trims any whitespace from either end of the input string.
1064
-// The std::string_view versions return a substring referencing the input
1065
+// The std::experimental::string_view versions return a substring referencing the input
1066
// buffer. The ASCII versions look only for ASCII whitespace.
1068
// The std::string versions return where whitespace was found.
1069
@@ -189,12 +189,12 @@ void TruncateUTF8ToByteSize(const std::s
1070
TrimPositions TrimWhitespace(const std::u16string& input,
1071
TrimPositions positions,
1072
std::u16string* output);
1073
-std::u16string_view TrimWhitespace(std::u16string_view input,
1074
+std::experimental::u16string_view TrimWhitespace(std::experimental::u16string_view input,
1075
TrimPositions positions);
1076
TrimPositions TrimWhitespaceASCII(const std::string& input,
1077
TrimPositions positions,
1078
std::string* output);
1079
-std::string_view TrimWhitespaceASCII(std::string_view input,
1080
+std::experimental::string_view TrimWhitespaceASCII(std::experimental::string_view input,
1081
TrimPositions positions);
1083
// Searches for CR or LF characters. Removes all contiguous whitespace
1084
@@ -212,9 +212,9 @@ std::string CollapseWhitespaceASCII(cons
1086
// Returns true if |input| is empty or contains only characters found in
1088
-bool ContainsOnlyChars(std::string_view input, std::string_view characters);
1089
-bool ContainsOnlyChars(std::u16string_view input,
1090
- std::u16string_view characters);
1091
+bool ContainsOnlyChars(std::experimental::string_view input, std::experimental::string_view characters);
1092
+bool ContainsOnlyChars(std::experimental::u16string_view input,
1093
+ std::experimental::u16string_view characters);
1095
// Returns true if the specified string matches the criteria. How can a wide
1096
// string be 8-bit or UTF8? It contains only characters that are < 256 (in the
1097
@@ -230,21 +230,21 @@ bool ContainsOnlyChars(std::u16string_vi
1099
// IsStringASCII assumes the input is likely all ASCII, and does not leave early
1100
// if it is not the case.
1101
-bool IsStringUTF8(std::string_view str);
1102
-bool IsStringASCII(std::string_view str);
1103
-bool IsStringASCII(std::u16string_view str);
1104
+bool IsStringUTF8(std::experimental::string_view str);
1105
+bool IsStringASCII(std::experimental::string_view str);
1106
+bool IsStringASCII(std::experimental::u16string_view str);
1108
// Compare the lower-case form of the given string against the given
1109
// previously-lower-cased ASCII string (typically a constant).
1110
-bool LowerCaseEqualsASCII(std::string_view str,
1111
- std::string_view lowecase_ascii);
1112
-bool LowerCaseEqualsASCII(std::u16string_view str,
1113
- std::string_view lowecase_ascii);
1114
+bool LowerCaseEqualsASCII(std::experimental::string_view str,
1115
+ std::experimental::string_view lowecase_ascii);
1116
+bool LowerCaseEqualsASCII(std::experimental::u16string_view str,
1117
+ std::experimental::string_view lowecase_ascii);
1119
// Performs a case-sensitive string compare of the given 16-bit string against
1120
// the given 8-bit ASCII string (typically a constant). The behavior is
1121
// undefined if the |ascii| string is not ASCII.
1122
-bool EqualsASCII(std::u16string_view str, std::string_view ascii);
1123
+bool EqualsASCII(std::experimental::u16string_view str, std::experimental::string_view ascii);
1125
// Indicates case sensitivity of comparisons. Only ASCII case insensitivity
1126
// is supported. Full Unicode case-insensitive conversions would need to go in
1127
@@ -259,17 +259,17 @@ enum class CompareCase {
1131
-bool StartsWith(std::string_view str,
1132
- std::string_view search_for,
1133
+bool StartsWith(std::experimental::string_view str,
1134
+ std::experimental::string_view search_for,
1135
CompareCase case_sensitivity);
1136
-bool StartsWith(std::u16string_view str,
1137
- std::u16string_view search_for,
1138
+bool StartsWith(std::experimental::u16string_view str,
1139
+ std::experimental::u16string_view search_for,
1140
CompareCase case_sensitivity);
1141
-bool EndsWith(std::string_view str,
1142
- std::string_view search_for,
1143
+bool EndsWith(std::experimental::string_view str,
1144
+ std::experimental::string_view search_for,
1145
CompareCase case_sensitivity);
1146
-bool EndsWith(std::u16string_view str,
1147
- std::u16string_view search_for,
1148
+bool EndsWith(std::experimental::u16string_view str,
1149
+ std::experimental::u16string_view search_for,
1150
CompareCase case_sensitivity);
1152
// Determines the type of ASCII character, independent of locale (the C
1153
@@ -321,12 +321,12 @@ std::u16string FormatBytesUnlocalized(in
1154
// |find_this| with |replace_with|.
1155
void ReplaceFirstSubstringAfterOffset(std::u16string* str,
1156
size_t start_offset,
1157
- std::u16string_view find_this,
1158
- std::u16string_view replace_with);
1159
+ std::experimental::u16string_view find_this,
1160
+ std::experimental::u16string_view replace_with);
1161
void ReplaceFirstSubstringAfterOffset(std::string* str,
1162
size_t start_offset,
1163
- std::string_view find_this,
1164
- std::string_view replace_with);
1165
+ std::experimental::string_view find_this,
1166
+ std::experimental::string_view replace_with);
1168
// Starting at |start_offset| (usually 0), look through |str| and replace all
1169
// instances of |find_this| with |replace_with|.
1170
@@ -336,12 +336,12 @@ void ReplaceFirstSubstringAfterOffset(st
1171
// std::replace(str.begin(), str.end(), 'a', 'b');
1172
void ReplaceSubstringsAfterOffset(std::u16string* str,
1173
size_t start_offset,
1174
- std::u16string_view find_this,
1175
- std::u16string_view replace_with);
1176
+ std::experimental::u16string_view find_this,
1177
+ std::experimental::u16string_view replace_with);
1178
void ReplaceSubstringsAfterOffset(std::string* str,
1179
size_t start_offset,
1180
- std::string_view find_this,
1181
- std::string_view replace_with);
1182
+ std::experimental::string_view find_this,
1183
+ std::experimental::string_view replace_with);
1185
// Reserves enough memory in |str| to accommodate |length_with_null| characters,
1186
// sets the size of |str| to |length_with_null - 1| characters, and returns a
1187
@@ -370,28 +370,28 @@ char16_t* WriteInto(std::u16string* str,
1188
// of strings into a single string, inserting |separator| (which may be empty)
1189
// in between all elements.
1191
-// If possible, callers should build a vector of std::string_views and use the
1192
-// std::string_view variant, so that they do not create unnecessary copies of
1193
+// If possible, callers should build a vector of std::experimental::string_views and use the
1194
+// std::experimental::string_view variant, so that they do not create unnecessary copies of
1195
// strings. For example, instead of using SplitString, modifying the vector,
1196
// then using JoinString, use SplitStringPiece followed by JoinString so that no
1197
// copies of those strings are created until the final join operation.
1199
// Use StrCat (in base/strings/strcat.h) if you don't need a separator.
1200
std::string JoinString(const std::vector<std::string>& parts,
1201
- std::string_view separator);
1202
+ std::experimental::string_view separator);
1203
std::u16string JoinString(const std::vector<std::u16string>& parts,
1204
- std::u16string_view separator);
1205
-std::string JoinString(const std::vector<std::string_view>& parts,
1206
- std::string_view separator);
1207
-std::u16string JoinString(const std::vector<std::u16string_view>& parts,
1208
- std::u16string_view separator);
1209
+ std::experimental::u16string_view separator);
1210
+std::string JoinString(const std::vector<std::experimental::string_view>& parts,
1211
+ std::experimental::string_view separator);
1212
+std::u16string JoinString(const std::vector<std::experimental::u16string_view>& parts,
1213
+ std::experimental::u16string_view separator);
1214
// Explicit initializer_list overloads are required to break ambiguity when used
1215
// with a literal initializer list (otherwise the compiler would not be able to
1216
-// decide between the string and std::string_view overloads).
1217
-std::string JoinString(std::initializer_list<std::string_view> parts,
1218
- std::string_view separator);
1219
-std::u16string JoinString(std::initializer_list<std::u16string_view> parts,
1220
- std::u16string_view separator);
1221
+// decide between the string and std::experimental::string_view overloads).
1222
+std::string JoinString(std::initializer_list<std::experimental::string_view> parts,
1223
+ std::experimental::string_view separator);
1224
+std::u16string JoinString(std::initializer_list<std::experimental::u16string_view> parts,
1225
+ std::experimental::u16string_view separator);
1227
// Replace $1-$2-$3..$9 in the format string with values from |subst|.
1228
// Additionally, any number of consecutive '$' characters is replaced by that
1229
@@ -402,7 +402,7 @@ std::u16string ReplaceStringPlaceholders
1230
const std::vector<std::u16string>& subst,
1231
std::vector<size_t>* offsets);
1233
-std::string ReplaceStringPlaceholders(std::string_view format_string,
1234
+std::string ReplaceStringPlaceholders(std::experimental::string_view format_string,
1235
const std::vector<std::string>& subst,
1236
std::vector<size_t>* offsets);
1238
--- a/tools/gn/src/base/strings/utf_offset_string_conversions.cc
1239
+++ b/tools/gn/src/base/strings/utf_offset_string_conversions.cc
1242
#include <algorithm>
1244
-#include <string_view>
1245
+#include <experimental/string_view>
1247
#include "base/logging.h"
1248
#include "base/strings/utf_string_conversion_utils.h"
1249
@@ -228,7 +228,7 @@ bool UTF8ToUTF16WithAdjustments(
1252
std::u16string UTF8ToUTF16WithAdjustments(
1253
- const std::string_view& utf8,
1254
+ const std::experimental::string_view& utf8,
1255
base::OffsetAdjuster::Adjustments* adjustments) {
1256
std::u16string result;
1257
UTF8ToUTF16WithAdjustments(utf8.data(), utf8.length(), &result, adjustments);
1258
@@ -236,7 +236,7 @@ std::u16string UTF8ToUTF16WithAdjustment
1261
std::u16string UTF8ToUTF16AndAdjustOffsets(
1262
- const std::string_view& utf8,
1263
+ const std::experimental::string_view& utf8,
1264
std::vector<size_t>* offsets_for_adjustment) {
1265
for (size_t& offset : *offsets_for_adjustment) {
1266
if (offset > utf8.length())
1267
@@ -249,7 +249,7 @@ std::u16string UTF8ToUTF16AndAdjustOffse
1270
std::string UTF16ToUTF8AndAdjustOffsets(
1271
- const std::u16string_view& utf16,
1272
+ const std::experimental::u16string_view& utf16,
1273
std::vector<size_t>* offsets_for_adjustment) {
1274
for (size_t& offset : *offsets_for_adjustment) {
1275
if (offset > utf16.length())
1276
--- a/tools/gn/src/base/strings/utf_offset_string_conversions.h
1277
+++ b/tools/gn/src/base/strings/utf_offset_string_conversions.h
1282
-#include <string_view>
1283
+#include <experimental/string_view>
1287
@@ -93,17 +93,17 @@ bool UTF8ToUTF16WithAdjustments(const ch
1288
std::u16string* output,
1289
base::OffsetAdjuster::Adjustments* adjustments);
1290
std::u16string UTF8ToUTF16WithAdjustments(
1291
- const std::string_view& utf8,
1292
+ const std::experimental::string_view& utf8,
1293
base::OffsetAdjuster::Adjustments* adjustments);
1294
// As above, but instead internally examines the adjustments and applies them
1295
// to |offsets_for_adjustment|. Input offsets greater than the length of the
1296
// input string will be set to std::u16string::npos. See comments by
1298
std::u16string UTF8ToUTF16AndAdjustOffsets(
1299
- const std::string_view& utf8,
1300
+ const std::experimental::string_view& utf8,
1301
std::vector<size_t>* offsets_for_adjustment);
1302
std::string UTF16ToUTF8AndAdjustOffsets(
1303
- const std::u16string_view& utf16,
1304
+ const std::experimental::u16string_view& utf16,
1305
std::vector<size_t>* offsets_for_adjustment);
1308
--- a/tools/gn/src/base/strings/utf_string_conversions.cc
1309
+++ b/tools/gn/src/base/strings/utf_string_conversions.cc
1314
-#include <string_view>
1315
+#include <experimental/string_view>
1317
#include "base/strings/string_util.h"
1318
#include "base/strings/utf_string_conversion_utils.h"
1319
@@ -157,10 +157,10 @@ bool UTFConversion(const InputString& sr
1320
// UTF16 <-> UTF8 --------------------------------------------------------------
1322
bool UTF8ToUTF16(const char* src, size_t src_len, std::u16string* output) {
1323
- return UTFConversion(std::string_view(src, src_len), output);
1324
+ return UTFConversion(std::experimental::string_view(src, src_len), output);
1327
-std::u16string UTF8ToUTF16(std::string_view utf8) {
1328
+std::u16string UTF8ToUTF16(std::experimental::string_view utf8) {
1330
// Ignore the success flag of this call, it will do the best it can for
1331
// invalid input, which is what we want here.
1332
@@ -169,10 +169,10 @@ std::u16string UTF8ToUTF16(std::string_v
1335
bool UTF16ToUTF8(const char16_t* src, size_t src_len, std::string* output) {
1336
- return UTFConversion(std::u16string_view(src, src_len), output);
1337
+ return UTFConversion(std::experimental::u16string_view(src, src_len), output);
1340
-std::string UTF16ToUTF8(std::u16string_view utf16) {
1341
+std::string UTF16ToUTF8(std::experimental::u16string_view utf16) {
1343
// Ignore the success flag of this call, it will do the best it can for
1344
// invalid input, which is what we want here.
1345
@@ -182,12 +182,12 @@ std::string UTF16ToUTF8(std::u16string_v
1347
// ASCII <-> UTF-16 -----------------------------------------------------------
1349
-std::u16string ASCIIToUTF16(std::string_view ascii) {
1350
+std::u16string ASCIIToUTF16(std::experimental::string_view ascii) {
1351
DCHECK(IsStringASCII(ascii)) << ascii;
1352
return std::u16string(ascii.begin(), ascii.end());
1355
-std::string UTF16ToASCII(std::u16string_view utf16) {
1356
+std::string UTF16ToASCII(std::experimental::u16string_view utf16) {
1357
DCHECK(IsStringASCII(utf16)) << UTF16ToUTF8(utf16);
1358
return std::string(utf16.begin(), utf16.end());
1360
--- a/tools/gn/src/base/strings/utf_string_conversions.h
1361
+++ b/tools/gn/src/base/strings/utf_string_conversions.h
1366
-#include <string_view>
1367
+#include <experimental/string_view>
1371
bool UTF8ToUTF16(const char* src, size_t src_len, std::u16string* output);
1372
-std::u16string UTF8ToUTF16(std::string_view utf8);
1373
+std::u16string UTF8ToUTF16(std::experimental::string_view utf8);
1374
bool UTF16ToUTF8(const char16_t* src, size_t src_len, std::string* output);
1375
-std::string UTF16ToUTF8(std::u16string_view utf16);
1376
+std::string UTF16ToUTF8(std::experimental::u16string_view utf16);
1378
// This converts an ASCII string, typically a hardcoded constant, to a UTF16
1380
-std::u16string ASCIIToUTF16(std::string_view ascii);
1381
+std::u16string ASCIIToUTF16(std::experimental::string_view ascii);
1383
// Converts to 7-bit ASCII by truncating. The result must be known to be ASCII
1385
-std::string UTF16ToASCII(std::u16string_view utf16);
1386
+std::string UTF16ToASCII(std::experimental::u16string_view utf16);
1390
--- a/tools/gn/src/base/values.h
1391
+++ b/tools/gn/src/base/values.h
1396
-#include <string_view>
1397
+#include <experimental/string_view>
1401
@@ -116,14 +116,14 @@ class Value {
1402
explicit Value(int in_int);
1404
// Value(const char*) and Value(const char16_t*) are required despite
1405
- // Value(std::string_view) and Value(std::u16string_view) because otherwise
1406
+ // Value(std::experimental::string_view) and Value(std::experimental::u16string_view) because otherwise
1407
// the compiler will choose the Value(bool) constructor for these arguments.
1408
// Value(std::string&&) allow for efficient move construction.
1409
explicit Value(const char* in_string);
1410
- explicit Value(std::string_view in_string);
1411
+ explicit Value(std::experimental::string_view in_string);
1412
explicit Value(std::string&& in_string) noexcept;
1413
explicit Value(const char16_t* in_string16);
1414
- explicit Value(std::u16string_view in_string16);
1415
+ explicit Value(std::experimental::u16string_view in_string16);
1417
explicit Value(const BlobStorage& in_blob);
1418
explicit Value(BlobStorage&& in_blob) noexcept;
1419
@@ -170,8 +170,8 @@ class Value {
1422
// auto* found = FindKey("foo");
1423
- Value* FindKey(std::string_view key);
1424
- const Value* FindKey(std::string_view key) const;
1425
+ Value* FindKey(std::experimental::string_view key);
1426
+ const Value* FindKey(std::experimental::string_view key) const;
1428
// |FindKeyOfType| is similar to |FindKey|, but it also requires the found
1429
// value to have type |type|. If no type is found, or the found value is of a
1430
@@ -182,8 +182,8 @@ class Value {
1433
// auto* found = FindKey("foo", Type::INTEGER);
1434
- Value* FindKeyOfType(std::string_view key, Type type);
1435
- const Value* FindKeyOfType(std::string_view key, Type type) const;
1436
+ Value* FindKeyOfType(std::experimental::string_view key, Type type);
1437
+ const Value* FindKeyOfType(std::experimental::string_view key, Type type) const;
1439
// |SetKey| looks up |key| in the underlying dictionary and sets the mapped
1440
// value to |value|. If |key| could not be found, a new element is inserted.
1441
@@ -192,7 +192,7 @@ class Value {
1444
// SetKey("foo", std::move(myvalue));
1445
- Value* SetKey(std::string_view key, Value value);
1446
+ Value* SetKey(std::experimental::string_view key, Value value);
1447
// This overload results in a performance improvement for std::string&&.
1448
Value* SetKey(std::string&& key, Value value);
1449
// This overload is necessary to avoid ambiguity for const char* arguments.
1450
@@ -206,7 +206,7 @@ class Value {
1453
// bool success = RemoveKey("foo");
1454
- bool RemoveKey(std::string_view key);
1455
+ bool RemoveKey(std::experimental::string_view key);
1457
// Searches a hierarchy of dictionary values for a given value. If a path
1458
// of dictionaries exist, returns the item at that path. If any of the path
1459
@@ -222,26 +222,26 @@ class Value {
1461
// auto* found = FindPath({"foo", "bar"});
1463
- // std::vector<std::string_view> components = ...
1464
+ // std::vector<std::experimental::string_view> components = ...
1465
// auto* found = FindPath(components);
1467
// Note: If there is only one component in the path, use FindKey() instead.
1468
- Value* FindPath(std::initializer_list<std::string_view> path);
1469
- Value* FindPath(span<const std::string_view> path);
1470
- const Value* FindPath(std::initializer_list<std::string_view> path) const;
1471
- const Value* FindPath(span<const std::string_view> path) const;
1472
+ Value* FindPath(std::initializer_list<std::experimental::string_view> path);
1473
+ Value* FindPath(span<const std::experimental::string_view> path);
1474
+ const Value* FindPath(std::initializer_list<std::experimental::string_view> path) const;
1475
+ const Value* FindPath(span<const std::experimental::string_view> path) const;
1477
// Like FindPath() but will only return the value if the leaf Value type
1478
// matches the given type. Will return nullptr otherwise.
1480
// Note: If there is only one component in the path, use FindKeyOfType()
1482
- Value* FindPathOfType(std::initializer_list<std::string_view> path,
1483
+ Value* FindPathOfType(std::initializer_list<std::experimental::string_view> path,
1485
- Value* FindPathOfType(span<const std::string_view> path, Type type);
1486
- const Value* FindPathOfType(std::initializer_list<std::string_view> path,
1487
+ Value* FindPathOfType(span<const std::experimental::string_view> path, Type type);
1488
+ const Value* FindPathOfType(std::initializer_list<std::experimental::string_view> path,
1490
- const Value* FindPathOfType(span<const std::string_view> path,
1491
+ const Value* FindPathOfType(span<const std::experimental::string_view> path,
1494
// Sets the given path, expanding and creating dictionary keys as necessary.
1495
@@ -256,12 +256,12 @@ class Value {
1497
// value.SetPath({"foo", "bar"}, std::move(myvalue));
1499
- // std::vector<std::string_view> components = ...
1500
+ // std::vector<std::experimental::string_view> components = ...
1501
// value.SetPath(components, std::move(myvalue));
1503
// Note: If there is only one component in the path, use SetKey() instead.
1504
- Value* SetPath(std::initializer_list<std::string_view> path, Value value);
1505
- Value* SetPath(span<const std::string_view> path, Value value);
1506
+ Value* SetPath(std::initializer_list<std::experimental::string_view> path, Value value);
1507
+ Value* SetPath(span<const std::experimental::string_view> path, Value value);
1509
// Tries to remove a Value at the given path.
1511
@@ -273,12 +273,12 @@ class Value {
1513
// bool success = value.RemovePath({"foo", "bar"});
1515
- // std::vector<std::string_view> components = ...
1516
+ // std::vector<std::experimental::string_view> components = ...
1517
// bool success = value.RemovePath(components);
1519
// Note: If there is only one component in the path, use RemoveKey() instead.
1520
- bool RemovePath(std::initializer_list<std::string_view> path);
1521
- bool RemovePath(span<const std::string_view> path);
1522
+ bool RemovePath(std::initializer_list<std::experimental::string_view> path);
1523
+ bool RemovePath(span<const std::experimental::string_view> path);
1525
using dict_iterator_proxy = detail::dict_iterator_proxy;
1526
using const_dict_iterator_proxy = detail::const_dict_iterator_proxy;
1527
@@ -308,7 +308,7 @@ class Value {
1528
bool GetAsString(std::string* out_value) const;
1529
bool GetAsString(std::u16string* out_value) const;
1530
bool GetAsString(const Value** out_value) const;
1531
- bool GetAsString(std::string_view* out_value) const;
1532
+ bool GetAsString(std::experimental::string_view* out_value) const;
1533
// ListValue::From is the equivalent for std::unique_ptr conversions.
1534
// DEPRECATED, use GetList() instead.
1535
bool GetAsList(ListValue** out_value);
1536
@@ -385,7 +385,7 @@ class DictionaryValue : public Value {
1538
// Returns true if the current dictionary has a value for the given key.
1539
// DEPRECATED, use Value::FindKey(key) instead.
1540
- bool HasKey(std::string_view key) const;
1541
+ bool HasKey(std::experimental::string_view key) const;
1543
// Returns the number of Values in this dictionary.
1544
size_t size() const { return dict_.size(); }
1545
@@ -405,29 +405,29 @@ class DictionaryValue : public Value {
1546
// to the path in that location. |in_value| must be non-null.
1547
// Returns a pointer to the inserted value.
1548
// DEPRECATED, use Value::SetPath(path, value) instead.
1549
- Value* Set(std::string_view path, std::unique_ptr<Value> in_value);
1550
+ Value* Set(std::experimental::string_view path, std::unique_ptr<Value> in_value);
1552
// Convenience forms of Set(). These methods will replace any existing
1553
// value at that path, even if it has a different type.
1554
// DEPRECATED, use Value::SetPath(path, Value(bool)) instead.
1555
- Value* SetBoolean(std::string_view path, bool in_value);
1556
+ Value* SetBoolean(std::experimental::string_view path, bool in_value);
1557
// DEPRECATED, use Value::SetPath(path, Value(int)) instead.
1558
- Value* SetInteger(std::string_view path, int in_value);
1559
- // DEPRECATED, use Value::SetPath(path, Value(std::string_view)) instead.
1560
- Value* SetString(std::string_view path, std::string_view in_value);
1561
+ Value* SetInteger(std::experimental::string_view path, int in_value);
1562
+ // DEPRECATED, use Value::SetPath(path, Value(std::experimental::string_view)) instead.
1563
+ Value* SetString(std::experimental::string_view path, std::experimental::string_view in_value);
1564
// DEPRECATED, use Value::SetPath(path, Value(const string& 16)) instead.
1565
- Value* SetString(std::string_view path, const std::u16string& in_value);
1566
+ Value* SetString(std::experimental::string_view path, const std::u16string& in_value);
1567
// DEPRECATED, use Value::SetPath(path, Value(Type::DICTIONARY)) instead.
1568
- DictionaryValue* SetDictionary(std::string_view path,
1569
+ DictionaryValue* SetDictionary(std::experimental::string_view path,
1570
std::unique_ptr<DictionaryValue> in_value);
1571
// DEPRECATED, use Value::SetPath(path, Value(Type::LIST)) instead.
1572
- ListValue* SetList(std::string_view path,
1573
+ ListValue* SetList(std::experimental::string_view path,
1574
std::unique_ptr<ListValue> in_value);
1576
// Like Set(), but without special treatment of '.'. This allows e.g. URLs to
1577
// be used as paths.
1578
// DEPRECATED, use Value::SetKey(key, value) instead.
1579
- Value* SetWithoutPathExpansion(std::string_view key,
1580
+ Value* SetWithoutPathExpansion(std::experimental::string_view key,
1581
std::unique_ptr<Value> in_value);
1583
// Gets the Value associated with the given path starting from this object.
1584
@@ -439,69 +439,69 @@ class DictionaryValue : public Value {
1585
// Note that the dictionary always owns the value that's returned.
1586
// |out_value| is optional and will only be set if non-NULL.
1587
// DEPRECATED, use Value::FindPath(path) instead.
1588
- bool Get(std::string_view path, const Value** out_value) const;
1589
+ bool Get(std::experimental::string_view path, const Value** out_value) const;
1590
// DEPRECATED, use Value::FindPath(path) instead.
1591
- bool Get(std::string_view path, Value** out_value);
1592
+ bool Get(std::experimental::string_view path, Value** out_value);
1594
// These are convenience forms of Get(). The value will be retrieved
1595
// and the return value will be true if the path is valid and the value at
1596
// the end of the path can be returned in the form specified.
1597
// |out_value| is optional and will only be set if non-NULL.
1598
// DEPRECATED, use Value::FindPath(path) and Value::GetBool() instead.
1599
- bool GetBoolean(std::string_view path, bool* out_value) const;
1600
+ bool GetBoolean(std::experimental::string_view path, bool* out_value) const;
1601
// DEPRECATED, use Value::FindPath(path) and Value::GetInt() instead.
1602
- bool GetInteger(std::string_view path, int* out_value) const;
1603
+ bool GetInteger(std::experimental::string_view path, int* out_value) const;
1604
// DEPRECATED, use Value::FindPath(path) and Value::GetString() instead.
1605
- bool GetString(std::string_view path, std::string* out_value) const;
1606
+ bool GetString(std::experimental::string_view path, std::string* out_value) const;
1607
// DEPRECATED, use Value::FindPath(path) and Value::GetString() instead.
1608
- bool GetString(std::string_view path, std::u16string* out_value) const;
1609
+ bool GetString(std::experimental::string_view path, std::u16string* out_value) const;
1610
// DEPRECATED, use Value::FindPath(path) and Value::GetString() instead.
1611
- bool GetStringASCII(std::string_view path, std::string* out_value) const;
1612
+ bool GetStringASCII(std::experimental::string_view path, std::string* out_value) const;
1613
// DEPRECATED, use Value::FindPath(path) and Value::GetBlob() instead.
1614
- bool GetBinary(std::string_view path, const Value** out_value) const;
1615
+ bool GetBinary(std::experimental::string_view path, const Value** out_value) const;
1616
// DEPRECATED, use Value::FindPath(path) and Value::GetBlob() instead.
1617
- bool GetBinary(std::string_view path, Value** out_value);
1618
+ bool GetBinary(std::experimental::string_view path, Value** out_value);
1619
// DEPRECATED, use Value::FindPath(path) and Value's Dictionary API instead.
1620
- bool GetDictionary(std::string_view path,
1621
+ bool GetDictionary(std::experimental::string_view path,
1622
const DictionaryValue** out_value) const;
1623
// DEPRECATED, use Value::FindPath(path) and Value's Dictionary API instead.
1624
- bool GetDictionary(std::string_view path, DictionaryValue** out_value);
1625
+ bool GetDictionary(std::experimental::string_view path, DictionaryValue** out_value);
1626
// DEPRECATED, use Value::FindPath(path) and Value::GetList() instead.
1627
- bool GetList(std::string_view path, const ListValue** out_value) const;
1628
+ bool GetList(std::experimental::string_view path, const ListValue** out_value) const;
1629
// DEPRECATED, use Value::FindPath(path) and Value::GetList() instead.
1630
- bool GetList(std::string_view path, ListValue** out_value);
1631
+ bool GetList(std::experimental::string_view path, ListValue** out_value);
1633
// Like Get(), but without special treatment of '.'. This allows e.g. URLs to
1634
// be used as paths.
1635
// DEPRECATED, use Value::FindKey(key) instead.
1636
- bool GetWithoutPathExpansion(std::string_view key,
1637
+ bool GetWithoutPathExpansion(std::experimental::string_view key,
1638
const Value** out_value) const;
1639
// DEPRECATED, use Value::FindKey(key) instead.
1640
- bool GetWithoutPathExpansion(std::string_view key, Value** out_value);
1641
+ bool GetWithoutPathExpansion(std::experimental::string_view key, Value** out_value);
1642
// DEPRECATED, use Value::FindKey(key) and Value::GetBool() instead.
1643
- bool GetBooleanWithoutPathExpansion(std::string_view key,
1644
+ bool GetBooleanWithoutPathExpansion(std::experimental::string_view key,
1645
bool* out_value) const;
1646
// DEPRECATED, use Value::FindKey(key) and Value::GetInt() instead.
1647
- bool GetIntegerWithoutPathExpansion(std::string_view key,
1648
+ bool GetIntegerWithoutPathExpansion(std::experimental::string_view key,
1649
int* out_value) const;
1650
// DEPRECATED, use Value::FindKey(key) and Value::GetString() instead.
1651
- bool GetStringWithoutPathExpansion(std::string_view key,
1652
+ bool GetStringWithoutPathExpansion(std::experimental::string_view key,
1653
std::string* out_value) const;
1654
// DEPRECATED, use Value::FindKey(key) and Value::GetString() instead.
1655
- bool GetStringWithoutPathExpansion(std::string_view key,
1656
+ bool GetStringWithoutPathExpansion(std::experimental::string_view key,
1657
std::u16string* out_value) const;
1658
// DEPRECATED, use Value::FindKey(key) and Value's Dictionary API instead.
1659
bool GetDictionaryWithoutPathExpansion(
1660
- std::string_view key,
1661
+ std::experimental::string_view key,
1662
const DictionaryValue** out_value) const;
1663
// DEPRECATED, use Value::FindKey(key) and Value's Dictionary API instead.
1664
- bool GetDictionaryWithoutPathExpansion(std::string_view key,
1665
+ bool GetDictionaryWithoutPathExpansion(std::experimental::string_view key,
1666
DictionaryValue** out_value);
1667
// DEPRECATED, use Value::FindKey(key) and Value::GetList() instead.
1668
- bool GetListWithoutPathExpansion(std::string_view key,
1669
+ bool GetListWithoutPathExpansion(std::experimental::string_view key,
1670
const ListValue** out_value) const;
1671
// DEPRECATED, use Value::FindKey(key) and Value::GetList() instead.
1672
- bool GetListWithoutPathExpansion(std::string_view key, ListValue** out_value);
1673
+ bool GetListWithoutPathExpansion(std::experimental::string_view key, ListValue** out_value);
1675
// Removes the Value with the specified path from this dictionary (or one
1676
// of its child dictionaries, if the path is more than just a local key).
1677
@@ -510,18 +510,18 @@ class DictionaryValue : public Value {
1678
// This method returns true if |path| is a valid path; otherwise it will
1679
// return false and the DictionaryValue object will be unchanged.
1680
// DEPRECATED, use Value::RemovePath(path) instead.
1681
- bool Remove(std::string_view path, std::unique_ptr<Value>* out_value);
1682
+ bool Remove(std::experimental::string_view path, std::unique_ptr<Value>* out_value);
1684
// Like Remove(), but without special treatment of '.'. This allows e.g. URLs
1685
// to be used as paths.
1686
// DEPRECATED, use Value::RemoveKey(key) instead.
1687
- bool RemoveWithoutPathExpansion(std::string_view key,
1688
+ bool RemoveWithoutPathExpansion(std::experimental::string_view key,
1689
std::unique_ptr<Value>* out_value);
1691
// Removes a path, clearing out all dictionaries on |path| that remain empty
1692
// after removing the value at |path|.
1693
// DEPRECATED, use Value::RemovePath(path) instead.
1694
- bool RemovePath(std::string_view path, std::unique_ptr<Value>* out_value);
1695
+ bool RemovePath(std::experimental::string_view path, std::unique_ptr<Value>* out_value);
1697
using Value::RemovePath; // DictionaryValue::RemovePath shadows otherwise.
1699
@@ -670,7 +670,7 @@ class ListValue : public Value {
1700
// DEPRECATED, use GetList()::emplace_back() instead.
1701
void AppendBoolean(bool in_value);
1702
void AppendInteger(int in_value);
1703
- void AppendString(std::string_view in_value);
1704
+ void AppendString(std::experimental::string_view in_value);
1705
void AppendString(const std::u16string& in_value);
1706
// DEPRECATED, use GetList()::emplace_back() in a loop instead.
1707
void AppendStrings(const std::vector<std::string>& in_values);
1708
--- a/tools/gn/src/base/win/win_util.h
1709
+++ b/tools/gn/src/base/win/win_util.h
1711
#define BASE_WIN_WIN_UTIL_H_
1714
-#include <string_view>
1715
+#include <experimental/string_view>
1719
--- a/tools/gn/src/gn/c_include_iterator.h
1720
+++ b/tools/gn/src/gn/c_include_iterator.h
1725
-#include <string_view>
1726
+#include <experimental/string_view>
1728
#include "base/macros.h"
1729
#include "gn/location.h"
1733
struct IncludeStringWithLocation {
1734
- std::string_view contents;
1735
+ std::experimental::string_view contents;
1736
LocationRange location;
1737
bool system_style_include = false;
1739
@@ -39,12 +39,12 @@ class CIncludeIterator {
1741
// Returns false on EOF, otherwise fills in the given line and the one-based
1742
// line number into *line_number;
1743
- bool GetNextLine(std::string_view* line, int* line_number);
1744
+ bool GetNextLine(std::experimental::string_view* line, int* line_number);
1746
const InputFile* input_file_;
1748
// This just points into input_file_.contents() for convenience.
1749
- std::string_view file_;
1750
+ std::experimental::string_view file_;
1752
// 0-based offset into the file.
1754
--- a/tools/gn/src/gn/commands.h
1755
+++ b/tools/gn/src/gn/commands.h
1760
-#include <string_view>
1761
+#include <experimental/string_view>
1764
#include "base/values.h"
1765
@@ -102,7 +102,7 @@ struct CommandInfo {
1766
CommandRunner runner;
1769
-using CommandInfoMap = std::map<std::string_view, CommandInfo>;
1770
+using CommandInfoMap = std::map<std::experimental::string_view, CommandInfo>;
1772
const CommandInfoMap& GetCommands();
1774
--- a/tools/gn/src/gn/escape.h
1775
+++ b/tools/gn/src/gn/escape.h
1777
#define TOOLS_GN_ESCAPE_H_
1780
-#include <string_view>
1781
+#include <experimental/string_view>
1785
@@ -66,14 +66,14 @@ struct EscapeOptions {
1786
// (if inhibit_quoting was set) quoted will be written to it. This value should
1787
// be initialized to false by the caller and will be written to only if it's
1788
// true (the common use-case is for chaining calls).
1789
-std::string EscapeString(const std::string_view& str,
1790
+std::string EscapeString(const std::experimental::string_view& str,
1791
const EscapeOptions& options,
1792
bool* needed_quoting);
1794
// Same as EscapeString but writes the results to the given stream, saving a
1796
void EscapeStringToStream(std::ostream& out,
1797
- const std::string_view& str,
1798
+ const std::experimental::string_view& str,
1799
const EscapeOptions& options);
1801
#endif // TOOLS_GN_ESCAPE_H_
1802
--- a/tools/gn/src/gn/filesystem_utils.h
1803
+++ b/tools/gn/src/gn/filesystem_utils.h
1808
-#include <string_view>
1809
+#include <experimental/string_view>
1811
#include "base/files/file_path.h"
1812
#include "gn/settings.h"
1813
@@ -20,7 +20,7 @@ std::string FilePathToUTF8(const base::F
1814
inline std::string FilePathToUTF8(const base::FilePath& path) {
1815
return FilePathToUTF8(path.value());
1817
-base::FilePath UTF8ToFilePath(const std::string_view& sp);
1818
+base::FilePath UTF8ToFilePath(const std::experimental::string_view& sp);
1820
// Extensions -----------------------------------------------------------------
1822
@@ -31,7 +31,7 @@ size_t FindExtensionOffset(const std::st
1824
// Returns a string piece pointing into the input string identifying the
1825
// extension. Note that the input pointer must outlive the output.
1826
-std::string_view FindExtension(const std::string* path);
1827
+std::experimental::string_view FindExtension(const std::string* path);
1829
// Filename parts -------------------------------------------------------------
1831
@@ -43,10 +43,10 @@ size_t FindFilenameOffset(const std::str
1832
// Returns a string piece pointing into the input string identifying the
1833
// file name (following the last slash, including the extension). Note that the
1834
// input pointer must outlive the output.
1835
-std::string_view FindFilename(const std::string* path);
1836
+std::experimental::string_view FindFilename(const std::string* path);
1838
// Like FindFilename but does not include the extension.
1839
-std::string_view FindFilenameNoExtension(const std::string* path);
1840
+std::experimental::string_view FindFilenameNoExtension(const std::string* path);
1842
// Removes everything after the last slash. The last slash, if any, will be
1844
@@ -67,11 +67,11 @@ bool EndsWithSlash(const std::string& s)
1845
// Returns a string piece pointing into the input string identifying the
1846
// directory name of the given path, including the last slash. Note that the
1847
// input pointer must outlive the output.
1848
-std::string_view FindDir(const std::string* path);
1849
+std::experimental::string_view FindDir(const std::string* path);
1851
// Returns the substring identifying the last component of the dir, or the
1852
// empty substring if none. For example "//foo/bar/" -> "bar".
1853
-std::string_view FindLastDirComponent(const SourceDir& dir);
1854
+std::experimental::string_view FindLastDirComponent(const SourceDir& dir);
1856
// Returns true if the given string is in the given output dir. This is pretty
1857
// stupid and doesn't handle "." and "..", etc., it is designed for a sanity
1858
@@ -96,12 +96,12 @@ bool EnsureStringIsInOutputDir(const Sou
1859
// Returns true if the input string is absolute. Double-slashes at the
1860
// beginning are treated as source-relative paths. On Windows, this handles
1861
// paths of both the native format: "C:/foo" and ours "/C:/foo"
1862
-bool IsPathAbsolute(const std::string_view& path);
1863
+bool IsPathAbsolute(const std::experimental::string_view& path);
1865
// Returns true if the input string is source-absolute. Source-absolute
1866
// paths begin with two forward slashes and resolve as if they are
1867
// relative to the source root.
1868
-bool IsPathSourceAbsolute(const std::string_view& path);
1869
+bool IsPathSourceAbsolute(const std::experimental::string_view& path);
1871
// Given an absolute path, checks to see if is it is inside the source root.
1872
// If it is, fills a source-absolute path into the given output and returns
1873
@@ -112,8 +112,8 @@ bool IsPathSourceAbsolute(const std::str
1874
// ("/C:/"). The source root can end with a slash or not.
1876
// Note that this does not attempt to normalize slashes in the output.
1877
-bool MakeAbsolutePathRelativeIfPossible(const std::string_view& source_root,
1878
- const std::string_view& path,
1879
+bool MakeAbsolutePathRelativeIfPossible(const std::experimental::string_view& source_root,
1880
+ const std::experimental::string_view& path,
1883
// Given two absolute paths |base| and |target|, returns a relative path to
1884
@@ -134,7 +134,7 @@ base::FilePath MakeAbsoluteFilePathRelat
1885
// a leading slash. Otherwise, |path| will retain its relativity. |source_root|
1886
// must not end with a slash.
1887
void NormalizePath(std::string* path,
1888
- const std::string_view& source_root = std::string_view());
1889
+ const std::experimental::string_view& source_root = std::experimental::string_view());
1891
// Converts slashes to backslashes for Windows. Keeps the string unchanged
1892
// for other systems.
1893
@@ -150,7 +150,7 @@ void ConvertPathToSystem(std::string* pa
1894
std::string RebasePath(
1895
const std::string& input,
1896
const SourceDir& dest_dir,
1897
- const std::string_view& source_root = std::string_view());
1898
+ const std::experimental::string_view& source_root = std::experimental::string_view());
1900
// Resolves a file or dir name (parameter input) relative to
1901
// value directory. Will return an empty SourceDir/File on error
1902
@@ -169,7 +169,7 @@ template <typename StringType>
1903
std::string ResolveRelative(const StringType& input,
1904
const std::string& value,
1906
- const std::string_view& source_root);
1907
+ const std::experimental::string_view& source_root);
1909
// Resolves source file or directory relative to some given source root. Returns
1910
// an empty file path on error.
1911
--- a/tools/gn/src/gn/functions.h
1912
+++ b/tools/gn/src/gn/functions.h
1917
-#include <string_view>
1918
+#include <experimental/string_view>
1922
@@ -441,7 +441,7 @@ struct FunctionInfo {
1926
-using FunctionInfoMap = std::map<std::string_view, FunctionInfo>;
1927
+using FunctionInfoMap = std::map<std::experimental::string_view, FunctionInfo>;
1929
// Returns the mapping of all built-in functions.
1930
const FunctionInfoMap& GetFunctions();
1931
--- a/tools/gn/src/gn/header_checker.h
1932
+++ b/tools/gn/src/gn/header_checker.h
1937
-#include <string_view>
1938
+#include <experimental/string_view>
1941
#include "base/atomic_ref_count.h"
1942
--- a/tools/gn/src/gn/label_pattern.h
1943
+++ b/tools/gn/src/gn/label_pattern.h
1945
#ifndef TOOLS_GN_LABEL_PATTERN_H_
1946
#define TOOLS_GN_LABEL_PATTERN_H_
1948
-#include <string_view>
1949
+#include <experimental/string_view>
1951
#include "gn/label.h"
1952
#include "gn/source_dir.h"
1953
@@ -30,7 +30,7 @@ class LabelPattern {
1955
LabelPattern(Type type,
1956
const SourceDir& dir,
1957
- const std::string_view& name,
1958
+ const std::experimental::string_view& name,
1959
const Label& toolchain_label);
1960
LabelPattern(const LabelPattern& other);
1962
@@ -38,7 +38,7 @@ class LabelPattern {
1963
// Converts the given input string to a pattern. This does special stuff
1964
// to treat the pattern as a label. Sets the error on failure.
1965
static LabelPattern GetPattern(const SourceDir& current_dir,
1966
- const std::string_view& source_root,
1967
+ const std::experimental::string_view& source_root,
1971
--- a/tools/gn/src/gn/lib_file.h
1972
+++ b/tools/gn/src/gn/lib_file.h
1975
#include <algorithm>
1977
-#include <string_view>
1978
+#include <experimental/string_view>
1980
#include "gn/source_file.h"
1982
@@ -19,7 +19,7 @@ class LibFile {
1984
LibFile() = default;
1986
- explicit LibFile(const std::string_view& lib_name);
1987
+ explicit LibFile(const std::experimental::string_view& lib_name);
1988
explicit LibFile(const SourceFile& source_file);
1990
bool is_source_file() const { return name_.empty(); }
1991
--- a/tools/gn/src/gn/path_output.h
1992
+++ b/tools/gn/src/gn/path_output.h
1997
-#include <string_view>
1998
+#include <experimental/string_view>
2000
#include "base/macros.h"
2001
#include "gn/escape.h"
2002
@@ -35,7 +35,7 @@ class PathOutput {
2005
PathOutput(const SourceDir& current_dir,
2006
- const std::string_view& source_root,
2007
+ const std::experimental::string_view& source_root,
2008
EscapingMode escaping);
2011
@@ -71,13 +71,13 @@ class PathOutput {
2013
// Backend for WriteFile and WriteDir. This appends the given file or
2014
// directory string to the file.
2015
- void WritePathStr(std::ostream& out, const std::string_view& str) const;
2016
+ void WritePathStr(std::ostream& out, const std::experimental::string_view& str) const;
2019
// Takes the given string and writes it out, appending to the inverse
2020
// current dir. This assumes leading slashes have been trimmed.
2021
void WriteSourceRelativeString(std::ostream& out,
2022
- const std::string_view& str) const;
2023
+ const std::experimental::string_view& str) const;
2025
SourceDir current_dir_;
2027
--- a/tools/gn/src/gn/source_dir.h
2028
+++ b/tools/gn/src/gn/source_dir.h
2031
#include <algorithm>
2033
-#include <string_view>
2034
+#include <experimental/string_view>
2036
#include "base/files/file_path.h"
2037
#include "base/logging.h"
2038
@@ -47,7 +47,7 @@ class SourceDir {
2042
- const std::string_view& source_root = std::string_view(),
2043
+ const std::experimental::string_view& source_root = std::experimental::string_view(),
2044
const std::string* v_value = nullptr) const;
2046
// Like ResolveRelativeAs above, but allows to produce result
2047
@@ -58,13 +58,13 @@ class SourceDir {
2048
const Value& blame_input_value,
2049
const StringType& input_value,
2051
- const std::string_view& source_root = std::string_view()) const;
2052
+ const std::experimental::string_view& source_root = std::experimental::string_view()) const;
2054
// Wrapper for ResolveRelativeAs.
2055
SourceFile ResolveRelativeFile(
2058
- const std::string_view& source_root = std::string_view()) const;
2059
+ const std::experimental::string_view& source_root = std::experimental::string_view()) const;
2061
// Wrapper for ResolveRelativeAs.
2062
template <typename StringType>
2063
@@ -72,7 +72,7 @@ class SourceDir {
2064
const Value& blame_input_value,
2065
const StringType& input_value,
2067
- const std::string_view& source_root = std::string_view()) const {
2068
+ const std::experimental::string_view& source_root = std::experimental::string_view()) const {
2070
ret.value_ = ResolveRelativeAs<StringType>(false, blame_input_value,
2071
input_value, err, source_root);
2072
@@ -84,7 +84,7 @@ class SourceDir {
2073
SourceDir ResolveRelativeDir(
2076
- const std::string_view& source_root = std::string_view()) const;
2077
+ const std::experimental::string_view& source_root = std::experimental::string_view()) const;
2079
// Resolves this source file relative to some given source root. Returns
2080
// an empty file path on error.
2081
@@ -110,19 +110,19 @@ class SourceDir {
2083
// This function asserts that the directory is actually source-absolute. The
2084
// return value points into our buffer.
2085
- std::string_view SourceAbsoluteWithOneSlash() const {
2086
+ std::experimental::string_view SourceAbsoluteWithOneSlash() const {
2087
CHECK(is_source_absolute());
2088
- return std::string_view(&value_[1], value_.size() - 1);
2089
+ return std::experimental::string_view(&value_[1], value_.size() - 1);
2092
// Returns a path that does not end with a slash.
2094
// This function simply returns the reference to the value if the path is a
2095
// root, e.g. "/" or "//".
2096
- std::string_view SourceWithNoTrailingSlash() const {
2097
+ std::experimental::string_view SourceWithNoTrailingSlash() const {
2098
if (value_.size() > 2)
2099
- return std::string_view(&value_[0], value_.size() - 1);
2100
- return std::string_view(value_);
2101
+ return std::experimental::string_view(&value_[0], value_.size() - 1);
2102
+ return std::experimental::string_view(value_);
2105
void SwapValue(std::string* v);
2106
--- a/tools/gn/src/gn/source_file.h
2107
+++ b/tools/gn/src/gn/source_file.h
2110
#include <algorithm>
2112
-#include <string_view>
2113
+#include <experimental/string_view>
2115
#include "base/containers/flat_set.h"
2116
#include "base/files/file_path.h"
2117
@@ -82,9 +82,9 @@ class SourceFile {
2119
// This function asserts that the file is actually source-absolute. The
2120
// return value points into our buffer.
2121
- std::string_view SourceAbsoluteWithOneSlash() const {
2122
+ std::experimental::string_view SourceAbsoluteWithOneSlash() const {
2123
CHECK(is_source_absolute());
2124
- return std::string_view(&value()[1], value().size() - 1);
2125
+ return std::experimental::string_view(&value()[1], value().size() - 1);
2128
bool operator==(const SourceFile& other) const {
2129
--- a/tools/gn/src/gn/standard_out.cc
2130
+++ b/tools/gn/src/gn/standard_out.cc
2135
-#include <string_view>
2136
+#include <experimental/string_view>
2139
#include "base/command_line.h"
2140
--- a/tools/gn/src/gn/string_utils.h
2141
+++ b/tools/gn/src/gn/string_utils.h
2143
#define TOOLS_GN_STRING_UTILS_H_
2146
-#include <string_view>
2147
+#include <experimental/string_view>
2151
@@ -14,7 +14,7 @@ class Scope;
2155
-inline std::string operator+(const std::string& a, const std::string_view& b) {
2156
+inline std::string operator+(const std::string& a, const std::experimental::string_view& b) {
2158
ret.reserve(a.size() + b.size());
2160
@@ -22,7 +22,7 @@ inline std::string operator+(const std::
2164
-inline std::string operator+(const std::string_view& a, const std::string& b) {
2165
+inline std::string operator+(const std::experimental::string_view& a, const std::string& b) {
2167
ret.reserve(a.size() + b.size());
2168
ret.assign(a.data(), a.size());
2169
@@ -40,15 +40,15 @@ bool ExpandStringLiteral(Scope* scope,
2170
// Returns the minimum number of inserts, deleted, and replacements of
2171
// characters needed to transform s1 to s2, or max_edit_distance + 1 if
2172
// transforming s1 into s2 isn't possible in at most max_edit_distance steps.
2173
-size_t EditDistance(const std::string_view& s1,
2174
- const std::string_view& s2,
2175
+size_t EditDistance(const std::experimental::string_view& s1,
2176
+ const std::experimental::string_view& s2,
2177
size_t max_edit_distance);
2179
// Given a string |text| and a vector of correctly-spelled strings |words|,
2180
// returns the first string in |words| closest to |text|, or an empty
2181
-// std::string_view if none of the strings in |words| is close.
2182
-std::string_view SpellcheckString(const std::string_view& text,
2183
- const std::vector<std::string_view>& words);
2184
+// std::experimental::string_view if none of the strings in |words| is close.
2185
+std::experimental::string_view SpellcheckString(const std::experimental::string_view& text,
2186
+ const std::vector<std::experimental::string_view>& words);
2188
// Reads stdin until end-of-data and returns what it read.
2189
std::string ReadStdin();
2190
--- a/tools/gn/src/gn/switches.h
2191
+++ b/tools/gn/src/gn/switches.h
2193
#define TOOLS_GN_SWITCHES_H_
2196
-#include <string_view>
2197
+#include <experimental/string_view>
2199
namespace switches {
2201
@@ -18,7 +18,7 @@ struct SwitchInfo {
2202
const char* long_help;
2205
-using SwitchInfoMap = std::map<std::string_view, SwitchInfo>;
2206
+using SwitchInfoMap = std::map<std::experimental::string_view, SwitchInfo>;
2208
// Returns the mapping of all global switches.
2209
const SwitchInfoMap& GetSwitches();
2210
--- a/tools/gn/src/gn/tokenizer.h
2211
+++ b/tools/gn/src/gn/tokenizer.h
2216
-#include <string_view>
2217
+#include <experimental/string_view>
2220
#include "base/macros.h"
2221
@@ -40,11 +40,11 @@ class Tokenizer {
2223
// This is a helper function for error output so that the tokenizer's
2224
// notion of lines can be used elsewhere.
2225
- static size_t ByteOffsetOfNthLine(const std::string_view& buf, int n);
2226
+ static size_t ByteOffsetOfNthLine(const std::experimental::string_view& buf, int n);
2228
// Returns true if the given offset of the string piece counts as a newline.
2229
// The offset must be in the buffer.
2230
- static bool IsNewline(const std::string_view& buffer, size_t offset);
2231
+ static bool IsNewline(const std::experimental::string_view& buffer, size_t offset);
2233
static bool IsIdentifierFirstChar(char c);
2235
@@ -92,7 +92,7 @@ class Tokenizer {
2236
std::vector<Token> tokens_;
2238
const InputFile* input_file_;
2239
- const std::string_view input_;
2240
+ const std::experimental::string_view input_;
2242
WhitespaceTransform whitespace_transform_;
2243
size_t cur_ = 0; // Byte offset into input buffer.
2244
--- a/tools/gn/src/gn/toolchain.h
2245
+++ b/tools/gn/src/gn/toolchain.h
2247
#define TOOLS_GN_TOOLCHAIN_H_
2250
-#include <string_view>
2251
+#include <experimental/string_view>
2253
#include "base/logging.h"
2254
#include "gn/item.h"
2255
--- a/tools/gn/src/gn/variables.h
2256
+++ b/tools/gn/src/gn/variables.h
2258
#define TOOLS_GN_VARIABLES_H_
2261
-#include <string_view>
2262
+#include <experimental/string_view>
2264
namespace variables {
2266
@@ -352,7 +352,7 @@ struct VariableInfo {
2270
-using VariableInfoMap = std::map<std::string_view, VariableInfo>;
2271
+using VariableInfoMap = std::map<std::experimental::string_view, VariableInfo>;
2273
// Returns the built-in readonly variables.
2274
// Note: this is used only for help so this getter is not threadsafe.
2275
--- a/tools/gn/src/gn/visibility.cc
2276
+++ b/tools/gn/src/gn/visibility.cc
2278
#include "gn/visibility.h"
2281
-#include <string_view>
2282
+#include <experimental/string_view>
2284
#include "base/strings/string_util.h"
2285
#include "base/values.h"
2286
@@ -22,7 +22,7 @@ Visibility::Visibility() = default;
2287
Visibility::~Visibility() = default;
2289
bool Visibility::Set(const SourceDir& current_dir,
2290
- const std::string_view& source_root,
2291
+ const std::experimental::string_view& source_root,
2295
--- a/tools/gn/src/gn/xml_element_writer.h
2296
+++ b/tools/gn/src/gn/xml_element_writer.h
2301
-#include <string_view>
2302
+#include <experimental/string_view>
2308
// Vector of XML attribute key-value pairs.
2310
- : public std::vector<std::pair<std::string_view, std::string_view>> {
2311
+ : public std::vector<std::pair<std::experimental::string_view, std::experimental::string_view>> {
2314
- XmlAttributes(const std::string_view& attr_key,
2315
- const std::string_view& attr_value);
2316
+ XmlAttributes(const std::experimental::string_view& attr_key,
2317
+ const std::experimental::string_view& attr_value);
2319
- XmlAttributes& add(const std::string_view& attr_key,
2320
- const std::string_view& attr_value);
2321
+ XmlAttributes& add(const std::experimental::string_view& attr_key,
2322
+ const std::experimental::string_view& attr_value);
2325
// Helper class for writing XML elements. New XML element is started in
2326
@@ -54,7 +54,7 @@ class XmlElementWriter {
2327
~XmlElementWriter();
2329
// Writes arbitrary XML element text.
2330
- void Text(const std::string_view& content);
2331
+ void Text(const std::experimental::string_view& content);
2333
// Starts new XML sub-element. Caller must ensure that parent element outlives
2335
--- a/tools/gn/src/gn/scope.h
2336
+++ b/tools/gn/src/gn/scope.h
2337
@@ -38,7 +38,7 @@ class Template;
2338
// variables. So you should use a non-const containing scope whenever possible.
2341
- using KeyValueMap = std::map<std::string_view, Value>;
2342
+ using KeyValueMap = std::map<std::experimental::string_view, Value>;
2343
// Holds an owning list of Items.
2344
using ItemVector = std::vector<std::unique_ptr<Item>>;
2346
@@ -59,7 +59,7 @@ class Scope {
2347
// Returns a non-null value if the given value can be programmatically
2348
// generated, or NULL if there is none.
2349
virtual const Value* GetProgrammaticValue(
2350
- const std::string_view& ident) = 0;
2351
+ const std::experimental::string_view& ident) = 0;
2355
@@ -135,11 +135,11 @@ class Scope {
2356
// found_in_scope is set to the scope that contains the definition of the
2357
// ident. If the value was provided programmatically (like host_cpu),
2358
// found_in_scope will be set to null.
2359
- const Value* GetValue(const std::string_view& ident, bool counts_as_used);
2360
- const Value* GetValue(const std::string_view& ident) const;
2361
- const Value* GetValueWithScope(const std::string_view& ident,
2362
+ const Value* GetValue(const std::experimental::string_view& ident, bool counts_as_used);
2363
+ const Value* GetValue(const std::experimental::string_view& ident) const;
2364
+ const Value* GetValueWithScope(const std::experimental::string_view& ident,
2365
const Scope** found_in_scope) const;
2366
- const Value* GetValueWithScope(const std::string_view& ident,
2367
+ const Value* GetValueWithScope(const std::experimental::string_view& ident,
2368
bool counts_as_used,
2369
const Scope** found_in_scope);
2371
@@ -165,28 +165,28 @@ class Scope {
2373
// The 6 should get set on the nested scope rather than modify the value
2374
// in the outer one.
2375
- Value* GetMutableValue(const std::string_view& ident,
2376
+ Value* GetMutableValue(const std::experimental::string_view& ident,
2377
SearchNested search_mode,
2378
bool counts_as_used);
2380
- // Returns the std::string_view used to identify the value. This string piece
2381
+ // Returns the std::experimental::string_view used to identify the value. This string piece
2382
// will have the same contents as "ident" passed in, but may point to a
2383
- // different underlying buffer. This is useful because this std::string_view
2384
+ // different underlying buffer. This is useful because this std::experimental::string_view
2385
// is static and won't be deleted for the life of the program, so it can be
2386
// used as keys in places that may outlive a temporary. It will return an
2387
// empty string for programmatic and nonexistant values.
2388
- std::string_view GetStorageKey(const std::string_view& ident) const;
2389
+ std::experimental::string_view GetStorageKey(const std::experimental::string_view& ident) const;
2391
// The set_node indicates the statement that caused the set, for displaying
2392
// errors later. Returns a pointer to the value in the current scope (a copy
2393
// is made for storage).
2394
- Value* SetValue(const std::string_view& ident,
2395
+ Value* SetValue(const std::experimental::string_view& ident,
2397
const ParseNode* set_node);
2399
// Removes the value with the given identifier if it exists on the current
2400
// scope. This does not search recursive scopes. Does nothing if not found.
2401
- void RemoveIdentifier(const std::string_view& ident);
2402
+ void RemoveIdentifier(const std::experimental::string_view& ident);
2404
// Removes from this scope all identifiers and templates that are considered
2406
@@ -200,17 +200,17 @@ class Scope {
2407
const Template* GetTemplate(const std::string& name) const;
2409
// Marks the given identifier as (un)used in the current scope.
2410
- void MarkUsed(const std::string_view& ident);
2411
+ void MarkUsed(const std::experimental::string_view& ident);
2413
void MarkAllUsed(const std::set<std::string>& excluded_values);
2414
- void MarkUnused(const std::string_view& ident);
2415
+ void MarkUnused(const std::experimental::string_view& ident);
2417
// Checks to see if the scope has a var set that hasn't been used. This is
2418
// called before replacing the var with a different one. It does not check
2419
// containing scopes.
2421
// If the identifier is present but hasnn't been used, return true.
2422
- bool IsSetButUnused(const std::string_view& ident) const;
2423
+ bool IsSetButUnused(const std::experimental::string_view& ident) const;
2425
// Checks the scope to see if any values were set but not used, and fills in
2426
// the error and returns false if they were.
2427
@@ -338,7 +338,7 @@ class Scope {
2431
- using RecordMap = std::unordered_map<std::string_view, Record>;
2432
+ using RecordMap = std::unordered_map<std::experimental::string_view, Record>;
2434
void AddProvider(ProgrammaticProvider* p);
2435
void RemoveProvider(ProgrammaticProvider* p);
2436
--- a/tools/gn/src/gn/args.h
2437
+++ b/tools/gn/src/gn/args.h
2438
@@ -37,7 +37,7 @@ class Args {
2439
bool has_override; // True indicates override_value is valid.
2440
Value override_value; // From .gn or the current build's "gn args".
2442
- using ValueWithOverrideMap = std::map<std::string_view, ValueWithOverride>;
2443
+ using ValueWithOverrideMap = std::map<std::experimental::string_view, ValueWithOverride>;
2446
Args(const Args& other);
2447
--- a/tools/gn/src/gn/label.h
2448
+++ b/tools/gn/src/gn/label.h
2449
@@ -24,18 +24,18 @@ class Label {
2450
// Makes a label given an already-separated out path and name.
2451
// See also Resolve().
2452
Label(const SourceDir& dir,
2453
- const std::string_view& name,
2454
+ const std::experimental::string_view& name,
2455
const SourceDir& toolchain_dir,
2456
- const std::string_view& toolchain_name);
2457
+ const std::experimental::string_view& toolchain_name);
2459
// Makes a label with an empty toolchain.
2460
- Label(const SourceDir& dir, const std::string_view& name);
2461
+ Label(const SourceDir& dir, const std::experimental::string_view& name);
2463
// Resolves a string from a build file that may be relative to the
2464
// current directory into a fully qualified label. On failure returns an
2465
// is_null() label and sets the error.
2466
static Label Resolve(const SourceDir& current_dir,
2467
- const std::string_view& source_root,
2468
+ const std::experimental::string_view& source_root,
2469
const Label& current_toolchain,
2472
--- a/tools/gn/src/gn/parse_tree.h
2473
+++ b/tools/gn/src/gn/parse_tree.h
2474
@@ -113,7 +113,7 @@ class ParseNode {
2475
// given type (and value).
2476
base::Value CreateJSONNode(const char* type) const;
2477
base::Value CreateJSONNode(const char* type,
2478
- const std::string_view& value) const;
2479
+ const std::experimental::string_view& value) const;
2482
// Helper function for CreateJSONNode.
2483
--- a/tools/gn/src/gn/scope_per_file_provider.h
2484
+++ b/tools/gn/src/gn/scope_per_file_provider.h
2485
@@ -21,7 +21,7 @@ class ScopePerFileProvider : public Scop
2486
~ScopePerFileProvider() override;
2488
// ProgrammaticProvider implementation.
2489
- const Value* GetProgrammaticValue(const std::string_view& ident) override;
2490
+ const Value* GetProgrammaticValue(const std::experimental::string_view& ident) override;
2493
const Value* GetCurrentToolchain();
2494
--- a/tools/gn/src/base/strings/string_split.cc
2495
+++ b/tools/gn/src/base/strings/string_split.cc
2496
@@ -16,13 +16,13 @@ namespace {
2498
// Returns either the ASCII or UTF-16 whitespace.
2499
template <typename char_type>
2500
-std::basic_string_view<char_type> WhitespaceForType();
2501
+std::experimental::basic_string_view<char_type> WhitespaceForType();
2503
-std::u16string_view WhitespaceForType<char16_t>() {
2504
+std::experimental::u16string_view WhitespaceForType<char16_t>() {
2505
return kWhitespaceUTF16;
2508
-std::string_view WhitespaceForType<char>() {
2509
+std::experimental::string_view WhitespaceForType<char>() {
2510
return kWhitespaceASCII;
2513
@@ -30,37 +30,37 @@ std::string_view WhitespaceForType<char>
2514
// since this is the common case and can be made faster. This could have been
2515
// done with template specialization too, but would have been less clear.
2517
-// There is no corresponding FindFirstNotOf because std::string_view already
2518
+// There is no corresponding FindFirstNotOf because std::experimental::string_view already
2519
// implements these different versions that do the optimized searching.
2520
-size_t FindFirstOf(std::string_view piece, char c, size_t pos) {
2521
+size_t FindFirstOf(std::experimental::string_view piece, char c, size_t pos) {
2522
return piece.find(c, pos);
2524
-size_t FindFirstOf(std::u16string_view piece, char16_t c, size_t pos) {
2525
+size_t FindFirstOf(std::experimental::u16string_view piece, char16_t c, size_t pos) {
2526
return piece.find(c, pos);
2528
-size_t FindFirstOf(std::string_view piece,
2529
- std::string_view one_of,
2530
+size_t FindFirstOf(std::experimental::string_view piece,
2531
+ std::experimental::string_view one_of,
2533
return piece.find_first_of(one_of, pos);
2535
-size_t FindFirstOf(std::u16string_view piece,
2536
- std::u16string_view one_of,
2537
+size_t FindFirstOf(std::experimental::u16string_view piece,
2538
+ std::experimental::u16string_view one_of,
2540
return piece.find_first_of(one_of, pos);
2543
// General string splitter template. Can take 8- or 16-bit input, can produce
2544
-// the corresponding string or std::string_view output, and can take single- or
2545
+// the corresponding string or std::experimental::string_view output, and can take single- or
2546
// multiple-character delimiters.
2548
// DelimiterType is either a character (Str::value_type) or a string piece of
2549
-// multiple characters (std::basic_string_view<char>). std::string_view has a
2550
+// multiple characters (std::experimental::basic_string_view<char>). std::experimental::string_view has a
2551
// version of find for both of these cases, and the single-character version is
2552
// the most common and can be implemented faster, which is why this is a
2554
template <typename char_type, typename OutputStringType, typename DelimiterType>
2555
static std::vector<OutputStringType> SplitStringT(
2556
- std::basic_string_view<char_type> str,
2557
+ std::experimental::basic_string_view<char_type> str,
2558
DelimiterType delimiter,
2559
WhitespaceHandling whitespace,
2560
SplitResult result_type) {
2561
@@ -68,7 +68,7 @@ static std::vector<OutputStringType> Spl
2565
- using ViewType = std::basic_string_view<char_type>;
2566
+ using ViewType = std::experimental::basic_string_view<char_type>;
2569
while (start != ViewType::npos) {
2570
@@ -92,7 +92,7 @@ static std::vector<OutputStringType> Spl
2574
-bool AppendStringKeyValue(std::string_view input,
2575
+bool AppendStringKeyValue(std::experimental::string_view input,
2577
StringPairs* result) {
2578
// Always append a new item regardless of success (it might be empty). The
2579
@@ -105,28 +105,28 @@ bool AppendStringKeyValue(std::string_vi
2580
if (end_key_pos == std::string::npos) {
2581
return false; // No delimiter.
2583
- result_pair.first.assign(input.substr(0, end_key_pos));
2584
+ result_pair.first.assign(input.substr(0, end_key_pos).data(), end_key_pos);
2586
// Find the value string.
2587
- std::string_view remains =
2588
+ std::experimental::string_view remains =
2589
input.substr(end_key_pos, input.size() - end_key_pos);
2590
size_t begin_value_pos = remains.find_first_not_of(delimiter);
2591
- if (begin_value_pos == std::string_view::npos) {
2592
+ if (begin_value_pos == std::experimental::string_view::npos) {
2593
return false; // No value.
2595
result_pair.second.assign(
2596
- remains.substr(begin_value_pos, remains.size() - begin_value_pos));
2597
+ remains.substr(begin_value_pos, remains.size() - begin_value_pos).data(), remains.size() - begin_value_pos);
2602
template <typename char_type, typename OutputStringType>
2603
-void SplitStringUsingSubstrT(std::basic_string_view<char_type> input,
2604
- std::basic_string_view<char_type> delimiter,
2605
+void SplitStringUsingSubstrT(std::experimental::basic_string_view<char_type> input,
2606
+ std::experimental::basic_string_view<char_type> delimiter,
2607
WhitespaceHandling whitespace,
2608
SplitResult result_type,
2609
std::vector<OutputStringType>* result) {
2610
- using Piece = std::basic_string_view<char_type>;
2611
+ using Piece = std::experimental::basic_string_view<char_type>;
2612
using size_type = typename Piece::size_type;
2615
@@ -147,68 +147,68 @@ void SplitStringUsingSubstrT(std::basic_
2619
-std::vector<std::string> SplitString(std::string_view input,
2620
- std::string_view separators,
2621
+std::vector<std::string> SplitString(std::experimental::string_view input,
2622
+ std::experimental::string_view separators,
2623
WhitespaceHandling whitespace,
2624
SplitResult result_type) {
2625
if (separators.size() == 1) {
2626
return SplitStringT<char, std::string, char>(input, separators[0],
2627
whitespace, result_type);
2629
- return SplitStringT<char, std::string, std::string_view>(
2630
+ return SplitStringT<char, std::string, std::experimental::string_view>(
2631
input, separators, whitespace, result_type);
2634
-std::vector<std::u16string> SplitString(std::u16string_view input,
2635
- std::u16string_view separators,
2636
+std::vector<std::u16string> SplitString(std::experimental::u16string_view input,
2637
+ std::experimental::u16string_view separators,
2638
WhitespaceHandling whitespace,
2639
SplitResult result_type) {
2640
if (separators.size() == 1) {
2641
return SplitStringT<char16_t, std::u16string, char16_t>(
2642
input, separators[0], whitespace, result_type);
2644
- return SplitStringT<char16_t, std::u16string, std::u16string_view>(
2645
+ return SplitStringT<char16_t, std::u16string, std::experimental::u16string_view>(
2646
input, separators, whitespace, result_type);
2649
-std::vector<std::string_view> SplitStringPiece(std::string_view input,
2650
- std::string_view separators,
2651
+std::vector<std::experimental::string_view> SplitStringPiece(std::experimental::string_view input,
2652
+ std::experimental::string_view separators,
2653
WhitespaceHandling whitespace,
2654
SplitResult result_type) {
2655
if (separators.size() == 1) {
2656
- return SplitStringT<char, std::string_view, char>(input, separators[0],
2657
+ return SplitStringT<char, std::experimental::string_view, char>(input, separators[0],
2658
whitespace, result_type);
2660
- return SplitStringT<char, std::string_view, std::string_view>(
2661
+ return SplitStringT<char, std::experimental::string_view, std::experimental::string_view>(
2662
input, separators, whitespace, result_type);
2665
-std::vector<std::u16string_view> SplitStringPiece(
2666
- std::u16string_view input,
2667
- std::u16string_view separators,
2668
+std::vector<std::experimental::u16string_view> SplitStringPiece(
2669
+ std::experimental::u16string_view input,
2670
+ std::experimental::u16string_view separators,
2671
WhitespaceHandling whitespace,
2672
SplitResult result_type) {
2673
if (separators.size() == 1) {
2674
- return SplitStringT<char16_t, std::u16string_view, char16_t>(
2675
+ return SplitStringT<char16_t, std::experimental::u16string_view, char16_t>(
2676
input, separators[0], whitespace, result_type);
2678
- return SplitStringT<char16_t, std::u16string_view, std::u16string_view>(
2679
+ return SplitStringT<char16_t, std::experimental::u16string_view, std::experimental::u16string_view>(
2680
input, separators, whitespace, result_type);
2683
-bool SplitStringIntoKeyValuePairs(std::string_view input,
2684
+bool SplitStringIntoKeyValuePairs(std::experimental::string_view input,
2685
char key_value_delimiter,
2686
char key_value_pair_delimiter,
2687
StringPairs* key_value_pairs) {
2688
key_value_pairs->clear();
2690
- std::vector<std::string_view> pairs =
2691
+ std::vector<std::experimental::string_view> pairs =
2692
SplitStringPiece(input, std::string(1, key_value_pair_delimiter),
2693
TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY);
2694
key_value_pairs->reserve(pairs.size());
2696
bool success = true;
2697
- for (const std::string_view& pair : pairs) {
2698
+ for (const std::experimental::string_view& pair : pairs) {
2699
if (!AppendStringKeyValue(pair, key_value_delimiter, key_value_pairs)) {
2700
// Don't return here, to allow for pairs without associated
2701
// value or key; just record that the split failed.
2702
@@ -219,8 +219,8 @@ bool SplitStringIntoKeyValuePairs(std::s
2705
std::vector<std::u16string> SplitStringUsingSubstr(
2706
- std::u16string_view input,
2707
- std::u16string_view delimiter,
2708
+ std::experimental::u16string_view input,
2709
+ std::experimental::u16string_view delimiter,
2710
WhitespaceHandling whitespace,
2711
SplitResult result_type) {
2712
std::vector<std::u16string> result;
2713
@@ -228,8 +228,8 @@ std::vector<std::u16string> SplitStringU
2717
-std::vector<std::string> SplitStringUsingSubstr(std::string_view input,
2718
- std::string_view delimiter,
2719
+std::vector<std::string> SplitStringUsingSubstr(std::experimental::string_view input,
2720
+ std::experimental::string_view delimiter,
2721
WhitespaceHandling whitespace,
2722
SplitResult result_type) {
2723
std::vector<std::string> result;
2724
@@ -237,22 +237,22 @@ std::vector<std::string> SplitStringUsin
2728
-std::vector<std::u16string_view> SplitStringPieceUsingSubstr(
2729
- std::u16string_view input,
2730
- std::u16string_view delimiter,
2731
+std::vector<std::experimental::u16string_view> SplitStringPieceUsingSubstr(
2732
+ std::experimental::u16string_view input,
2733
+ std::experimental::u16string_view delimiter,
2734
WhitespaceHandling whitespace,
2735
SplitResult result_type) {
2736
- std::vector<std::u16string_view> result;
2737
+ std::vector<std::experimental::u16string_view> result;
2738
SplitStringUsingSubstrT(input, delimiter, whitespace, result_type, &result);
2742
-std::vector<std::string_view> SplitStringPieceUsingSubstr(
2743
- std::string_view input,
2744
- std::string_view delimiter,
2745
+std::vector<std::experimental::string_view> SplitStringPieceUsingSubstr(
2746
+ std::experimental::string_view input,
2747
+ std::experimental::string_view delimiter,
2748
WhitespaceHandling whitespace,
2749
SplitResult result_type) {
2750
- std::vector<std::string_view> result;
2751
+ std::vector<std::experimental::string_view> result;
2752
SplitStringUsingSubstrT(input, delimiter, whitespace, result_type, &result);
2755
--- a/tools/gn/src/base/strings/string_util.cc
2756
+++ b/tools/gn/src/base/strings/string_util.cc
2757
@@ -90,7 +90,7 @@ namespace {
2759
template <typename StringType>
2760
StringType ToLowerASCIIImpl(
2761
- std::basic_string_view<typename StringType::value_type> str) {
2762
+ std::experimental::basic_string_view<typename StringType::value_type> str) {
2764
ret.reserve(str.size());
2765
for (size_t i = 0; i < str.size(); i++)
2766
@@ -100,7 +100,7 @@ StringType ToLowerASCIIImpl(
2768
template <typename StringType>
2769
StringType ToUpperASCIIImpl(
2770
- std::basic_string_view<typename StringType::value_type> str) {
2771
+ std::experimental::basic_string_view<typename StringType::value_type> str) {
2773
ret.reserve(str.size());
2774
for (size_t i = 0; i < str.size(); i++)
2775
@@ -110,26 +110,26 @@ StringType ToUpperASCIIImpl(
2779
-std::string ToLowerASCII(std::string_view str) {
2780
+std::string ToLowerASCII(std::experimental::string_view str) {
2781
return ToLowerASCIIImpl<std::string>(str);
2784
-std::u16string ToLowerASCII(std::u16string_view str) {
2785
+std::u16string ToLowerASCII(std::experimental::u16string_view str) {
2786
return ToLowerASCIIImpl<std::u16string>(str);
2789
-std::string ToUpperASCII(std::string_view str) {
2790
+std::string ToUpperASCII(std::experimental::string_view str) {
2791
return ToUpperASCIIImpl<std::string>(str);
2794
-std::u16string ToUpperASCII(std::u16string_view str) {
2795
+std::u16string ToUpperASCII(std::experimental::u16string_view str) {
2796
return ToUpperASCIIImpl<std::u16string>(str);
2799
template <class StringType>
2800
int CompareCaseInsensitiveASCIIT(
2801
- std::basic_string_view<typename StringType::value_type> a,
2802
- std::basic_string_view<typename StringType::value_type> b) {
2803
+ std::experimental::basic_string_view<typename StringType::value_type> a,
2804
+ std::experimental::basic_string_view<typename StringType::value_type> b) {
2805
// Find the first characters that aren't equal and compare them. If the end
2806
// of one of the strings is found before a nonequal character, the lengths
2807
// of the strings are compared.
2808
@@ -154,21 +154,21 @@ int CompareCaseInsensitiveASCIIT(
2812
-int CompareCaseInsensitiveASCII(std::string_view a, std::string_view b) {
2813
+int CompareCaseInsensitiveASCII(std::experimental::string_view a, std::experimental::string_view b) {
2814
return CompareCaseInsensitiveASCIIT<std::string>(a, b);
2817
-int CompareCaseInsensitiveASCII(std::u16string_view a, std::u16string_view b) {
2818
+int CompareCaseInsensitiveASCII(std::experimental::u16string_view a, std::experimental::u16string_view b) {
2819
return CompareCaseInsensitiveASCIIT<std::u16string>(a, b);
2822
-bool EqualsCaseInsensitiveASCII(std::string_view a, std::string_view b) {
2823
+bool EqualsCaseInsensitiveASCII(std::experimental::string_view a, std::experimental::string_view b) {
2824
if (a.length() != b.length())
2826
return CompareCaseInsensitiveASCIIT<std::string>(a, b) == 0;
2829
-bool EqualsCaseInsensitiveASCII(std::u16string_view a, std::u16string_view b) {
2830
+bool EqualsCaseInsensitiveASCII(std::experimental::u16string_view a, std::experimental::u16string_view b) {
2831
if (a.length() != b.length())
2833
return CompareCaseInsensitiveASCIIT<std::u16string>(a, b) == 0;
2834
@@ -177,49 +177,49 @@ bool EqualsCaseInsensitiveASCII(std::u16
2835
template <class StringType>
2837
const StringType& input,
2838
- std::basic_string_view<typename StringType::value_type> find_any_of_these,
2839
- std::basic_string_view<typename StringType::value_type> replace_with,
2840
+ std::experimental::basic_string_view<typename StringType::value_type> find_any_of_these,
2841
+ std::experimental::basic_string_view<typename StringType::value_type> replace_with,
2842
StringType* output);
2844
bool ReplaceChars(const std::u16string& input,
2845
- std::u16string_view replace_chars,
2846
+ std::experimental::u16string_view replace_chars,
2847
const std::u16string& replace_with,
2848
std::u16string* output) {
2849
- return ReplaceCharsT(input, replace_chars, std::u16string_view(replace_with),
2850
+ return ReplaceCharsT(input, replace_chars, std::experimental::u16string_view(replace_with),
2854
bool ReplaceChars(const std::string& input,
2855
- std::string_view replace_chars,
2856
+ std::experimental::string_view replace_chars,
2857
const std::string& replace_with,
2858
std::string* output) {
2859
- return ReplaceCharsT(input, replace_chars, std::string_view(replace_with),
2860
+ return ReplaceCharsT(input, replace_chars, std::experimental::string_view(replace_with),
2864
bool RemoveChars(const std::u16string& input,
2865
- std::u16string_view remove_chars,
2866
+ std::experimental::u16string_view remove_chars,
2867
std::u16string* output) {
2868
- return ReplaceCharsT(input, remove_chars, std::u16string_view(), output);
2869
+ return ReplaceCharsT(input, remove_chars, std::experimental::u16string_view(), output);
2872
bool RemoveChars(const std::string& input,
2873
- std::string_view remove_chars,
2874
+ std::experimental::string_view remove_chars,
2875
std::string* output) {
2876
- return ReplaceCharsT(input, remove_chars, std::string_view(), output);
2877
+ return ReplaceCharsT(input, remove_chars, std::experimental::string_view(), output);
2880
template <typename Str>
2881
TrimPositions TrimStringT(
2883
- std::basic_string_view<typename Str::value_type> trim_chars,
2884
+ std::experimental::basic_string_view<typename Str::value_type> trim_chars,
2885
TrimPositions positions,
2887
// Find the edges of leading/trailing whitespace as desired. Need to use
2888
- // a std::string_view version of input to be able to call find* on it with the
2889
- // std::string_view version of trim_chars (normally the trim_chars will be a
2890
+ // a std::experimental::string_view version of input to be able to call find* on it with the
2891
+ // std::experimental::string_view version of trim_chars (normally the trim_chars will be a
2892
// constant so avoid making a copy).
2893
- std::basic_string_view<typename Str::value_type> input_piece(input);
2894
+ std::experimental::basic_string_view<typename Str::value_type> input_piece(input);
2895
const size_t last_char = input.length() - 1;
2896
const size_t first_good_char = (positions & TRIM_LEADING)
2897
? input_piece.find_first_not_of(trim_chars)
2898
@@ -248,26 +248,26 @@ TrimPositions TrimStringT(
2901
bool TrimString(const std::u16string& input,
2902
- std::u16string_view trim_chars,
2903
+ std::experimental::u16string_view trim_chars,
2904
std::u16string* output) {
2905
return TrimStringT(input, trim_chars, TRIM_ALL, output) != TRIM_NONE;
2908
bool TrimString(const std::string& input,
2909
- std::string_view trim_chars,
2910
+ std::experimental::string_view trim_chars,
2911
std::string* output) {
2912
return TrimStringT(input, trim_chars, TRIM_ALL, output) != TRIM_NONE;
2915
template <typename char_type>
2916
-std::basic_string_view<char_type> TrimStringPieceT(
2917
- std::basic_string_view<char_type> input,
2918
- std::basic_string_view<char_type> trim_chars,
2919
+std::experimental::basic_string_view<char_type> TrimStringPieceT(
2920
+ std::experimental::basic_string_view<char_type> input,
2921
+ std::experimental::basic_string_view<char_type> trim_chars,
2922
TrimPositions positions) {
2924
(positions & TRIM_LEADING) ? input.find_first_not_of(trim_chars) : 0;
2925
- if (begin == std::basic_string_view<char_type>::npos)
2926
- return std::basic_string_view<char_type>(); // All trimmed.
2927
+ if (begin == std::experimental::basic_string_view<char_type>::npos)
2928
+ return std::experimental::basic_string_view<char_type>(); // All trimmed.
2930
size_t end = (positions & TRIM_TRAILING)
2931
? input.find_last_not_of(trim_chars) + 1
2932
@@ -275,14 +275,14 @@ std::basic_string_view<char_type> TrimSt
2933
return input.substr(begin, end - begin);
2936
-std::u16string_view TrimString(std::u16string_view input,
2937
- std::u16string_view trim_chars,
2938
+std::experimental::u16string_view TrimString(std::experimental::u16string_view input,
2939
+ std::experimental::u16string_view trim_chars,
2940
TrimPositions positions) {
2941
return TrimStringPieceT(input, trim_chars, positions);
2944
-std::string_view TrimString(std::string_view input,
2945
- std::string_view trim_chars,
2946
+std::experimental::string_view TrimString(std::experimental::string_view input,
2947
+ std::experimental::string_view trim_chars,
2948
TrimPositions positions) {
2949
return TrimStringPieceT(input, trim_chars, positions);
2951
@@ -326,26 +326,26 @@ void TruncateUTF8ToByteSize(const std::s
2952
TrimPositions TrimWhitespace(const std::u16string& input,
2953
TrimPositions positions,
2954
std::u16string* output) {
2955
- return TrimStringT(input, std::u16string_view(kWhitespaceUTF16), positions,
2956
+ return TrimStringT(input, std::experimental::u16string_view(kWhitespaceUTF16), positions,
2960
-std::u16string_view TrimWhitespace(std::u16string_view input,
2961
+std::experimental::u16string_view TrimWhitespace(std::experimental::u16string_view input,
2962
TrimPositions positions) {
2963
- return TrimStringPieceT(input, std::u16string_view(kWhitespaceUTF16),
2964
+ return TrimStringPieceT(input, std::experimental::u16string_view(kWhitespaceUTF16),
2968
TrimPositions TrimWhitespaceASCII(const std::string& input,
2969
TrimPositions positions,
2970
std::string* output) {
2971
- return TrimStringT(input, std::string_view(kWhitespaceASCII), positions,
2972
+ return TrimStringT(input, std::experimental::string_view(kWhitespaceASCII), positions,
2976
-std::string_view TrimWhitespaceASCII(std::string_view input,
2977
+std::experimental::string_view TrimWhitespaceASCII(std::experimental::string_view input,
2978
TrimPositions positions) {
2979
- return TrimStringPieceT(input, std::string_view(kWhitespaceASCII), positions);
2980
+ return TrimStringPieceT(input, std::experimental::string_view(kWhitespaceASCII), positions);
2983
template <typename STR>
2984
@@ -399,13 +399,13 @@ std::string CollapseWhitespaceASCII(cons
2985
return CollapseWhitespaceT(text, trim_sequences_with_line_breaks);
2988
-bool ContainsOnlyChars(std::string_view input, std::string_view characters) {
2989
- return input.find_first_not_of(characters) == std::string_view::npos;
2990
+bool ContainsOnlyChars(std::experimental::string_view input, std::experimental::string_view characters) {
2991
+ return input.find_first_not_of(characters) == std::experimental::string_view::npos;
2994
-bool ContainsOnlyChars(std::u16string_view input,
2995
- std::u16string_view characters) {
2996
- return input.find_first_not_of(characters) == std::u16string_view::npos;
2997
+bool ContainsOnlyChars(std::experimental::u16string_view input,
2998
+ std::experimental::u16string_view characters) {
2999
+ return input.find_first_not_of(characters) == std::experimental::u16string_view::npos;
3002
template <class Char>
3003
@@ -438,15 +438,15 @@ inline bool DoIsStringASCII(const Char*
3004
return !(all_char_bits & non_ascii_bit_mask);
3007
-bool IsStringASCII(std::string_view str) {
3008
+bool IsStringASCII(std::experimental::string_view str) {
3009
return DoIsStringASCII(str.data(), str.length());
3012
-bool IsStringASCII(std::u16string_view str) {
3013
+bool IsStringASCII(std::experimental::u16string_view str) {
3014
return DoIsStringASCII(str.data(), str.length());
3017
-bool IsStringUTF8(std::string_view str) {
3018
+bool IsStringUTF8(std::experimental::string_view str) {
3019
const char* src = str.data();
3020
int32_t src_len = static_cast<int32_t>(str.length());
3021
int32_t char_index = 0;
3022
@@ -461,7 +461,7 @@ bool IsStringUTF8(std::string_view str)
3025
// Implementation note: Normally this function will be called with a hardcoded
3026
-// constant for the lowercase_ascii parameter. Constructing a std::string_view
3027
+// constant for the lowercase_ascii parameter. Constructing a std::experimental::string_view
3028
// from a C constant requires running strlen, so the result will be two passes
3029
// through the buffers, one to file the length of lowercase_ascii, and one to
3030
// compare each letter.
3031
@@ -474,11 +474,11 @@ bool IsStringUTF8(std::string_view str)
3033
// The hardcoded strings are typically very short so it doesn't matter, and the
3034
// string piece gives additional flexibility for the caller (doesn't have to be
3035
-// null terminated) so we choose the std::string_view route.
3036
+// null terminated) so we choose the std::experimental::string_view route.
3037
template <typename Str>
3038
static inline bool DoLowerCaseEqualsASCII(
3039
- std::basic_string_view<typename Str::value_type> str,
3040
- std::string_view lowercase_ascii) {
3041
+ std::experimental::basic_string_view<typename Str::value_type> str,
3042
+ std::experimental::string_view lowercase_ascii) {
3043
if (str.size() != lowercase_ascii.size())
3045
for (size_t i = 0; i < str.size(); i++) {
3046
@@ -488,30 +488,30 @@ static inline bool DoLowerCaseEqualsASCI
3050
-bool LowerCaseEqualsASCII(std::string_view str,
3051
- std::string_view lowercase_ascii) {
3052
+bool LowerCaseEqualsASCII(std::experimental::string_view str,
3053
+ std::experimental::string_view lowercase_ascii) {
3054
return DoLowerCaseEqualsASCII<std::string>(str, lowercase_ascii);
3057
-bool LowerCaseEqualsASCII(std::u16string_view str,
3058
- std::string_view lowercase_ascii) {
3059
+bool LowerCaseEqualsASCII(std::experimental::u16string_view str,
3060
+ std::experimental::string_view lowercase_ascii) {
3061
return DoLowerCaseEqualsASCII<std::u16string>(str, lowercase_ascii);
3064
-bool EqualsASCII(std::u16string_view str, std::string_view ascii) {
3065
+bool EqualsASCII(std::experimental::u16string_view str, std::experimental::string_view ascii) {
3066
if (str.length() != ascii.length())
3068
return std::equal(ascii.begin(), ascii.end(), str.begin());
3071
template <typename char_type>
3072
-bool StartsWithT(std::basic_string_view<char_type> str,
3073
- std::basic_string_view<char_type> search_for,
3074
+bool StartsWithT(std::experimental::basic_string_view<char_type> str,
3075
+ std::experimental::basic_string_view<char_type> search_for,
3076
CompareCase case_sensitivity) {
3077
if (search_for.size() > str.size())
3080
- std::basic_string_view<char_type> source = str.substr(0, search_for.size());
3081
+ std::experimental::basic_string_view<char_type> source = str.substr(0, search_for.size());
3083
switch (case_sensitivity) {
3084
case CompareCase::SENSITIVE:
3085
@@ -527,26 +527,26 @@ bool StartsWithT(std::basic_string_view<
3089
-bool StartsWith(std::string_view str,
3090
- std::string_view search_for,
3091
+bool StartsWith(std::experimental::string_view str,
3092
+ std::experimental::string_view search_for,
3093
CompareCase case_sensitivity) {
3094
return StartsWithT(str, search_for, case_sensitivity);
3097
-bool StartsWith(std::u16string_view str,
3098
- std::u16string_view search_for,
3099
+bool StartsWith(std::experimental::u16string_view str,
3100
+ std::experimental::u16string_view search_for,
3101
CompareCase case_sensitivity) {
3102
return StartsWithT(str, search_for, case_sensitivity);
3105
template <typename Str>
3106
-bool EndsWithT(std::basic_string_view<typename Str::value_type> str,
3107
- std::basic_string_view<typename Str::value_type> search_for,
3108
+bool EndsWithT(std::experimental::basic_string_view<typename Str::value_type> str,
3109
+ std::experimental::basic_string_view<typename Str::value_type> search_for,
3110
CompareCase case_sensitivity) {
3111
if (search_for.size() > str.size())
3114
- std::basic_string_view<typename Str::value_type> source =
3115
+ std::experimental::basic_string_view<typename Str::value_type> source =
3116
str.substr(str.size() - search_for.size(), search_for.size());
3118
switch (case_sensitivity) {
3119
@@ -564,14 +564,14 @@ bool EndsWithT(std::basic_string_view<ty
3123
-bool EndsWith(std::string_view str,
3124
- std::string_view search_for,
3125
+bool EndsWith(std::experimental::string_view str,
3126
+ std::experimental::string_view search_for,
3127
CompareCase case_sensitivity) {
3128
return EndsWithT<std::string>(str, search_for, case_sensitivity);
3131
-bool EndsWith(std::u16string_view str,
3132
- std::u16string_view search_for,
3133
+bool EndsWith(std::experimental::u16string_view str,
3134
+ std::experimental::u16string_view search_for,
3135
CompareCase case_sensitivity) {
3136
return EndsWithT<std::u16string>(str, search_for, case_sensitivity);
3138
@@ -624,7 +624,7 @@ std::u16string FormatBytesUnlocalized(in
3139
// A Matcher for DoReplaceMatchesAfterOffset() that matches substrings.
3140
template <class StringType>
3141
struct SubstringMatcher {
3142
- std::basic_string_view<typename StringType::value_type> find_this;
3143
+ std::experimental::basic_string_view<typename StringType::value_type> find_this;
3145
size_t Find(const StringType& input, size_t pos) {
3146
return input.find(find_this.data(), pos, find_this.length());
3147
@@ -635,7 +635,7 @@ struct SubstringMatcher {
3148
// A Matcher for DoReplaceMatchesAfterOffset() that matches single characters.
3149
template <class StringType>
3150
struct CharacterMatcher {
3151
- std::basic_string_view<typename StringType::value_type> find_any_of_these;
3152
+ std::experimental::basic_string_view<typename StringType::value_type> find_any_of_these;
3154
size_t Find(const StringType& input, size_t pos) {
3155
return input.find_first_of(find_any_of_these.data(), pos,
3156
@@ -656,7 +656,7 @@ bool DoReplaceMatchesAfterOffset(
3158
size_t initial_offset,
3160
- std::basic_string_view<typename StringType::value_type> replace_with,
3161
+ std::experimental::basic_string_view<typename StringType::value_type> replace_with,
3162
ReplaceType replace_type) {
3163
using CharTraits = typename StringType::traits_type;
3165
@@ -798,8 +798,8 @@ bool DoReplaceMatchesAfterOffset(
3166
template <class StringType>
3168
const StringType& input,
3169
- std::basic_string_view<typename StringType::value_type> find_any_of_these,
3170
- std::basic_string_view<typename StringType::value_type> replace_with,
3171
+ std::experimental::basic_string_view<typename StringType::value_type> find_any_of_these,
3172
+ std::experimental::basic_string_view<typename StringType::value_type> replace_with,
3173
StringType* output) {
3174
// Commonly, this is called with output and input being the same string; in
3175
// that case, this assignment is inexpensive.
3176
@@ -812,8 +812,8 @@ bool ReplaceCharsT(
3178
void ReplaceFirstSubstringAfterOffset(std::u16string* str,
3179
size_t start_offset,
3180
- std::u16string_view find_this,
3181
- std::u16string_view replace_with) {
3182
+ std::experimental::u16string_view find_this,
3183
+ std::experimental::u16string_view replace_with) {
3184
DoReplaceMatchesAfterOffset(str, start_offset,
3185
SubstringMatcher<std::u16string>{find_this},
3186
replace_with, ReplaceType::REPLACE_FIRST);
3187
@@ -821,8 +821,8 @@ void ReplaceFirstSubstringAfterOffset(st
3189
void ReplaceFirstSubstringAfterOffset(std::string* str,
3190
size_t start_offset,
3191
- std::string_view find_this,
3192
- std::string_view replace_with) {
3193
+ std::experimental::string_view find_this,
3194
+ std::experimental::string_view replace_with) {
3195
DoReplaceMatchesAfterOffset(str, start_offset,
3196
SubstringMatcher<std::string>{find_this},
3197
replace_with, ReplaceType::REPLACE_FIRST);
3198
@@ -830,8 +830,8 @@ void ReplaceFirstSubstringAfterOffset(st
3200
void ReplaceSubstringsAfterOffset(std::u16string* str,
3201
size_t start_offset,
3202
- std::u16string_view find_this,
3203
- std::u16string_view replace_with) {
3204
+ std::experimental::u16string_view find_this,
3205
+ std::experimental::u16string_view replace_with) {
3206
DoReplaceMatchesAfterOffset(str, start_offset,
3207
SubstringMatcher<std::u16string>{find_this},
3208
replace_with, ReplaceType::REPLACE_ALL);
3209
@@ -839,8 +839,8 @@ void ReplaceSubstringsAfterOffset(std::u
3211
void ReplaceSubstringsAfterOffset(std::string* str,
3212
size_t start_offset,
3213
- std::string_view find_this,
3214
- std::string_view replace_with) {
3215
+ std::experimental::string_view find_this,
3216
+ std::experimental::string_view replace_with) {
3217
DoReplaceMatchesAfterOffset(str, start_offset,
3218
SubstringMatcher<std::string>{find_this},
3219
replace_with, ReplaceType::REPLACE_ALL);
3220
@@ -873,7 +873,7 @@ char16_t* WriteInto(std::u16string* str,
3221
template <typename char_type, typename list_type>
3222
static std::basic_string<char_type> JoinStringT(
3223
const list_type& parts,
3224
- std::basic_string_view<char_type> sep) {
3225
+ std::experimental::basic_string_view<char_type> sep) {
3226
if (parts.size() == 0)
3227
return std::basic_string<char_type>();
3229
@@ -887,12 +887,12 @@ static std::basic_string<char_type> Join
3231
auto iter = parts.begin();
3232
DCHECK(iter != parts.end());
3233
- result.append(*iter);
3234
+ result.append(iter->data(), iter->size());
3237
for (; iter != parts.end(); ++iter) {
3238
- result.append(sep);
3239
- result.append(*iter);
3240
+ result.append(sep.data(), sep.size());
3241
+ result.append(iter->data(), iter->size());
3244
// Sanity-check that we pre-allocated correctly.
3245
@@ -902,12 +902,12 @@ static std::basic_string<char_type> Join
3248
std::string JoinString(const std::vector<std::string>& parts,
3249
- std::string_view separator) {
3250
+ std::experimental::string_view separator) {
3251
return JoinStringT(parts, separator);
3254
std::u16string JoinString(const std::vector<std::u16string>& parts,
3255
- std::u16string_view separator) {
3256
+ std::experimental::u16string_view separator) {
3257
return JoinStringT(parts, separator);
3260
@@ -916,23 +916,23 @@ std::u16string JoinString(const std::vec
3261
#pragma optimize("", on)
3264
-std::string JoinString(const std::vector<std::string_view>& parts,
3265
- std::string_view separator) {
3266
+std::string JoinString(const std::vector<std::experimental::string_view>& parts,
3267
+ std::experimental::string_view separator) {
3268
return JoinStringT(parts, separator);
3271
-std::u16string JoinString(const std::vector<std::u16string_view>& parts,
3272
- std::u16string_view separator) {
3273
+std::u16string JoinString(const std::vector<std::experimental::u16string_view>& parts,
3274
+ std::experimental::u16string_view separator) {
3275
return JoinStringT(parts, separator);
3278
-std::string JoinString(std::initializer_list<std::string_view> parts,
3279
- std::string_view separator) {
3280
+std::string JoinString(std::initializer_list<std::experimental::string_view> parts,
3281
+ std::experimental::string_view separator) {
3282
return JoinStringT(parts, separator);
3285
-std::u16string JoinString(std::initializer_list<std::u16string_view> parts,
3286
- std::u16string_view separator) {
3287
+std::u16string JoinString(std::initializer_list<std::experimental::u16string_view> parts,
3288
+ std::experimental::u16string_view separator) {
3289
return JoinStringT(parts, separator);
3292
@@ -998,7 +998,7 @@ std::u16string ReplaceStringPlaceholders
3293
return DoReplaceStringPlaceholders(format_string, subst, offsets);
3296
-std::string ReplaceStringPlaceholders(std::string_view format_string,
3297
+std::string ReplaceStringPlaceholders(std::experimental::string_view format_string,
3298
const std::vector<std::string>& subst,
3299
std::vector<size_t>* offsets) {
3300
return DoReplaceStringPlaceholders(format_string, subst, offsets);
3301
--- a/tools/gn/src/base/containers/span.h
3302
+++ b/tools/gn/src/base/containers/span.h
3303
@@ -88,7 +88,7 @@ using EnableIfSpanCompatibleContainer =
3304
// own the underlying memory, so care must be taken to ensure that a span does
3305
// not outlive the backing store.
3307
-// span is somewhat analogous to std::string_view, but with arbitrary element
3308
+// span is somewhat analogous to std::experimental::string_view, but with arbitrary element
3309
// types, allowing mutation if T is non-const.
3311
// span is implicitly convertible from C++ arrays, as well as most [1]
3312
--- a/tools/gn/src/base/files/file_util_posix.cc
3313
+++ b/tools/gn/src/base/files/file_util_posix.cc
3314
@@ -143,7 +143,7 @@ bool CopyFileContents(File* infile, File
3315
// Appends |mode_char| to |mode| before the optional character set encoding; see
3316
// https://www.gnu.org/software/libc/manual/html_node/Opening-Streams.html for
3318
-std::string AppendModeCharacter(std::string_view mode, char mode_char) {
3319
+std::string AppendModeCharacter(std::experimental::string_view mode, char mode_char) {
3320
std::string result(mode);
3321
size_t comma_pos = result.find(',');
3322
result.insert(comma_pos == std::string::npos ? result.length() : comma_pos, 1,
3323
@@ -332,7 +332,7 @@ bool ExecutableExistsInPath(Environment*
3327
- for (const std::string_view& cur_path :
3328
+ for (const std::experimental::string_view& cur_path :
3329
SplitStringPiece(path, ":", KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY)) {
3330
FilePath file(cur_path);
3332
--- a/tools/gn/src/base/json/json_reader.cc
3333
+++ b/tools/gn/src/base/json/json_reader.cc
3334
@@ -40,7 +40,7 @@ JSONReader::JSONReader(int options, int
3335
JSONReader::~JSONReader() = default;
3338
-std::unique_ptr<Value> JSONReader::Read(std::string_view json,
3339
+std::unique_ptr<Value> JSONReader::Read(std::experimental::string_view json,
3342
internal::JSONParser parser(options, max_depth);
3343
@@ -50,7 +50,7 @@ std::unique_ptr<Value> JSONReader::Read(
3346
std::unique_ptr<Value> JSONReader::ReadAndReturnError(
3347
- std::string_view json,
3348
+ std::experimental::string_view json,
3350
int* error_code_out,
3351
std::string* error_msg_out,
3352
@@ -102,7 +102,7 @@ std::string JSONReader::ErrorCodeToStrin
3353
return std::string();
3356
-std::unique_ptr<Value> JSONReader::ReadToValue(std::string_view json) {
3357
+std::unique_ptr<Value> JSONReader::ReadToValue(std::experimental::string_view json) {
3358
std::optional<Value> value = parser_->Parse(json);
3359
return value ? std::make_unique<Value>(std::move(*value)) : nullptr;
3361
--- a/tools/gn/src/base/json/string_escape.cc
3362
+++ b/tools/gn/src/base/json/string_escape.cc
3363
@@ -116,40 +116,40 @@ bool EscapeJSONStringImpl(const S& str,
3367
-bool EscapeJSONString(std::string_view str,
3368
+bool EscapeJSONString(std::experimental::string_view str,
3370
std::string* dest) {
3371
return EscapeJSONStringImpl(str, put_in_quotes, dest);
3374
-bool EscapeJSONString(std::u16string_view str,
3375
+bool EscapeJSONString(std::experimental::u16string_view str,
3377
std::string* dest) {
3378
return EscapeJSONStringImpl(str, put_in_quotes, dest);
3381
-std::string GetQuotedJSONString(std::string_view str) {
3382
+std::string GetQuotedJSONString(std::experimental::string_view str) {
3384
bool ok = EscapeJSONStringImpl(str, true, &dest);
3389
-std::string GetQuotedJSONString(std::u16string_view str) {
3390
+std::string GetQuotedJSONString(std::experimental::u16string_view str) {
3392
bool ok = EscapeJSONStringImpl(str, true, &dest);
3397
-std::string EscapeBytesAsInvalidJSONString(std::string_view str,
3398
+std::string EscapeBytesAsInvalidJSONString(std::experimental::string_view str,
3399
bool put_in_quotes) {
3403
dest.push_back('"');
3405
- for (std::string_view::const_iterator it = str.begin(); it != str.end();
3406
+ for (std::experimental::string_view::const_iterator it = str.begin(); it != str.end();
3408
unsigned char c = *it;
3409
if (EscapeSpecialCodePoint(c, &dest))
3410
--- a/tools/gn/src/base/md5.cc
3411
+++ b/tools/gn/src/base/md5.cc
3412
@@ -169,7 +169,7 @@ void MD5Init(MD5Context* context) {
3413
* Update context to reflect the concatenation of another buffer full
3416
-void MD5Update(MD5Context* context, const std::string_view& data) {
3417
+void MD5Update(MD5Context* context, const std::experimental::string_view& data) {
3418
struct Context* ctx = reinterpret_cast<struct Context*>(context);
3419
const uint8_t* buf = reinterpret_cast<const uint8_t*>(data.data());
3420
size_t len = data.size();
3421
@@ -288,11 +288,11 @@ void MD5Sum(const void* data, size_t len
3425
- std::string_view(reinterpret_cast<const char*>(data), length));
3426
+ std::experimental::string_view(reinterpret_cast<const char*>(data), length));
3427
MD5Final(digest, &ctx);
3430
-std::string MD5String(const std::string_view& str) {
3431
+std::string MD5String(const std::experimental::string_view& str) {
3433
MD5Sum(str.data(), str.length(), &digest);
3434
return MD5DigestToBase16(digest);
3435
--- a/tools/gn/src/base/strings/string_number_conversions.cc
3436
+++ b/tools/gn/src/base/strings/string_number_conversions.cc
3437
@@ -270,38 +270,38 @@ template <typename ITERATOR>
3438
class BaseHexIteratorRangeToUInt64Traits
3439
: public BaseIteratorRangeToNumberTraits<ITERATOR, uint64_t, 16> {};
3441
-typedef BaseHexIteratorRangeToIntTraits<std::string_view::const_iterator>
3442
+typedef BaseHexIteratorRangeToIntTraits<std::experimental::string_view::const_iterator>
3443
HexIteratorRangeToIntTraits;
3445
-typedef BaseHexIteratorRangeToUIntTraits<std::string_view::const_iterator>
3446
+typedef BaseHexIteratorRangeToUIntTraits<std::experimental::string_view::const_iterator>
3447
HexIteratorRangeToUIntTraits;
3449
-typedef BaseHexIteratorRangeToInt64Traits<std::string_view::const_iterator>
3450
+typedef BaseHexIteratorRangeToInt64Traits<std::experimental::string_view::const_iterator>
3451
HexIteratorRangeToInt64Traits;
3453
-typedef BaseHexIteratorRangeToUInt64Traits<std::string_view::const_iterator>
3454
+typedef BaseHexIteratorRangeToUInt64Traits<std::experimental::string_view::const_iterator>
3455
HexIteratorRangeToUInt64Traits;
3457
template <typename VALUE, int BASE>
3458
class StringPieceToNumberTraits
3459
- : public BaseIteratorRangeToNumberTraits<std::string_view::const_iterator,
3460
+ : public BaseIteratorRangeToNumberTraits<std::experimental::string_view::const_iterator,
3464
template <typename VALUE>
3465
-bool StringToIntImpl(std::string_view input, VALUE* output) {
3466
+bool StringToIntImpl(std::experimental::string_view input, VALUE* output) {
3467
return IteratorRangeToNumber<StringPieceToNumberTraits<VALUE, 10>>::Invoke(
3468
input.begin(), input.end(), output);
3471
template <typename VALUE, int BASE>
3472
class StringPiece16ToNumberTraits : public BaseIteratorRangeToNumberTraits<
3473
- std::u16string_view::const_iterator,
3474
+ std::experimental::u16string_view::const_iterator,
3478
template <typename VALUE>
3479
-bool String16ToIntImpl(std::u16string_view input, VALUE* output) {
3480
+bool String16ToIntImpl(std::experimental::u16string_view input, VALUE* output) {
3481
return IteratorRangeToNumber<StringPiece16ToNumberTraits<VALUE, 10>>::Invoke(
3482
input.begin(), input.end(), output);
3484
@@ -356,43 +356,43 @@ std::u16string NumberToString16(unsigned
3485
return IntToStringT<std::u16string, unsigned long long>::IntToString(value);
3488
-bool StringToInt(std::string_view input, int* output) {
3489
+bool StringToInt(std::experimental::string_view input, int* output) {
3490
return StringToIntImpl(input, output);
3493
-bool StringToInt(std::u16string_view input, int* output) {
3494
+bool StringToInt(std::experimental::u16string_view input, int* output) {
3495
return String16ToIntImpl(input, output);
3498
-bool StringToUint(std::string_view input, unsigned* output) {
3499
+bool StringToUint(std::experimental::string_view input, unsigned* output) {
3500
return StringToIntImpl(input, output);
3503
-bool StringToUint(std::u16string_view input, unsigned* output) {
3504
+bool StringToUint(std::experimental::u16string_view input, unsigned* output) {
3505
return String16ToIntImpl(input, output);
3508
-bool StringToInt64(std::string_view input, int64_t* output) {
3509
+bool StringToInt64(std::experimental::string_view input, int64_t* output) {
3510
return StringToIntImpl(input, output);
3513
-bool StringToInt64(std::u16string_view input, int64_t* output) {
3514
+bool StringToInt64(std::experimental::u16string_view input, int64_t* output) {
3515
return String16ToIntImpl(input, output);
3518
-bool StringToUint64(std::string_view input, uint64_t* output) {
3519
+bool StringToUint64(std::experimental::string_view input, uint64_t* output) {
3520
return StringToIntImpl(input, output);
3523
-bool StringToUint64(std::u16string_view input, uint64_t* output) {
3524
+bool StringToUint64(std::experimental::u16string_view input, uint64_t* output) {
3525
return String16ToIntImpl(input, output);
3528
-bool StringToSizeT(std::string_view input, size_t* output) {
3529
+bool StringToSizeT(std::experimental::string_view input, size_t* output) {
3530
return StringToIntImpl(input, output);
3533
-bool StringToSizeT(std::u16string_view input, size_t* output) {
3534
+bool StringToSizeT(std::experimental::u16string_view input, size_t* output) {
3535
return String16ToIntImpl(input, output);
3538
@@ -418,27 +418,27 @@ std::string HexEncode(const void* bytes,
3542
-bool HexStringToInt(std::string_view input, int* output) {
3543
+bool HexStringToInt(std::experimental::string_view input, int* output) {
3544
return IteratorRangeToNumber<HexIteratorRangeToIntTraits>::Invoke(
3545
input.begin(), input.end(), output);
3548
-bool HexStringToUInt(std::string_view input, uint32_t* output) {
3549
+bool HexStringToUInt(std::experimental::string_view input, uint32_t* output) {
3550
return IteratorRangeToNumber<HexIteratorRangeToUIntTraits>::Invoke(
3551
input.begin(), input.end(), output);
3554
-bool HexStringToInt64(std::string_view input, int64_t* output) {
3555
+bool HexStringToInt64(std::experimental::string_view input, int64_t* output) {
3556
return IteratorRangeToNumber<HexIteratorRangeToInt64Traits>::Invoke(
3557
input.begin(), input.end(), output);
3560
-bool HexStringToUInt64(std::string_view input, uint64_t* output) {
3561
+bool HexStringToUInt64(std::experimental::string_view input, uint64_t* output) {
3562
return IteratorRangeToNumber<HexIteratorRangeToUInt64Traits>::Invoke(
3563
input.begin(), input.end(), output);
3566
-bool HexStringToBytes(std::string_view input, std::vector<uint8_t>* output) {
3567
+bool HexStringToBytes(std::experimental::string_view input, std::vector<uint8_t>* output) {
3568
DCHECK_EQ(output->size(), 0u);
3569
size_t count = input.size();
3570
if (count == 0 || (count % 2) != 0)
3571
--- a/tools/gn/src/base/values.cc
3572
+++ b/tools/gn/src/base/values.cc
3573
@@ -131,7 +131,7 @@ Value::Value(int in_int) : type_(Type::I
3575
Value::Value(const char* in_string) : Value(std::string(in_string)) {}
3577
-Value::Value(std::string_view in_string) : Value(std::string(in_string)) {}
3578
+Value::Value(std::experimental::string_view in_string) : Value(std::string(in_string)) {}
3580
Value::Value(std::string&& in_string) noexcept
3581
: type_(Type::STRING), string_value_(std::move(in_string)) {
3582
@@ -139,9 +139,9 @@ Value::Value(std::string&& in_string) no
3585
Value::Value(const char16_t* in_string16)
3586
- : Value(std::u16string_view(in_string16)) {}
3587
+ : Value(std::experimental::u16string_view(in_string16)) {}
3589
-Value::Value(std::u16string_view in_string16)
3590
+Value::Value(std::experimental::u16string_view in_string16)
3591
: Value(UTF16ToUTF8(in_string16)) {}
3593
Value::Value(const BlobStorage& in_blob)
3594
@@ -240,11 +240,11 @@ const Value::ListStorage& Value::GetList
3598
-Value* Value::FindKey(std::string_view key) {
3599
+Value* Value::FindKey(std::experimental::string_view key) {
3600
return const_cast<Value*>(static_cast<const Value*>(this)->FindKey(key));
3603
-const Value* Value::FindKey(std::string_view key) const {
3604
+const Value* Value::FindKey(std::experimental::string_view key) const {
3606
auto found = dict_.find(key);
3607
if (found == dict_.end())
3608
@@ -252,28 +252,28 @@ const Value* Value::FindKey(std::string_
3609
return found->second.get();
3612
-Value* Value::FindKeyOfType(std::string_view key, Type type) {
3613
+Value* Value::FindKeyOfType(std::experimental::string_view key, Type type) {
3614
return const_cast<Value*>(
3615
static_cast<const Value*>(this)->FindKeyOfType(key, type));
3618
-const Value* Value::FindKeyOfType(std::string_view key, Type type) const {
3619
+const Value* Value::FindKeyOfType(std::experimental::string_view key, Type type) const {
3620
const Value* result = FindKey(key);
3621
if (!result || result->type() != type)
3626
-bool Value::RemoveKey(std::string_view key) {
3627
+bool Value::RemoveKey(std::experimental::string_view key) {
3629
// NOTE: Can't directly return dict_->erase(key) due to MSVC warning C4800.
3630
return dict_.erase(key) != 0;
3633
-Value* Value::SetKey(std::string_view key, Value value) {
3634
+Value* Value::SetKey(std::experimental::string_view key, Value value) {
3636
// NOTE: We can't use |insert_or_assign| here, as only |try_emplace| does
3637
- // an explicit conversion from std::string_view to std::string if necessary.
3638
+ // an explicit conversion from std::experimental::string_view to std::string if necessary.
3639
auto val_ptr = std::make_unique<Value>(std::move(value));
3640
auto result = dict_.try_emplace(key, std::move(val_ptr));
3641
if (!result.second) {
3642
@@ -292,50 +292,50 @@ Value* Value::SetKey(std::string&& key,
3645
Value* Value::SetKey(const char* key, Value value) {
3646
- return SetKey(std::string_view(key), std::move(value));
3647
+ return SetKey(std::experimental::string_view(key), std::move(value));
3650
-Value* Value::FindPath(std::initializer_list<std::string_view> path) {
3651
+Value* Value::FindPath(std::initializer_list<std::experimental::string_view> path) {
3652
return const_cast<Value*>(const_cast<const Value*>(this)->FindPath(path));
3655
-Value* Value::FindPath(span<const std::string_view> path) {
3656
+Value* Value::FindPath(span<const std::experimental::string_view> path) {
3657
return const_cast<Value*>(const_cast<const Value*>(this)->FindPath(path));
3660
const Value* Value::FindPath(
3661
- std::initializer_list<std::string_view> path) const {
3662
+ std::initializer_list<std::experimental::string_view> path) const {
3663
DCHECK_GE(path.size(), 2u) << "Use FindKey() for a path of length 1.";
3664
return FindPath(make_span(path.begin(), path.size()));
3667
-const Value* Value::FindPath(span<const std::string_view> path) const {
3668
+const Value* Value::FindPath(span<const std::experimental::string_view> path) const {
3669
const Value* cur = this;
3670
- for (const std::string_view component : path) {
3671
+ for (const std::experimental::string_view component : path) {
3672
if (!cur->is_dict() || (cur = cur->FindKey(component)) == nullptr)
3678
-Value* Value::FindPathOfType(std::initializer_list<std::string_view> path,
3679
+Value* Value::FindPathOfType(std::initializer_list<std::experimental::string_view> path,
3681
return const_cast<Value*>(
3682
const_cast<const Value*>(this)->FindPathOfType(path, type));
3685
-Value* Value::FindPathOfType(span<const std::string_view> path, Type type) {
3686
+Value* Value::FindPathOfType(span<const std::experimental::string_view> path, Type type) {
3687
return const_cast<Value*>(
3688
const_cast<const Value*>(this)->FindPathOfType(path, type));
3691
-const Value* Value::FindPathOfType(std::initializer_list<std::string_view> path,
3692
+const Value* Value::FindPathOfType(std::initializer_list<std::experimental::string_view> path,
3694
DCHECK_GE(path.size(), 2u) << "Use FindKeyOfType() for a path of length 1.";
3695
return FindPathOfType(make_span(path.begin(), path.size()), type);
3698
-const Value* Value::FindPathOfType(span<const std::string_view> path,
3699
+const Value* Value::FindPathOfType(span<const std::experimental::string_view> path,
3701
const Value* result = FindPath(path);
3702
if (!result || result->type() != type)
3703
@@ -343,25 +343,25 @@ const Value* Value::FindPathOfType(span<
3707
-Value* Value::SetPath(std::initializer_list<std::string_view> path,
3708
+Value* Value::SetPath(std::initializer_list<std::experimental::string_view> path,
3710
DCHECK_GE(path.size(), 2u) << "Use SetKey() for a path of length 1.";
3711
return SetPath(make_span(path.begin(), path.size()), std::move(value));
3714
-Value* Value::SetPath(span<const std::string_view> path, Value value) {
3715
+Value* Value::SetPath(span<const std::experimental::string_view> path, Value value) {
3716
DCHECK_NE(path.begin(), path.end()); // Can't be empty path.
3718
// Walk/construct intermediate dictionaries. The last element requires
3719
// special handling so skip it in this loop.
3721
- const std::string_view* cur_path = path.begin();
3722
+ const std::experimental::string_view* cur_path = path.begin();
3723
for (; (cur_path + 1) < path.end(); ++cur_path) {
3724
if (!cur->is_dict())
3727
// Use lower_bound to avoid doing the search twice for missing keys.
3728
- const std::string_view path_component = *cur_path;
3729
+ const std::experimental::string_view path_component = *cur_path;
3730
auto found = cur->dict_.lower_bound(path_component);
3731
if (found == cur->dict_.end() || found->first != path_component) {
3732
// No key found, insert one.
3733
@@ -379,12 +379,12 @@ Value* Value::SetPath(span<const std::st
3734
return cur->SetKey(*cur_path, std::move(value));
3737
-bool Value::RemovePath(std::initializer_list<std::string_view> path) {
3738
+bool Value::RemovePath(std::initializer_list<std::experimental::string_view> path) {
3739
DCHECK_GE(path.size(), 2u) << "Use RemoveKey() for a path of length 1.";
3740
return RemovePath(make_span(path.begin(), path.size()));
3743
-bool Value::RemovePath(span<const std::string_view> path) {
3744
+bool Value::RemovePath(span<const std::experimental::string_view> path) {
3745
if (!is_dict() || path.empty())
3748
@@ -462,7 +462,7 @@ bool Value::GetAsString(const Value** ou
3752
-bool Value::GetAsString(std::string_view* out_value) const {
3753
+bool Value::GetAsString(std::experimental::string_view* out_value) const {
3754
if (out_value && is_string()) {
3755
*out_value = string_value_;
3757
@@ -665,7 +665,7 @@ DictionaryValue::DictionaryValue(const D
3758
DictionaryValue::DictionaryValue(DictStorage&& in_dict) noexcept
3759
: Value(std::move(in_dict)) {}
3761
-bool DictionaryValue::HasKey(std::string_view key) const {
3762
+bool DictionaryValue::HasKey(std::experimental::string_view key) const {
3763
DCHECK(IsStringUTF8(key));
3764
auto current_entry = dict_.find(key);
3765
DCHECK((current_entry == dict_.end()) || current_entry->second);
3766
@@ -676,18 +676,18 @@ void DictionaryValue::Clear() {
3770
-Value* DictionaryValue::Set(std::string_view path,
3771
+Value* DictionaryValue::Set(std::experimental::string_view path,
3772
std::unique_ptr<Value> in_value) {
3773
DCHECK(IsStringUTF8(path));
3776
- std::string_view current_path(path);
3777
+ std::experimental::string_view current_path(path);
3778
Value* current_dictionary = this;
3779
for (size_t delimiter_position = current_path.find('.');
3780
- delimiter_position != std::string_view::npos;
3781
+ delimiter_position != std::experimental::string_view::npos;
3782
delimiter_position = current_path.find('.')) {
3783
// Assume that we're indexing into a dictionary.
3784
- std::string_view key = current_path.substr(0, delimiter_position);
3785
+ std::experimental::string_view key = current_path.substr(0, delimiter_position);
3786
Value* child_dictionary =
3787
current_dictionary->FindKeyOfType(key, Type::DICTIONARY);
3788
if (!child_dictionary) {
3789
@@ -703,40 +703,40 @@ Value* DictionaryValue::Set(std::string_
3790
->SetWithoutPathExpansion(current_path, std::move(in_value));
3793
-Value* DictionaryValue::SetBoolean(std::string_view path, bool in_value) {
3794
+Value* DictionaryValue::SetBoolean(std::experimental::string_view path, bool in_value) {
3795
return Set(path, std::make_unique<Value>(in_value));
3798
-Value* DictionaryValue::SetInteger(std::string_view path, int in_value) {
3799
+Value* DictionaryValue::SetInteger(std::experimental::string_view path, int in_value) {
3800
return Set(path, std::make_unique<Value>(in_value));
3803
-Value* DictionaryValue::SetString(std::string_view path,
3804
- std::string_view in_value) {
3805
+Value* DictionaryValue::SetString(std::experimental::string_view path,
3806
+ std::experimental::string_view in_value) {
3807
return Set(path, std::make_unique<Value>(in_value));
3810
-Value* DictionaryValue::SetString(std::string_view path,
3811
+Value* DictionaryValue::SetString(std::experimental::string_view path,
3812
const std::u16string& in_value) {
3813
return Set(path, std::make_unique<Value>(in_value));
3816
DictionaryValue* DictionaryValue::SetDictionary(
3817
- std::string_view path,
3818
+ std::experimental::string_view path,
3819
std::unique_ptr<DictionaryValue> in_value) {
3820
return static_cast<DictionaryValue*>(Set(path, std::move(in_value)));
3823
-ListValue* DictionaryValue::SetList(std::string_view path,
3824
+ListValue* DictionaryValue::SetList(std::experimental::string_view path,
3825
std::unique_ptr<ListValue> in_value) {
3826
return static_cast<ListValue*>(Set(path, std::move(in_value)));
3829
Value* DictionaryValue::SetWithoutPathExpansion(
3830
- std::string_view key,
3831
+ std::experimental::string_view key,
3832
std::unique_ptr<Value> in_value) {
3833
// NOTE: We can't use |insert_or_assign| here, as only |try_emplace| does
3834
- // an explicit conversion from std::string_view to std::string if necessary.
3835
+ // an explicit conversion from std::experimental::string_view to std::string if necessary.
3836
auto result = dict_.try_emplace(key, std::move(in_value));
3837
if (!result.second) {
3838
// in_value is guaranteed to be still intact at this point.
3839
@@ -745,10 +745,10 @@ Value* DictionaryValue::SetWithoutPathEx
3840
return result.first->second.get();
3843
-bool DictionaryValue::Get(std::string_view path,
3844
+bool DictionaryValue::Get(std::experimental::string_view path,
3845
const Value** out_value) const {
3846
DCHECK(IsStringUTF8(path));
3847
- std::string_view current_path(path);
3848
+ std::experimental::string_view current_path(path);
3849
const DictionaryValue* current_dictionary = this;
3850
for (size_t delimiter_position = current_path.find('.');
3851
delimiter_position != std::string::npos;
3852
@@ -766,12 +766,12 @@ bool DictionaryValue::Get(std::string_vi
3853
return current_dictionary->GetWithoutPathExpansion(current_path, out_value);
3856
-bool DictionaryValue::Get(std::string_view path, Value** out_value) {
3857
+bool DictionaryValue::Get(std::experimental::string_view path, Value** out_value) {
3858
return static_cast<const DictionaryValue&>(*this).Get(
3859
path, const_cast<const Value**>(out_value));
3862
-bool DictionaryValue::GetBoolean(std::string_view path,
3863
+bool DictionaryValue::GetBoolean(std::experimental::string_view path,
3864
bool* bool_value) const {
3866
if (!Get(path, &value))
3867
@@ -780,7 +780,7 @@ bool DictionaryValue::GetBoolean(std::st
3868
return value->GetAsBoolean(bool_value);
3871
-bool DictionaryValue::GetInteger(std::string_view path, int* out_value) const {
3872
+bool DictionaryValue::GetInteger(std::experimental::string_view path, int* out_value) const {
3874
if (!Get(path, &value))
3876
@@ -788,7 +788,7 @@ bool DictionaryValue::GetInteger(std::st
3877
return value->GetAsInteger(out_value);
3880
-bool DictionaryValue::GetString(std::string_view path,
3881
+bool DictionaryValue::GetString(std::experimental::string_view path,
3882
std::string* out_value) const {
3884
if (!Get(path, &value))
3885
@@ -797,7 +797,7 @@ bool DictionaryValue::GetString(std::str
3886
return value->GetAsString(out_value);
3889
-bool DictionaryValue::GetString(std::string_view path,
3890
+bool DictionaryValue::GetString(std::experimental::string_view path,
3891
std::u16string* out_value) const {
3893
if (!Get(path, &value))
3894
@@ -806,7 +806,7 @@ bool DictionaryValue::GetString(std::str
3895
return value->GetAsString(out_value);
3898
-bool DictionaryValue::GetStringASCII(std::string_view path,
3899
+bool DictionaryValue::GetStringASCII(std::experimental::string_view path,
3900
std::string* out_value) const {
3902
if (!GetString(path, &out))
3903
@@ -821,7 +821,7 @@ bool DictionaryValue::GetStringASCII(std
3907
-bool DictionaryValue::GetBinary(std::string_view path,
3908
+bool DictionaryValue::GetBinary(std::experimental::string_view path,
3909
const Value** out_value) const {
3911
bool result = Get(path, &value);
3912
@@ -834,12 +834,12 @@ bool DictionaryValue::GetBinary(std::str
3916
-bool DictionaryValue::GetBinary(std::string_view path, Value** out_value) {
3917
+bool DictionaryValue::GetBinary(std::experimental::string_view path, Value** out_value) {
3918
return static_cast<const DictionaryValue&>(*this).GetBinary(
3919
path, const_cast<const Value**>(out_value));
3922
-bool DictionaryValue::GetDictionary(std::string_view path,
3923
+bool DictionaryValue::GetDictionary(std::experimental::string_view path,
3924
const DictionaryValue** out_value) const {
3926
bool result = Get(path, &value);
3927
@@ -852,13 +852,13 @@ bool DictionaryValue::GetDictionary(std:
3931
-bool DictionaryValue::GetDictionary(std::string_view path,
3932
+bool DictionaryValue::GetDictionary(std::experimental::string_view path,
3933
DictionaryValue** out_value) {
3934
return static_cast<const DictionaryValue&>(*this).GetDictionary(
3935
path, const_cast<const DictionaryValue**>(out_value));
3938
-bool DictionaryValue::GetList(std::string_view path,
3939
+bool DictionaryValue::GetList(std::experimental::string_view path,
3940
const ListValue** out_value) const {
3942
bool result = Get(path, &value);
3943
@@ -871,12 +871,12 @@ bool DictionaryValue::GetList(std::strin
3947
-bool DictionaryValue::GetList(std::string_view path, ListValue** out_value) {
3948
+bool DictionaryValue::GetList(std::experimental::string_view path, ListValue** out_value) {
3949
return static_cast<const DictionaryValue&>(*this).GetList(
3950
path, const_cast<const ListValue**>(out_value));
3953
-bool DictionaryValue::GetWithoutPathExpansion(std::string_view key,
3954
+bool DictionaryValue::GetWithoutPathExpansion(std::experimental::string_view key,
3955
const Value** out_value) const {
3956
DCHECK(IsStringUTF8(key));
3957
auto entry_iterator = dict_.find(key);
3958
@@ -888,13 +888,13 @@ bool DictionaryValue::GetWithoutPathExpa
3962
-bool DictionaryValue::GetWithoutPathExpansion(std::string_view key,
3963
+bool DictionaryValue::GetWithoutPathExpansion(std::experimental::string_view key,
3964
Value** out_value) {
3965
return static_cast<const DictionaryValue&>(*this).GetWithoutPathExpansion(
3966
key, const_cast<const Value**>(out_value));
3969
-bool DictionaryValue::GetBooleanWithoutPathExpansion(std::string_view key,
3970
+bool DictionaryValue::GetBooleanWithoutPathExpansion(std::experimental::string_view key,
3971
bool* out_value) const {
3973
if (!GetWithoutPathExpansion(key, &value))
3974
@@ -903,7 +903,7 @@ bool DictionaryValue::GetBooleanWithoutP
3975
return value->GetAsBoolean(out_value);
3978
-bool DictionaryValue::GetIntegerWithoutPathExpansion(std::string_view key,
3979
+bool DictionaryValue::GetIntegerWithoutPathExpansion(std::experimental::string_view key,
3980
int* out_value) const {
3982
if (!GetWithoutPathExpansion(key, &value))
3983
@@ -913,7 +913,7 @@ bool DictionaryValue::GetIntegerWithoutP
3986
bool DictionaryValue::GetStringWithoutPathExpansion(
3987
- std::string_view key,
3988
+ std::experimental::string_view key,
3989
std::string* out_value) const {
3991
if (!GetWithoutPathExpansion(key, &value))
3992
@@ -923,7 +923,7 @@ bool DictionaryValue::GetStringWithoutPa
3995
bool DictionaryValue::GetStringWithoutPathExpansion(
3996
- std::string_view key,
3997
+ std::experimental::string_view key,
3998
std::u16string* out_value) const {
4000
if (!GetWithoutPathExpansion(key, &value))
4001
@@ -933,7 +933,7 @@ bool DictionaryValue::GetStringWithoutPa
4004
bool DictionaryValue::GetDictionaryWithoutPathExpansion(
4005
- std::string_view key,
4006
+ std::experimental::string_view key,
4007
const DictionaryValue** out_value) const {
4009
bool result = GetWithoutPathExpansion(key, &value);
4010
@@ -947,7 +947,7 @@ bool DictionaryValue::GetDictionaryWitho
4013
bool DictionaryValue::GetDictionaryWithoutPathExpansion(
4014
- std::string_view key,
4015
+ std::experimental::string_view key,
4016
DictionaryValue** out_value) {
4017
const DictionaryValue& const_this =
4018
static_cast<const DictionaryValue&>(*this);
4019
@@ -956,7 +956,7 @@ bool DictionaryValue::GetDictionaryWitho
4022
bool DictionaryValue::GetListWithoutPathExpansion(
4023
- std::string_view key,
4024
+ std::experimental::string_view key,
4025
const ListValue** out_value) const {
4027
bool result = GetWithoutPathExpansion(key, &value);
4028
@@ -969,19 +969,19 @@ bool DictionaryValue::GetListWithoutPath
4032
-bool DictionaryValue::GetListWithoutPathExpansion(std::string_view key,
4033
+bool DictionaryValue::GetListWithoutPathExpansion(std::experimental::string_view key,
4034
ListValue** out_value) {
4035
return static_cast<const DictionaryValue&>(*this).GetListWithoutPathExpansion(
4036
key, const_cast<const ListValue**>(out_value));
4039
-bool DictionaryValue::Remove(std::string_view path,
4040
+bool DictionaryValue::Remove(std::experimental::string_view path,
4041
std::unique_ptr<Value>* out_value) {
4042
DCHECK(IsStringUTF8(path));
4043
- std::string_view current_path(path);
4044
+ std::experimental::string_view current_path(path);
4045
DictionaryValue* current_dictionary = this;
4046
size_t delimiter_position = current_path.rfind('.');
4047
- if (delimiter_position != std::string_view::npos) {
4048
+ if (delimiter_position != std::experimental::string_view::npos) {
4049
if (!GetDictionary(current_path.substr(0, delimiter_position),
4050
¤t_dictionary))
4052
@@ -993,7 +993,7 @@ bool DictionaryValue::Remove(std::string
4055
bool DictionaryValue::RemoveWithoutPathExpansion(
4056
- std::string_view key,
4057
+ std::experimental::string_view key,
4058
std::unique_ptr<Value>* out_value) {
4059
DCHECK(IsStringUTF8(key));
4060
auto entry_iterator = dict_.find(key);
4061
@@ -1006,7 +1006,7 @@ bool DictionaryValue::RemoveWithoutPathE
4065
-bool DictionaryValue::RemovePath(std::string_view path,
4066
+bool DictionaryValue::RemovePath(std::experimental::string_view path,
4067
std::unique_ptr<Value>* out_value) {
4068
bool result = false;
4069
size_t delimiter_position = path.find('.');
4070
@@ -1014,7 +1014,7 @@ bool DictionaryValue::RemovePath(std::st
4071
if (delimiter_position == std::string::npos)
4072
return RemoveWithoutPathExpansion(path, out_value);
4074
- std::string_view subdict_path = path.substr(0, delimiter_position);
4075
+ std::experimental::string_view subdict_path = path.substr(0, delimiter_position);
4076
DictionaryValue* subdict = nullptr;
4077
if (!GetDictionary(subdict_path, &subdict))
4079
@@ -1234,7 +1234,7 @@ void ListValue::AppendInteger(int in_val
4080
list_.emplace_back(in_value);
4083
-void ListValue::AppendString(std::string_view in_value) {
4084
+void ListValue::AppendString(std::experimental::string_view in_value) {
4085
list_.emplace_back(in_value);
4088
--- a/tools/gn/src/gn/args.cc
4089
+++ b/tools/gn/src/gn/args.cc
4090
@@ -108,8 +108,8 @@ Args::~Args() = default;
4091
void Args::AddArgOverride(const char* name, const Value& value) {
4092
std::lock_guard<std::mutex> lock(lock_);
4094
- overrides_[std::string_view(name)] = value;
4095
- all_overrides_[std::string_view(name)] = value;
4096
+ overrides_[std::experimental::string_view(name)] = value;
4097
+ all_overrides_[std::experimental::string_view(name)] = value;
4100
void Args::AddArgOverrides(const Scope::KeyValueMap& overrides) {
4101
@@ -131,7 +131,7 @@ const Value* Args::GetArgOverride(const
4102
std::lock_guard<std::mutex> lock(lock_);
4104
Scope::KeyValueMap::const_iterator found =
4105
- all_overrides_.find(std::string_view(name));
4106
+ all_overrides_.find(std::experimental::string_view(name));
4107
if (found == all_overrides_.end())
4109
return &found->second;
4110
@@ -240,7 +240,7 @@ bool Args::VerifyAllOverridesUsed(Err* e
4112
// Some assignments in args.gn had no effect. Show an error for the first
4113
// unused assignment.
4114
- std::string_view name = unused_overrides.begin()->first;
4115
+ std::experimental::string_view name = unused_overrides.begin()->first;
4116
const Value& value = unused_overrides.begin()->second;
4118
std::string err_help(
4119
@@ -250,12 +250,12 @@ bool Args::VerifyAllOverridesUsed(Err* e
4120
"To view all possible args, run \"gn args --list <out_dir>\"");
4122
// Use all declare_args for a spelling suggestion.
4123
- std::vector<std::string_view> candidates;
4124
+ std::vector<std::experimental::string_view> candidates;
4125
for (const auto& map_pair : declared_arguments_per_toolchain_) {
4126
for (const auto& declared_arg : map_pair.second)
4127
candidates.push_back(declared_arg.first);
4129
- std::string_view suggestion = SpellcheckString(name, candidates);
4130
+ std::experimental::string_view suggestion = SpellcheckString(name, candidates);
4131
if (!suggestion.empty())
4132
err_help = "Did you mean \"" + suggestion + "\"?\n\n" + err_help;
4134
--- a/tools/gn/src/gn/bundle_data.cc
4135
+++ b/tools/gn/src/gn/bundle_data.cc
4139
// Return directory of |path| without the trailing directory separator.
4140
-std::string_view FindDirNoTrailingSeparator(std::string_view path) {
4141
- std::string_view::size_type pos = path.find_last_of("/\\");
4142
- if (pos == std::string_view::npos)
4143
- return std::string_view();
4144
- return std::string_view(path.data(), pos);
4145
+std::experimental::string_view FindDirNoTrailingSeparator(std::experimental::string_view path) {
4146
+ std::experimental::string_view::size_type pos = path.find_last_of("/\\");
4147
+ if (pos == std::experimental::string_view::npos)
4148
+ return std::experimental::string_view();
4149
+ return std::experimental::string_view(path.data(), pos);
4152
-bool IsSourceFileFromAssetsCatalog(std::string_view source,
4153
+bool IsSourceFileFromAssetsCatalog(std::experimental::string_view source,
4154
SourceFile* asset_catalog) {
4155
// Check whether |source| matches one of the following pattern:
4156
// .*\.xcassets/Contents.json
4157
@@ -33,7 +33,7 @@ bool IsSourceFileFromAssetsCatalog(std::
4158
// .*\.xcassets/[^/]*\.colorset/[^/]*
4159
// .*\.xcassets/[^/]*\.dataset/[^/]*
4160
bool is_file_from_asset_catalog = false;
4161
- std::string_view dir = FindDirNoTrailingSeparator(source);
4162
+ std::experimental::string_view dir = FindDirNoTrailingSeparator(source);
4163
if (base::EndsWith(source, "/Contents.json", base::CompareCase::SENSITIVE) &&
4164
base::EndsWith(dir, ".xcassets", base::CompareCase::SENSITIVE)) {
4165
is_file_from_asset_catalog = true;
4166
--- a/tools/gn/src/gn/c_include_iterator.cc
4167
+++ b/tools/gn/src/gn/c_include_iterator.cc
4168
@@ -23,7 +23,7 @@ enum IncludeType {
4169
// Returns a new string piece referencing the same buffer as the argument, but
4170
// with leading space trimmed. This only checks for space and tab characters
4171
// since we're dealing with lines in C source files.
4172
-std::string_view TrimLeadingWhitespace(const std::string_view& str) {
4173
+std::experimental::string_view TrimLeadingWhitespace(const std::experimental::string_view& str) {
4174
size_t new_begin = 0;
4175
while (new_begin < str.size() &&
4176
(str[new_begin] == ' ' || str[new_begin] == '\t'))
4177
@@ -42,7 +42,7 @@ std::string_view TrimLeadingWhitespace(c
4179
// We assume the line has leading whitespace trimmed. We also assume that empty
4180
// lines have already been filtered out.
4181
-bool ShouldCountTowardNonIncludeLines(const std::string_view& line) {
4182
+bool ShouldCountTowardNonIncludeLines(const std::experimental::string_view& line) {
4183
if (base::StartsWith(line, "//", base::CompareCase::SENSITIVE))
4184
return false; // Don't count comments.
4185
if (base::StartsWith(line, "/*", base::CompareCase::SENSITIVE) ||
4186
@@ -61,15 +61,15 @@ bool ShouldCountTowardNonIncludeLines(co
4188
// The 1-based character number on the line that the include was found at
4189
// will be filled into *begin_char.
4190
-IncludeType ExtractInclude(const std::string_view& line,
4191
- std::string_view* path,
4192
+IncludeType ExtractInclude(const std::experimental::string_view& line,
4193
+ std::experimental::string_view* path,
4195
static const char kInclude[] = "include";
4196
static const size_t kIncludeLen = std::size(kInclude) - 1; // No null.
4197
static const char kImport[] = "import";
4198
static const size_t kImportLen = std::size(kImport) - 1; // No null.
4200
- std::string_view trimmed = TrimLeadingWhitespace(line);
4201
+ std::experimental::string_view trimmed = TrimLeadingWhitespace(line);
4202
if (trimmed.empty())
4203
return INCLUDE_NONE;
4205
@@ -78,11 +78,11 @@ IncludeType ExtractInclude(const std::st
4207
trimmed = TrimLeadingWhitespace(trimmed.substr(1));
4209
- std::string_view contents;
4210
- if (base::StartsWith(trimmed, std::string_view(kInclude, kIncludeLen),
4211
+ std::experimental::string_view contents;
4212
+ if (base::StartsWith(trimmed, std::experimental::string_view(kInclude, kIncludeLen),
4213
base::CompareCase::SENSITIVE))
4214
contents = TrimLeadingWhitespace(trimmed.substr(kIncludeLen));
4215
- else if (base::StartsWith(trimmed, std::string_view(kImport, kImportLen),
4216
+ else if (base::StartsWith(trimmed, std::experimental::string_view(kImport, kImportLen),
4217
base::CompareCase::SENSITIVE))
4218
contents = TrimLeadingWhitespace(trimmed.substr(kImportLen));
4220
@@ -103,7 +103,7 @@ IncludeType ExtractInclude(const std::st
4222
// Count everything to next "/> as the contents.
4223
size_t terminator_index = contents.find(terminating_char, 1);
4224
- if (terminator_index == std::string_view::npos)
4225
+ if (terminator_index == std::experimental::string_view::npos)
4226
return INCLUDE_NONE;
4228
*path = contents.substr(1, terminator_index - 1);
4229
@@ -113,8 +113,8 @@ IncludeType ExtractInclude(const std::st
4232
// Returns true if this line has a "nogncheck" comment associated with it.
4233
-bool HasNoCheckAnnotation(const std::string_view& line) {
4234
- return line.find("nogncheck") != std::string_view::npos;
4235
+bool HasNoCheckAnnotation(const std::experimental::string_view& line) {
4236
+ return line.find("nogncheck") != std::experimental::string_view::npos;
4240
@@ -128,11 +128,11 @@ CIncludeIterator::~CIncludeIterator() =
4242
bool CIncludeIterator::GetNextIncludeString(
4243
IncludeStringWithLocation* include) {
4244
- std::string_view line;
4245
+ std::experimental::string_view line;
4246
int cur_line_number = 0;
4247
while (lines_since_last_include_ <= kMaxNonIncludeLines &&
4248
GetNextLine(&line, &cur_line_number)) {
4249
- std::string_view include_contents;
4250
+ std::experimental::string_view include_contents;
4252
IncludeType type = ExtractInclude(line, &include_contents, &begin_char);
4253
if (HasNoCheckAnnotation(line))
4254
@@ -157,7 +157,7 @@ bool CIncludeIterator::GetNextIncludeStr
4258
-bool CIncludeIterator::GetNextLine(std::string_view* line, int* line_number) {
4259
+bool CIncludeIterator::GetNextLine(std::experimental::string_view* line, int* line_number) {
4260
if (offset_ == file_.size())
4263
--- a/tools/gn/src/gn/command_args.cc
4264
+++ b/tools/gn/src/gn/command_args.cc
4265
@@ -40,7 +40,7 @@ const char kSwitchShort[] = "short";
4266
const char kSwitchOverridesOnly[] = "overrides-only";
4267
const char kSwitchJson[] = "json";
4269
-bool DoesLineBeginWithComment(const std::string_view& line) {
4270
+bool DoesLineBeginWithComment(const std::experimental::string_view& line) {
4273
while (i < line.size() && base::IsAsciiWhitespace(line[i]))
4274
@@ -67,7 +67,7 @@ size_t BackUpToLineBegin(const std::stri
4276
// Assumes DoesLineBeginWithComment(), this strips the # character from the
4277
// beginning and normalizes preceding whitespace.
4278
-std::string StripHashFromLine(const std::string_view& line, bool pad) {
4279
+std::string StripHashFromLine(const std::experimental::string_view& line, bool pad) {
4280
// Replace the # sign and everything before it with 3 spaces, so that a
4281
// normal comment that has a space after the # will be indented 4 spaces
4282
// (which makes our formatting come out nicely). If the comment is indented
4283
@@ -104,7 +104,7 @@ void GetContextForValue(const Value& val
4284
line_off -= 2; // Back up to end of previous line.
4285
size_t previous_line_offset = BackUpToLineBegin(data, line_off);
4287
- std::string_view line(&data[previous_line_offset],
4288
+ std::experimental::string_view line(&data[previous_line_offset],
4289
line_off - previous_line_offset + 1);
4290
if (!DoesLineBeginWithComment(line))
4292
@@ -120,7 +120,7 @@ void GetContextForValue(const Value& val
4293
// is a bit different.
4295
// The default value also contains the docstring.
4296
-void PrintDefaultValueInfo(std::string_view name, const Value& value) {
4297
+void PrintDefaultValueInfo(std::experimental::string_view name, const Value& value) {
4298
OutputString(value.ToString(true) + "\n");
4299
if (value.origin()) {
4301
@@ -137,7 +137,7 @@ void PrintDefaultValueInfo(std::string_v
4304
// Override value is null if there is no override.
4305
-void PrintArgHelp(const std::string_view& name,
4306
+void PrintArgHelp(const std::experimental::string_view& name,
4307
const Args::ValueWithOverride& val) {
4308
OutputString(std::string(name), DECORATION_YELLOW);
4310
@@ -163,7 +163,7 @@ void PrintArgHelp(const std::string_view
4313
void BuildArgJson(base::Value& dict,
4314
- const std::string_view& name,
4315
+ const std::experimental::string_view& name,
4316
const Args::ValueWithOverride& arg,
4318
assert(dict.is_dict());
4319
--- a/tools/gn/src/gn/command_clean.cc
4320
+++ b/tools/gn/src/gn/command_clean.cc
4321
@@ -27,13 +27,13 @@ std::string ExtractGNBuildCommands(const
4322
if (!base::ReadFileToString(build_ninja_file, &file_contents))
4323
return std::string();
4325
- std::vector<std::string_view> lines = base::SplitStringPiece(
4326
+ std::vector<std::experimental::string_view> lines = base::SplitStringPiece(
4327
file_contents, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
4330
int num_blank_lines = 0;
4331
for (const auto& line : lines) {
4332
- result.append(line);
4333
+ result.append(line.data(), line.size());
4334
result.push_back('\n');
4337
--- a/tools/gn/src/gn/command_format.cc
4338
+++ b/tools/gn/src/gn/command_format.cc
4339
@@ -134,7 +134,7 @@ class Printer {
4343
- void Print(std::string_view str);
4344
+ void Print(std::experimental::string_view str);
4346
// Add the current margin (as spaces) to the output.
4348
@@ -248,7 +248,7 @@ class Printer {
4349
std::vector<IndentState> stack_;
4351
// Gives the precedence for operators in a BinaryOpNode.
4352
- std::map<std::string_view, Precedence> precedence_;
4353
+ std::map<std::experimental::string_view, Precedence> precedence_;
4355
DISALLOW_COPY_AND_ASSIGN(Printer);
4357
@@ -274,8 +274,8 @@ Printer::Printer() : penalty_depth_(0) {
4359
Printer::~Printer() = default;
4361
-void Printer::Print(std::string_view str) {
4362
- output_.append(str);
4363
+void Printer::Print(std::experimental::string_view str) {
4364
+ output_.append(str.data(), str.size());
4367
void Printer::PrintMargin() {
4368
@@ -397,7 +397,7 @@ void Printer::SortIfSourcesOrDeps(const
4369
if ((binop->op().value() == "=" || binop->op().value() == "+=" ||
4370
binop->op().value() == "-=") &&
4372
- const std::string_view lhs = ident->value().value();
4373
+ const std::experimental::string_view lhs = ident->value().value();
4374
if (base::EndsWith(lhs, "sources", base::CompareCase::SENSITIVE) ||
4376
const_cast<ListNode*>(list)->SortAsStringsList();
4377
@@ -440,14 +440,14 @@ void Printer::SortImports(std::vector<st
4378
const std::unique_ptr<PARSENODE>& b) const {
4379
const auto& a_args = a->AsFunctionCall()->args()->contents();
4380
const auto& b_args = b->AsFunctionCall()->args()->contents();
4381
- std::string_view a_name;
4382
- std::string_view b_name;
4383
+ std::experimental::string_view a_name;
4384
+ std::experimental::string_view b_name;
4385
if (!a_args.empty())
4386
a_name = a_args[0]->AsLiteral()->value().value();
4387
if (!b_args.empty())
4388
b_name = b_args[0]->AsLiteral()->value().value();
4390
- auto is_absolute = [](std::string_view import) {
4391
+ auto is_absolute = [](std::experimental::string_view import) {
4392
return import.size() >= 3 && import[0] == '"' && import[1] == '/' &&
4395
@@ -665,7 +665,7 @@ int Printer::AssessPenalty(const std::st
4396
bool Printer::ExceedsMaximumWidth(const std::string& output) {
4397
for (const auto& line : base::SplitString(output, "\n", base::KEEP_WHITESPACE,
4398
base::SPLIT_WANT_ALL)) {
4399
- std::string_view trimmed =
4400
+ std::experimental::string_view trimmed =
4401
TrimString(line, " ", base::TrimPositions::TRIM_TRAILING);
4402
if (trimmed.size() > kMaximumWidth) {
4404
--- a/tools/gn/src/gn/command_help.cc
4405
+++ b/tools/gn/src/gn/command_help.cc
4406
@@ -212,7 +212,7 @@ void PrintAllHelp() {
4407
bool PrintHelpOnSwitch(const std::string& what) {
4408
const switches::SwitchInfoMap& all = switches::GetSwitches();
4409
switches::SwitchInfoMap::const_iterator found =
4410
- all.find(std::string_view(what));
4411
+ all.find(std::experimental::string_view(what));
4412
if (found == all.end())
4414
PrintLongHelp(found->second.long_help);
4415
@@ -277,7 +277,7 @@ int RunHelp(const std::vector<std::strin
4419
- std::vector<std::string_view> all_help_topics;
4420
+ std::vector<std::experimental::string_view> all_help_topics;
4422
// Special-case ambiguous topics.
4423
if (what == "args") {
4424
@@ -358,7 +358,7 @@ int RunHelp(const std::vector<std::strin
4427
Err(Location(), "No help on \"" + what + "\".").PrintToStdout();
4428
- std::string_view suggestion = SpellcheckString(what, all_help_topics);
4429
+ std::experimental::string_view suggestion = SpellcheckString(what, all_help_topics);
4430
if (suggestion.empty()) {
4431
OutputString("Run `gn help` for a list of available topics.\n",
4433
--- a/tools/gn/src/gn/create_bundle_target_generator.cc
4434
+++ b/tools/gn/src/gn/create_bundle_target_generator.cc
4435
@@ -73,7 +73,7 @@ void CreateBundleTargetGenerator::DoRun(
4437
bool CreateBundleTargetGenerator::FillBundleDir(
4438
const SourceDir& bundle_root_dir,
4439
- const std::string_view& name,
4440
+ const std::experimental::string_view& name,
4441
SourceDir* bundle_dir) {
4442
// All bundle_foo_dir properties are optional. They are only required if they
4443
// are used in an expansion. The check is performed there.
4444
--- a/tools/gn/src/gn/create_bundle_target_generator.h
4445
+++ b/tools/gn/src/gn/create_bundle_target_generator.h
4446
@@ -24,7 +24,7 @@ class CreateBundleTargetGenerator : publ
4449
bool FillBundleDir(const SourceDir& bundle_root_dir,
4450
- const std::string_view& name,
4451
+ const std::experimental::string_view& name,
4452
SourceDir* bundle_dir);
4454
bool FillXcodeExtraAttributes();
4455
--- a/tools/gn/src/gn/err.cc
4456
+++ b/tools/gn/src/gn/err.cc
4461
-std::string GetNthLine(const std::string_view& data, int n) {
4462
+std::string GetNthLine(const std::experimental::string_view& data, int n) {
4463
size_t line_off = Tokenizer::ByteOffsetOfNthLine(data, n);
4464
size_t end = line_off + 1;
4465
while (end < data.size() && !Tokenizer::IsNewline(data, end))
4466
--- a/tools/gn/src/gn/escape.cc
4467
+++ b/tools/gn/src/gn/escape.cc
4468
@@ -41,7 +41,7 @@ const char kShellValid[0x80] = {
4469
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0};
4472
-size_t EscapeStringToString_Space(const std::string_view& str,
4473
+size_t EscapeStringToString_Space(const std::experimental::string_view& str,
4474
const EscapeOptions& options,
4476
bool* needed_quoting) {
4477
@@ -75,7 +75,7 @@ inline bool ShouldEscapeCharForNinja(cha
4478
return ch == '$' || ch == ' ' || ch == ':';
4481
-size_t EscapeStringToString_Ninja(const std::string_view& str,
4482
+size_t EscapeStringToString_Ninja(const std::experimental::string_view& str,
4483
const EscapeOptions& options,
4485
bool* needed_quoting) {
4486
@@ -88,7 +88,7 @@ size_t EscapeStringToString_Ninja(const
4490
-size_t EscapeStringToString_Depfile(const std::string_view& str,
4491
+size_t EscapeStringToString_Depfile(const std::experimental::string_view& str,
4492
const EscapeOptions& options,
4494
bool* needed_quoting) {
4495
@@ -106,7 +106,7 @@ size_t EscapeStringToString_Depfile(cons
4499
-size_t EscapeStringToString_NinjaPreformatted(const std::string_view& str,
4500
+size_t EscapeStringToString_NinjaPreformatted(const std::experimental::string_view& str,
4502
// Only Ninja-escape $.
4504
@@ -126,7 +126,7 @@ size_t EscapeStringToString_NinjaPreform
4506
// http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
4507
// http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx
4508
-size_t EscapeStringToString_WindowsNinjaFork(const std::string_view& str,
4509
+size_t EscapeStringToString_WindowsNinjaFork(const std::experimental::string_view& str,
4510
const EscapeOptions& options,
4512
bool* needed_quoting) {
4513
@@ -178,7 +178,7 @@ size_t EscapeStringToString_WindowsNinja
4517
-size_t EscapeStringToString_PosixNinjaFork(const std::string_view& str,
4518
+size_t EscapeStringToString_PosixNinjaFork(const std::experimental::string_view& str,
4519
const EscapeOptions& options,
4521
bool* needed_quoting) {
4522
@@ -209,7 +209,7 @@ size_t EscapeStringToString_PosixNinjaFo
4525
// Escapes |str| into |dest| and returns the number of characters written.
4526
-size_t EscapeStringToString(const std::string_view& str,
4527
+size_t EscapeStringToString(const std::experimental::string_view& str,
4528
const EscapeOptions& options,
4530
bool* needed_quoting) {
4531
@@ -252,7 +252,7 @@ size_t EscapeStringToString(const std::s
4535
-std::string EscapeString(const std::string_view& str,
4536
+std::string EscapeString(const std::experimental::string_view& str,
4537
const EscapeOptions& options,
4538
bool* needed_quoting) {
4539
StackOrHeapBuffer dest(str.size() * kMaxEscapedCharsPerChar);
4540
@@ -261,7 +261,7 @@ std::string EscapeString(const std::stri
4543
void EscapeStringToStream(std::ostream& out,
4544
- const std::string_view& str,
4545
+ const std::experimental::string_view& str,
4546
const EscapeOptions& options) {
4547
StackOrHeapBuffer dest(str.size() * kMaxEscapedCharsPerChar);
4548
out.write(dest, EscapeStringToString(str, options, dest, nullptr));
4549
--- a/tools/gn/src/gn/filesystem_utils.cc
4550
+++ b/tools/gn/src/gn/filesystem_utils.cc
4551
@@ -81,8 +81,8 @@ inline char NormalizeWindowsPathChar(cha
4553
// Attempts to do a case and slash-insensitive comparison of two 8-bit Windows
4555
-bool AreAbsoluteWindowsPathsEqual(const std::string_view& a,
4556
- const std::string_view& b) {
4557
+bool AreAbsoluteWindowsPathsEqual(const std::experimental::string_view& a,
4558
+ const std::experimental::string_view& b) {
4559
if (a.size() != b.size())
4562
@@ -95,7 +95,7 @@ bool AreAbsoluteWindowsPathsEqual(const
4566
-bool DoesBeginWindowsDriveLetter(const std::string_view& path) {
4567
+bool DoesBeginWindowsDriveLetter(const std::experimental::string_view& path) {
4568
if (path.size() < 3)
4571
@@ -200,7 +200,7 @@ void AppendFixedAbsolutePathSuffix(const
4575
-size_t AbsPathLenWithNoTrailingSlash(const std::string_view& path) {
4576
+size_t AbsPathLenWithNoTrailingSlash(const std::experimental::string_view& path) {
4577
size_t len = path.size();
4580
@@ -222,7 +222,7 @@ std::string FilePathToUTF8(const base::F
4584
-base::FilePath UTF8ToFilePath(const std::string_view& sp) {
4585
+base::FilePath UTF8ToFilePath(const std::experimental::string_view& sp) {
4587
return base::FilePath(base::UTF8ToUTF16(sp));
4589
@@ -240,11 +240,11 @@ size_t FindExtensionOffset(const std::st
4590
return std::string::npos;
4593
-std::string_view FindExtension(const std::string* path) {
4594
+std::experimental::string_view FindExtension(const std::string* path) {
4595
size_t extension_offset = FindExtensionOffset(*path);
4596
if (extension_offset == std::string::npos)
4597
- return std::string_view();
4598
- return std::string_view(&path->data()[extension_offset],
4599
+ return std::experimental::string_view();
4600
+ return std::experimental::string_view(&path->data()[extension_offset],
4601
path->size() - extension_offset);
4604
@@ -256,17 +256,17 @@ size_t FindFilenameOffset(const std::str
4605
return 0; // No filename found means everything was the filename.
4608
-std::string_view FindFilename(const std::string* path) {
4609
+std::experimental::string_view FindFilename(const std::string* path) {
4610
size_t filename_offset = FindFilenameOffset(*path);
4611
if (filename_offset == 0)
4612
- return std::string_view(*path); // Everything is the file name.
4613
- return std::string_view(&(*path).data()[filename_offset],
4614
+ return std::experimental::string_view(*path); // Everything is the file name.
4615
+ return std::experimental::string_view(&(*path).data()[filename_offset],
4616
path->size() - filename_offset);
4619
-std::string_view FindFilenameNoExtension(const std::string* path) {
4620
+std::experimental::string_view FindFilenameNoExtension(const std::string* path) {
4622
- return std::string_view();
4623
+ return std::experimental::string_view();
4624
size_t filename_offset = FindFilenameOffset(*path);
4625
size_t extension_offset = FindExtensionOffset(*path);
4627
@@ -276,7 +276,7 @@ std::string_view FindFilenameNoExtension
4629
name_len = extension_offset - filename_offset - 1;
4631
- return std::string_view(&(*path).data()[filename_offset], name_len);
4632
+ return std::experimental::string_view(&(*path).data()[filename_offset], name_len);
4635
void RemoveFilename(std::string* path) {
4636
@@ -287,18 +287,18 @@ bool EndsWithSlash(const std::string& s)
4637
return !s.empty() && IsSlash(s[s.size() - 1]);
4640
-std::string_view FindDir(const std::string* path) {
4641
+std::experimental::string_view FindDir(const std::string* path) {
4642
size_t filename_offset = FindFilenameOffset(*path);
4643
if (filename_offset == 0u)
4644
- return std::string_view();
4645
- return std::string_view(path->data(), filename_offset);
4646
+ return std::experimental::string_view();
4647
+ return std::experimental::string_view(path->data(), filename_offset);
4650
-std::string_view FindLastDirComponent(const SourceDir& dir) {
4651
+std::experimental::string_view FindLastDirComponent(const SourceDir& dir) {
4652
const std::string& dir_string = dir.value();
4654
if (dir_string.empty())
4655
- return std::string_view();
4656
+ return std::experimental::string_view();
4657
int cur = static_cast<int>(dir_string.size()) - 1;
4658
DCHECK(dir_string[cur] == '/');
4660
@@ -306,9 +306,9 @@ std::string_view FindLastDirComponent(co
4662
for (; cur >= 0; cur--) {
4663
if (dir_string[cur] == '/')
4664
- return std::string_view(&dir_string[cur + 1], end - cur - 1);
4665
+ return std::experimental::string_view(&dir_string[cur + 1], end - cur - 1);
4667
- return std::string_view(&dir_string[0], end);
4668
+ return std::experimental::string_view(&dir_string[0], end);
4671
bool IsStringInOutputDir(const SourceDir& output_dir, const std::string& str) {
4672
@@ -334,7 +334,7 @@ bool EnsureStringIsInOutputDir(const Sou
4676
-bool IsPathAbsolute(const std::string_view& path) {
4677
+bool IsPathAbsolute(const std::experimental::string_view& path) {
4681
@@ -355,12 +355,12 @@ bool IsPathAbsolute(const std::string_vi
4685
-bool IsPathSourceAbsolute(const std::string_view& path) {
4686
+bool IsPathSourceAbsolute(const std::experimental::string_view& path) {
4687
return (path.size() >= 2 && path[0] == '/' && path[1] == '/');
4690
-bool MakeAbsolutePathRelativeIfPossible(const std::string_view& source_root,
4691
- const std::string_view& path,
4692
+bool MakeAbsolutePathRelativeIfPossible(const std::experimental::string_view& source_root,
4693
+ const std::experimental::string_view& path,
4694
std::string* dest) {
4695
DCHECK(IsPathAbsolute(source_root));
4696
DCHECK(IsPathAbsolute(path));
4697
@@ -504,7 +504,7 @@ base::FilePath MakeAbsoluteFilePathRelat
4698
return base::FilePath(base::JoinString(relative_components, separator));
4701
-void NormalizePath(std::string* path, const std::string_view& source_root) {
4702
+void NormalizePath(std::string* path, const std::experimental::string_view& source_root) {
4703
char* pathbuf = path->empty() ? nullptr : &(*path)[0];
4705
// top_index is the first character we can modify in the path. Anything
4706
@@ -702,7 +702,7 @@ std::string MakeRelativePath(const std::
4708
std::string RebasePath(const std::string& input,
4709
const SourceDir& dest_dir,
4710
- const std::string_view& source_root) {
4711
+ const std::experimental::string_view& source_root) {
4713
DCHECK(source_root.empty() ||
4714
!base::EndsWith(source_root, "/", base::CompareCase::SENSITIVE));
4715
@@ -715,14 +715,14 @@ std::string RebasePath(const std::string
4716
std::string input_full;
4717
std::string dest_full;
4718
if (input_is_source_path) {
4719
- input_full.append(source_root);
4720
+ input_full.append(source_root.data(), source_root.size());
4721
input_full.push_back('/');
4722
input_full.append(input, 2, std::string::npos);
4724
input_full.append(input);
4726
if (dest_dir.is_source_absolute()) {
4727
- dest_full.append(source_root);
4728
+ dest_full.append(source_root.data(), source_root.size());
4729
dest_full.push_back('/');
4730
dest_full.append(dest_dir.value(), 2, std::string::npos);
4732
@@ -784,7 +784,7 @@ template <typename StringType>
4733
std::string ResolveRelative(const StringType& input,
4734
const std::string& value,
4736
- const std::string_view& source_root) {
4737
+ const std::experimental::string_view& source_root) {
4740
if (input.size() >= 2 && input[0] == '/' && input[1] == '/') {
4741
@@ -846,15 +846,15 @@ std::string ResolveRelative(const String
4744
// Explicit template instantiation
4745
-template std::string ResolveRelative(const std::string_view& input,
4746
+template std::string ResolveRelative(const std::experimental::string_view& input,
4747
const std::string& value,
4749
- const std::string_view& source_root);
4750
+ const std::experimental::string_view& source_root);
4752
template std::string ResolveRelative(const std::string& input,
4753
const std::string& value,
4755
- const std::string_view& source_root);
4756
+ const std::experimental::string_view& source_root);
4758
std::string DirectoryWithNoLastSlash(const SourceDir& dir) {
4760
--- a/tools/gn/src/gn/filesystem_utils_unittest.cc
4761
+++ b/tools/gn/src/gn/filesystem_utils_unittest.cc
4762
@@ -424,7 +424,7 @@ TEST(FilesystemUtils, NormalizePath) {
4765
TEST(FilesystemUtils, RebasePath) {
4766
- std::string_view source_root("/source/root");
4767
+ std::experimental::string_view source_root("/source/root");
4770
EXPECT_EQ(".", RebasePath("//", SourceDir("//"), source_root));
4771
@@ -468,84 +468,84 @@ TEST(FilesystemUtils, RebasePath) {
4773
// Check when only |input| is system-absolute
4774
EXPECT_EQ("foo", RebasePath("/source/root/foo", SourceDir("//"),
4775
- std::string_view("/source/root")));
4776
+ std::experimental::string_view("/source/root")));
4777
EXPECT_EQ("foo/", RebasePath("/source/root/foo/", SourceDir("//"),
4778
- std::string_view("/source/root")));
4779
+ std::experimental::string_view("/source/root")));
4780
EXPECT_EQ("../../builddir/Out/Debug",
4781
RebasePath("/builddir/Out/Debug", SourceDir("//"),
4782
- std::string_view("/source/root")));
4783
+ std::experimental::string_view("/source/root")));
4784
EXPECT_EQ("../../../builddir/Out/Debug",
4785
RebasePath("/builddir/Out/Debug", SourceDir("//"),
4786
- std::string_view("/source/root/foo")));
4787
+ std::experimental::string_view("/source/root/foo")));
4788
EXPECT_EQ("../../../builddir/Out/Debug/",
4789
RebasePath("/builddir/Out/Debug/", SourceDir("//"),
4790
- std::string_view("/source/root/foo")));
4791
+ std::experimental::string_view("/source/root/foo")));
4792
EXPECT_EQ("../../path/to/foo", RebasePath("/path/to/foo", SourceDir("//"),
4793
- std::string_view("/source/root")));
4794
+ std::experimental::string_view("/source/root")));
4795
EXPECT_EQ("../../../path/to/foo",
4796
RebasePath("/path/to/foo", SourceDir("//a"),
4797
- std::string_view("/source/root")));
4798
+ std::experimental::string_view("/source/root")));
4799
EXPECT_EQ("../../../../path/to/foo",
4800
RebasePath("/path/to/foo", SourceDir("//a/b"),
4801
- std::string_view("/source/root")));
4802
+ std::experimental::string_view("/source/root")));
4804
// Check when only |dest_dir| is system-absolute.
4805
EXPECT_EQ(".", RebasePath("//", SourceDir("/source/root"),
4806
- std::string_view("/source/root")));
4807
+ std::experimental::string_view("/source/root")));
4808
EXPECT_EQ("foo", RebasePath("//foo", SourceDir("/source/root"),
4809
- std::string_view("/source/root")));
4810
+ std::experimental::string_view("/source/root")));
4811
EXPECT_EQ("../foo", RebasePath("//foo", SourceDir("/source/root/bar"),
4812
- std::string_view("/source/root")));
4813
+ std::experimental::string_view("/source/root")));
4814
EXPECT_EQ("../../../source/root/foo",
4815
RebasePath("//foo", SourceDir("/other/source/root"),
4816
- std::string_view("/source/root")));
4817
+ std::experimental::string_view("/source/root")));
4818
EXPECT_EQ("../../../../source/root/foo",
4819
RebasePath("//foo", SourceDir("/other/source/root/bar"),
4820
- std::string_view("/source/root")));
4821
+ std::experimental::string_view("/source/root")));
4823
// Check when |input| and |dest_dir| are both system-absolute. Also,
4824
// in this case |source_root| is never used so set it to a dummy
4826
EXPECT_EQ("foo", RebasePath("/source/root/foo", SourceDir("/source/root"),
4827
- std::string_view("/x/y/z")));
4828
+ std::experimental::string_view("/x/y/z")));
4829
EXPECT_EQ("foo/", RebasePath("/source/root/foo/", SourceDir("/source/root"),
4830
- std::string_view("/x/y/z")));
4831
+ std::experimental::string_view("/x/y/z")));
4832
EXPECT_EQ("../../builddir/Out/Debug",
4833
RebasePath("/builddir/Out/Debug", SourceDir("/source/root"),
4834
- std::string_view("/x/y/z")));
4835
+ std::experimental::string_view("/x/y/z")));
4836
EXPECT_EQ("../../../builddir/Out/Debug",
4837
RebasePath("/builddir/Out/Debug", SourceDir("/source/root/foo"),
4838
- std::string_view("/source/root/foo")));
4839
+ std::experimental::string_view("/source/root/foo")));
4840
EXPECT_EQ("../../../builddir/Out/Debug/",
4841
RebasePath("/builddir/Out/Debug/", SourceDir("/source/root/foo"),
4842
- std::string_view("/source/root/foo")));
4843
+ std::experimental::string_view("/source/root/foo")));
4844
EXPECT_EQ("../../path/to/foo",
4845
RebasePath("/path/to/foo", SourceDir("/source/root"),
4846
- std::string_view("/x/y/z")));
4847
+ std::experimental::string_view("/x/y/z")));
4848
EXPECT_EQ("../../../path/to/foo",
4849
RebasePath("/path/to/foo", SourceDir("/source/root/a"),
4850
- std::string_view("/x/y/z")));
4851
+ std::experimental::string_view("/x/y/z")));
4852
EXPECT_EQ("../../../../path/to/foo",
4853
RebasePath("/path/to/foo", SourceDir("/source/root/a/b"),
4854
- std::string_view("/x/y/z")));
4855
+ std::experimental::string_view("/x/y/z")));
4858
// Test corrections while rebasing Windows-style absolute paths.
4859
EXPECT_EQ("../../../../path/to/foo",
4860
RebasePath("C:/path/to/foo", SourceDir("//a/b"),
4861
- std::string_view("/C:/source/root")));
4862
+ std::experimental::string_view("/C:/source/root")));
4863
EXPECT_EQ("../../../../path/to/foo",
4864
RebasePath("/C:/path/to/foo", SourceDir("//a/b"),
4865
- std::string_view("C:/source/root")));
4866
+ std::experimental::string_view("C:/source/root")));
4867
EXPECT_EQ("../../../../path/to/foo",
4868
RebasePath("/C:/path/to/foo", SourceDir("//a/b"),
4869
- std::string_view("/c:/source/root")));
4870
+ std::experimental::string_view("/c:/source/root")));
4871
EXPECT_EQ("../../../../path/to/foo",
4872
RebasePath("/c:/path/to/foo", SourceDir("//a/b"),
4873
- std::string_view("c:/source/root")));
4874
+ std::experimental::string_view("c:/source/root")));
4875
EXPECT_EQ("../../../../path/to/foo",
4876
RebasePath("/c:/path/to/foo", SourceDir("//a/b"),
4877
- std::string_view("C:/source/root")));
4878
+ std::experimental::string_view("C:/source/root")));
4882
--- a/tools/gn/src/gn/function_foreach.cc
4883
+++ b/tools/gn/src/gn/function_foreach.cc
4884
@@ -62,7 +62,7 @@ Value RunForEach(Scope* scope,
4885
Err(args_vector[0].get(), "Expected an identifier for the loop var.");
4888
- std::string_view loop_var(identifier->value().value());
4889
+ std::experimental::string_view loop_var(identifier->value().value());
4891
// Extract the list to iterate over. Always copy in case the code changes
4892
// the list variable inside the loop.
4893
--- a/tools/gn/src/gn/function_forward_variables_from.cc
4894
+++ b/tools/gn/src/gn/function_forward_variables_from.cc
4895
@@ -43,10 +43,10 @@ void ForwardValuesFromList(Scope* source
4897
// Use the storage key for the original value rather than the string in
4898
// "cur" because "cur" is a temporary that will be deleted, and Scopes
4899
- // expect a persistent std::string_view (it won't copy). Not doing this
4900
+ // expect a persistent std::experimental::string_view (it won't copy). Not doing this
4901
// will lead the scope's key to point to invalid memory after this
4903
- std::string_view storage_key = source->GetStorageKey(cur.string_value());
4904
+ std::experimental::string_view storage_key = source->GetStorageKey(cur.string_value());
4905
if (storage_key.empty()) {
4906
// Programmatic value, don't allow copying.
4908
--- a/tools/gn/src/gn/function_get_path_info.cc
4909
+++ b/tools/gn/src/gn/function_get_path_info.cc
4910
@@ -77,7 +77,7 @@ std::string GetOnePathInfo(const Setting
4911
return std::string(FindExtension(&input_string));
4914
- std::string_view dir_incl_slash = FindDir(&input_string);
4915
+ std::experimental::string_view dir_incl_slash = FindDir(&input_string);
4916
if (dir_incl_slash.empty())
4917
return std::string(".");
4918
// Trim slash since this function doesn't return trailing slashes. The
4919
--- a/tools/gn/src/gn/functions.cc
4920
+++ b/tools/gn/src/gn/functions.cc
4921
@@ -135,7 +135,7 @@ bool FillTargetBlockScope(const Scope* s
4923
// Set the target name variable to the current target, and mark it used
4924
// because we don't want to issue an error if the script ignores it.
4925
- const std::string_view target_name(variables::kTargetName);
4926
+ const std::experimental::string_view target_name(variables::kTargetName);
4927
block_scope->SetValue(target_name, Value(function, args[0].string_value()),
4929
block_scope->MarkUsed(target_name);
4930
--- a/tools/gn/src/gn/generated_file_target_generator.cc
4931
+++ b/tools/gn/src/gn/generated_file_target_generator.cc
4932
@@ -68,7 +68,7 @@ bool GeneratedFileTargetGenerator::FillC
4935
bool GeneratedFileTargetGenerator::IsMetadataCollectionTarget(
4936
- const std::string_view& variable,
4937
+ const std::experimental::string_view& variable,
4938
const ParseNode* origin) {
4939
if (contents_defined_) {
4941
--- a/tools/gn/src/gn/generated_file_target_generator.h
4942
+++ b/tools/gn/src/gn/generated_file_target_generator.h
4943
@@ -35,7 +35,7 @@ class GeneratedFileTargetGenerator : pub
4944
// it is okay to set metadata collection variables on this target.
4946
// Should be called before FillContents().
4947
- bool IsMetadataCollectionTarget(const std::string_view& variable,
4948
+ bool IsMetadataCollectionTarget(const std::experimental::string_view& variable,
4949
const ParseNode* origin);
4951
bool contents_defined_ = false;
4952
--- a/tools/gn/src/gn/input_conversion.cc
4953
+++ b/tools/gn/src/gn/input_conversion.cc
4954
@@ -108,7 +108,7 @@ Value ParseList(const std::string& input
4958
-bool IsIdentifier(const std::string_view& buffer) {
4959
+bool IsIdentifier(const std::experimental::string_view& buffer) {
4960
DCHECK(buffer.size() > 0);
4961
if (!Tokenizer::IsIdentifierFirstChar(buffer[0]))
4963
@@ -147,13 +147,13 @@ Value ParseJSONValue(const Settings* set
4965
// Search for the key in the input file. We know it's present because
4966
// it was parsed by the JSON reader, but we need its location to
4967
- // construct a std::string_view that can be used as key in the Scope.
4968
+ // construct a std::experimental::string_view that can be used as key in the Scope.
4969
size_t off = input_file->contents().find("\"" + it.first + "\"");
4970
if (off == std::string::npos) {
4971
*err = Err(origin, "Invalid encoding \"" + it.first + "\".");
4974
- std::string_view key(&input_file->contents()[off + 1], it.first.size());
4975
+ std::experimental::string_view key(&input_file->contents()[off + 1], it.first.size());
4976
scope->SetValue(key, std::move(parsed_value), origin);
4978
return Value(origin, std::move(scope));
4979
--- a/tools/gn/src/gn/label.cc
4980
+++ b/tools/gn/src/gn/label.cc
4981
@@ -29,8 +29,8 @@ std::string DirWithNoTrailingSlash(const
4982
// used. The value is used only for generating error messages.
4983
bool ComputeBuildLocationFromDep(const Value& input_value,
4984
const SourceDir& current_dir,
4985
- const std::string_view& source_root,
4986
- const std::string_view& input,
4987
+ const std::experimental::string_view& source_root,
4988
+ const std::experimental::string_view& input,
4991
// No rule, use the current location.
4992
@@ -50,7 +50,7 @@ bool ComputeBuildLocationFromDep(const V
4994
bool ComputeTargetNameFromDep(const Value& input_value,
4995
const SourceDir& computed_location,
4996
- const std::string_view& input,
4997
+ const std::experimental::string_view& input,
4998
std::string* result,
5000
if (!input.empty()) {
5001
@@ -88,16 +88,16 @@ bool ComputeTargetNameFromDep(const Valu
5002
// Returns true on success. On failure, the out* variables might be written to
5003
// but shouldn't be used.
5004
bool Resolve(const SourceDir& current_dir,
5005
- const std::string_view& source_root,
5006
+ const std::experimental::string_view& source_root,
5007
const Label& current_toolchain,
5008
const Value& original_value,
5009
- const std::string_view& input,
5010
+ const std::experimental::string_view& input,
5012
std::string* out_name,
5013
SourceDir* out_toolchain_dir,
5014
std::string* out_toolchain_name,
5016
- // To workaround the problem that std::string_view operator[] doesn't return a
5017
+ // To workaround the problem that std::experimental::string_view operator[] doesn't return a
5019
const char* input_str = input.data();
5021
@@ -114,18 +114,18 @@ bool Resolve(const SourceDir& current_di
5024
size_t path_separator = input.find_first_of(":(", offset);
5025
- std::string_view location_piece;
5026
- std::string_view name_piece;
5027
- std::string_view toolchain_piece;
5028
+ std::experimental::string_view location_piece;
5029
+ std::experimental::string_view name_piece;
5030
+ std::experimental::string_view toolchain_piece;
5031
if (path_separator == std::string::npos) {
5032
location_piece = input;
5033
// Leave name & toolchain piece null.
5035
- location_piece = std::string_view(&input_str[0], path_separator);
5036
+ location_piece = std::experimental::string_view(&input_str[0], path_separator);
5038
size_t toolchain_separator = input.find('(', path_separator);
5039
if (toolchain_separator == std::string::npos) {
5040
- name_piece = std::string_view(&input_str[path_separator + 1],
5041
+ name_piece = std::experimental::string_view(&input_str[path_separator + 1],
5042
input.size() - path_separator - 1);
5043
// Leave location piece null.
5044
} else if (!out_toolchain_dir) {
5045
@@ -139,7 +139,7 @@ bool Resolve(const SourceDir& current_di
5046
// Name piece is everything between the two separators. Note that the
5047
// separators may be the same (e.g. "//foo(bar)" which means empty name.
5048
if (toolchain_separator > path_separator) {
5049
- name_piece = std::string_view(&input_str[path_separator + 1],
5050
+ name_piece = std::experimental::string_view(&input_str[path_separator + 1],
5051
toolchain_separator - path_separator - 1);
5054
@@ -154,7 +154,7 @@ bool Resolve(const SourceDir& current_di
5056
// Subtract off the two parens to just get the toolchain name.
5058
- std::string_view(&input_str[toolchain_separator + 1],
5059
+ std::experimental::string_view(&input_str[toolchain_separator + 1],
5060
input.size() - toolchain_separator - 2);
5063
@@ -254,21 +254,21 @@ Implicit names
5066
Label::Label(const SourceDir& dir,
5067
- const std::string_view& name,
5068
+ const std::experimental::string_view& name,
5069
const SourceDir& toolchain_dir,
5070
- const std::string_view& toolchain_name)
5071
+ const std::experimental::string_view& toolchain_name)
5072
: dir_(dir), toolchain_dir_(toolchain_dir) {
5073
name_.assign(name.data(), name.size());
5074
toolchain_name_.assign(toolchain_name.data(), toolchain_name.size());
5077
-Label::Label(const SourceDir& dir, const std::string_view& name) : dir_(dir) {
5078
+Label::Label(const SourceDir& dir, const std::experimental::string_view& name) : dir_(dir) {
5079
name_.assign(name.data(), name.size());
5083
Label Label::Resolve(const SourceDir& current_dir,
5084
- const std::string_view& source_root,
5085
+ const std::experimental::string_view& source_root,
5086
const Label& current_toolchain,
5089
--- a/tools/gn/src/gn/label_pattern.cc
5090
+++ b/tools/gn/src/gn/label_pattern.cc
5091
@@ -53,7 +53,7 @@ LabelPattern::LabelPattern() : type_(MAT
5093
LabelPattern::LabelPattern(Type type,
5094
const SourceDir& dir,
5095
- const std::string_view& name,
5096
+ const std::experimental::string_view& name,
5097
const Label& toolchain_label)
5098
: toolchain_(toolchain_label), type_(type), dir_(dir), name_(name) {}
5100
@@ -63,13 +63,13 @@ LabelPattern::~LabelPattern() = default;
5103
LabelPattern LabelPattern::GetPattern(const SourceDir& current_dir,
5104
- const std::string_view& source_root,
5105
+ const std::experimental::string_view& source_root,
5108
if (!value.VerifyTypeIs(Value::STRING, err))
5109
return LabelPattern();
5111
- std::string_view str(value.string_value());
5112
+ std::experimental::string_view str(value.string_value());
5114
*err = Err(value, "Label pattern must not be empty.");
5115
return LabelPattern();
5116
@@ -121,8 +121,8 @@ LabelPattern LabelPattern::GetPattern(co
5119
// Extract path and name.
5120
- std::string_view path;
5121
- std::string_view name;
5122
+ std::experimental::string_view path;
5123
+ std::experimental::string_view name;
5126
if (IsPathAbsolute(str)) {
5127
@@ -137,7 +137,7 @@ LabelPattern LabelPattern::GetPattern(co
5129
size_t colon = str.find(':', offset);
5130
if (colon == std::string::npos) {
5131
- path = std::string_view(str);
5132
+ path = std::experimental::string_view(str);
5134
path = str.substr(0, colon);
5135
name = str.substr(colon + 1);
5136
@@ -174,7 +174,7 @@ LabelPattern LabelPattern::GetPattern(co
5137
// Resolve the part of the path that's not the wildcard.
5138
if (!path.empty()) {
5139
// The non-wildcard stuff better not have a wildcard.
5140
- if (path.find('*') != std::string_view::npos) {
5141
+ if (path.find('*') != std::experimental::string_view::npos) {
5142
*err = Err(value, "Label patterns only support wildcard suffixes.",
5143
"The pattern contained a '*' that wasn't at the end.");
5144
return LabelPattern();
5145
@@ -208,7 +208,7 @@ LabelPattern LabelPattern::GetPattern(co
5148
// When we're doing wildcard matching, the name is always empty.
5149
- return LabelPattern(type, dir, std::string_view(), toolchain_label);
5150
+ return LabelPattern(type, dir, std::experimental::string_view(), toolchain_label);
5153
bool LabelPattern::HasWildcard(const std::string& str) {
5154
--- a/tools/gn/src/gn/lib_file.cc
5155
+++ b/tools/gn/src/gn/lib_file.cc
5158
LibFile::LibFile(const SourceFile& source_file) : source_file_(source_file) {}
5160
-LibFile::LibFile(const std::string_view& lib_name)
5161
+LibFile::LibFile(const std::experimental::string_view& lib_name)
5162
: name_(lib_name.data(), lib_name.size()) {
5163
DCHECK(!lib_name.empty());
5165
--- a/tools/gn/src/gn/metadata_unittest.cc
5166
+++ b/tools/gn/src/gn/metadata_unittest.cc
5167
@@ -17,8 +17,8 @@ TEST(MetadataTest, SetContents) {
5168
b_expected.list_value().push_back(Value(nullptr, true));
5170
Metadata::Contents contents;
5171
- contents.insert(std::pair<std::string_view, Value>("a", a_expected));
5172
- contents.insert(std::pair<std::string_view, Value>("b", b_expected));
5173
+ contents.insert(std::pair<std::experimental::string_view, Value>("a", a_expected));
5174
+ contents.insert(std::pair<std::experimental::string_view, Value>("b", b_expected));
5176
metadata.set_contents(std::move(contents));
5178
@@ -41,7 +41,7 @@ TEST(MetadataTest, Walk) {
5179
a_expected.list_value().push_back(Value(nullptr, "bar.h"));
5181
metadata.contents().insert(
5182
- std::pair<std::string_view, Value>("a", a_expected));
5183
+ std::pair<std::experimental::string_view, Value>("a", a_expected));
5185
std::vector<std::string> data_keys;
5186
data_keys.emplace_back("a");
5187
@@ -75,7 +75,7 @@ TEST(MetadataTest, WalkWithRebase) {
5188
a_expected.list_value().push_back(Value(nullptr, "foo/bar.h"));
5190
metadata.contents().insert(
5191
- std::pair<std::string_view, Value>("a", a_expected));
5192
+ std::pair<std::experimental::string_view, Value>("a", a_expected));
5194
std::vector<std::string> data_keys;
5195
data_keys.emplace_back("a");
5196
@@ -117,7 +117,7 @@ TEST(MetadataTest, WalkWithRebaseNonStri
5197
inner_scope.SetScopeValue(std::move(scope));
5198
a.list_value().push_back(inner_scope);
5200
- metadata.contents().insert(std::pair<std::string_view, Value>("a", a));
5201
+ metadata.contents().insert(std::pair<std::experimental::string_view, Value>("a", a));
5202
std::vector<std::string> data_keys;
5203
data_keys.emplace_back("a");
5204
std::vector<std::string> walk_keys;
5205
@@ -162,7 +162,7 @@ TEST(MetadataTest, WalkKeysToWalk) {
5206
a_expected.list_value().push_back(Value(nullptr, "//target"));
5208
metadata.contents().insert(
5209
- std::pair<std::string_view, Value>("a", a_expected));
5210
+ std::pair<std::experimental::string_view, Value>("a", a_expected));
5212
std::vector<std::string> data_keys;
5213
std::vector<std::string> walk_keys;
5214
@@ -213,7 +213,7 @@ TEST(MetadataTest, WalkNoKeysWithContent
5215
a_expected.list_value().push_back(Value(nullptr, "//target"));
5217
metadata.contents().insert(
5218
- std::pair<std::string_view, Value>("a", a_expected));
5219
+ std::pair<std::experimental::string_view, Value>("a", a_expected));
5221
std::vector<std::string> data_keys;
5222
std::vector<std::string> walk_keys;
5223
--- a/tools/gn/src/gn/metadata_walk_unittest.cc
5224
+++ b/tools/gn/src/gn/metadata_walk_unittest.cc
5225
@@ -17,12 +17,12 @@ TEST(MetadataWalkTest, CollectNoRecurse)
5226
Value a_expected(nullptr, Value::LIST);
5227
a_expected.list_value().push_back(Value(nullptr, "foo"));
5228
one.metadata().contents().insert(
5229
- std::pair<std::string_view, Value>("a", a_expected));
5230
+ std::pair<std::experimental::string_view, Value>("a", a_expected));
5232
Value b_expected(nullptr, Value::LIST);
5233
b_expected.list_value().push_back(Value(nullptr, true));
5234
one.metadata().contents().insert(
5235
- std::pair<std::string_view, Value>("b", b_expected));
5236
+ std::pair<std::experimental::string_view, Value>("b", b_expected));
5238
one.metadata().set_source_dir(SourceDir("/usr/home/files/"));
5240
@@ -30,12 +30,12 @@ TEST(MetadataWalkTest, CollectNoRecurse)
5241
Value a_2_expected(nullptr, Value::LIST);
5242
a_2_expected.list_value().push_back(Value(nullptr, "bar"));
5243
two.metadata().contents().insert(
5244
- std::pair<std::string_view, Value>("a", a_2_expected));
5245
+ std::pair<std::experimental::string_view, Value>("a", a_2_expected));
5247
Value b_2_expected(nullptr, Value::LIST);
5248
b_2_expected.list_value().push_back(Value(nullptr, false));
5249
two.metadata().contents().insert(
5250
- std::pair<std::string_view, Value>("b", b_2_expected));
5251
+ std::pair<std::experimental::string_view, Value>("b", b_2_expected));
5253
two.metadata().set_source_dir(SourceDir("/usr/home/files/inner"));
5255
@@ -75,18 +75,18 @@ TEST(MetadataWalkTest, CollectWithRecurs
5256
Value a_expected(nullptr, Value::LIST);
5257
a_expected.list_value().push_back(Value(nullptr, "foo"));
5258
one.metadata().contents().insert(
5259
- std::pair<std::string_view, Value>("a", a_expected));
5260
+ std::pair<std::experimental::string_view, Value>("a", a_expected));
5262
Value b_expected(nullptr, Value::LIST);
5263
b_expected.list_value().push_back(Value(nullptr, true));
5264
one.metadata().contents().insert(
5265
- std::pair<std::string_view, Value>("b", b_expected));
5266
+ std::pair<std::experimental::string_view, Value>("b", b_expected));
5268
TestTarget two(setup, "//foo:two", Target::SOURCE_SET);
5269
Value a_2_expected(nullptr, Value::LIST);
5270
a_2_expected.list_value().push_back(Value(nullptr, "bar"));
5271
two.metadata().contents().insert(
5272
- std::pair<std::string_view, Value>("a", a_2_expected));
5273
+ std::pair<std::experimental::string_view, Value>("a", a_2_expected));
5275
one.public_deps().push_back(LabelTargetPair(&two));
5277
@@ -124,25 +124,25 @@ TEST(MetadataWalkTest, CollectWithBarrie
5278
Value a_expected(nullptr, Value::LIST);
5279
a_expected.list_value().push_back(Value(nullptr, "foo"));
5280
one.metadata().contents().insert(
5281
- std::pair<std::string_view, Value>("a", a_expected));
5282
+ std::pair<std::experimental::string_view, Value>("a", a_expected));
5284
Value walk_expected(nullptr, Value::LIST);
5285
walk_expected.list_value().push_back(
5286
Value(nullptr, "//foo:two(//toolchain:default)"));
5287
one.metadata().contents().insert(
5288
- std::pair<std::string_view, Value>("walk", walk_expected));
5289
+ std::pair<std::experimental::string_view, Value>("walk", walk_expected));
5291
TestTarget two(setup, "//foo:two", Target::SOURCE_SET);
5292
Value a_2_expected(nullptr, Value::LIST);
5293
a_2_expected.list_value().push_back(Value(nullptr, "bar"));
5294
two.metadata().contents().insert(
5295
- std::pair<std::string_view, Value>("a", a_2_expected));
5296
+ std::pair<std::experimental::string_view, Value>("a", a_2_expected));
5298
TestTarget three(setup, "//foo:three", Target::SOURCE_SET);
5299
Value a_3_expected(nullptr, Value::LIST);
5300
a_3_expected.list_value().push_back(Value(nullptr, "baz"));
5301
three.metadata().contents().insert(
5302
- std::pair<std::string_view, Value>("a", a_3_expected));
5303
+ std::pair<std::experimental::string_view, Value>("a", a_3_expected));
5305
one.public_deps().push_back(LabelTargetPair(&two));
5306
one.public_deps().push_back(LabelTargetPair(&three));
5307
@@ -180,12 +180,12 @@ TEST(MetadataWalkTest, CollectWithError)
5308
Value a_expected(nullptr, Value::LIST);
5309
a_expected.list_value().push_back(Value(nullptr, "foo"));
5310
one.metadata().contents().insert(
5311
- std::pair<std::string_view, Value>("a", a_expected));
5312
+ std::pair<std::experimental::string_view, Value>("a", a_expected));
5314
Value walk_expected(nullptr, Value::LIST);
5315
walk_expected.list_value().push_back(Value(nullptr, "//foo:missing"));
5316
one.metadata().contents().insert(
5317
- std::pair<std::string_view, Value>("walk", walk_expected));
5318
+ std::pair<std::experimental::string_view, Value>("walk", walk_expected));
5320
UniqueVector<const Target*> targets;
5321
targets.push_back(&one);
5322
--- a/tools/gn/src/gn/operators.cc
5323
+++ b/tools/gn/src/gn/operators.cc
5324
@@ -101,7 +101,7 @@ bool ValueDestination::Init(Scope* exec_
5327
// Known to be an accessor.
5328
- std::string_view base_str = dest_accessor->base().value();
5329
+ std::experimental::string_view base_str = dest_accessor->base().value();
5331
exec_scope->GetMutableValue(base_str, Scope::SEARCH_CURRENT, false);
5333
--- a/tools/gn/src/gn/output_conversion_unittest.cc
5334
+++ b/tools/gn/src/gn/output_conversion_unittest.cc
5335
@@ -100,7 +100,7 @@ TEST_F(OutputConversionTest, StringScope
5336
// Add some values to the scope.
5337
Value value(nullptr, "hello");
5338
new_scope->SetValue("v", value, nullptr);
5339
- std::string_view private_var_name("_private");
5340
+ std::experimental::string_view private_var_name("_private");
5341
new_scope->SetValue(private_var_name, value, nullptr);
5343
std::ostringstream result;
5344
@@ -164,7 +164,7 @@ TEST_F(OutputConversionTest, ValueScope)
5345
// Add some values to the scope.
5346
Value value(nullptr, "hello");
5347
new_scope->SetValue("v", value, nullptr);
5348
- std::string_view private_var_name("_private");
5349
+ std::experimental::string_view private_var_name("_private");
5350
new_scope->SetValue(private_var_name, value, nullptr);
5352
std::ostringstream result;
5353
--- a/tools/gn/src/gn/parse_tree.cc
5354
+++ b/tools/gn/src/gn/parse_tree.cc
5355
@@ -36,7 +36,7 @@ enum DepsCategory {
5356
DEPS_CATEGORY_OTHER,
5359
-DepsCategory GetDepsCategory(std::string_view deps) {
5360
+DepsCategory GetDepsCategory(std::experimental::string_view deps) {
5361
if (deps.length() < 2 || deps[0] != '"' || deps[deps.size() - 1] != '"')
5362
return DEPS_CATEGORY_OTHER;
5364
@@ -49,19 +49,19 @@ DepsCategory GetDepsCategory(std::string
5365
return DEPS_CATEGORY_RELATIVE;
5368
-std::tuple<std::string_view, std::string_view> SplitAtFirst(
5369
- std::string_view str,
5370
+std::tuple<std::experimental::string_view, std::experimental::string_view> SplitAtFirst(
5371
+ std::experimental::string_view str,
5373
if (!base::StartsWith(str, "\"", base::CompareCase::SENSITIVE) ||
5374
!base::EndsWith(str, "\"", base::CompareCase::SENSITIVE))
5375
- return std::make_tuple(str, std::string_view());
5376
+ return std::make_tuple(str, std::experimental::string_view());
5378
str = str.substr(1, str.length() - 2);
5379
size_t index_of_first = str.find(c);
5380
return std::make_tuple(str.substr(0, index_of_first),
5381
- index_of_first != std::string_view::npos
5382
+ index_of_first != std::experimental::string_view::npos
5383
? str.substr(index_of_first + 1)
5384
- : std::string_view());
5385
+ : std::experimental::string_view());
5388
bool IsSortRangeSeparator(const ParseNode* node, const ParseNode* prev) {
5389
@@ -74,7 +74,7 @@ bool IsSortRangeSeparator(const ParseNod
5390
static_cast<int>(node->comments()->before().size() + 1)));
5393
-std::string_view GetStringRepresentation(const ParseNode* node) {
5394
+std::experimental::string_view GetStringRepresentation(const ParseNode* node) {
5395
DCHECK(node->AsLiteral() || node->AsIdentifier() || node->AsAccessor());
5396
if (node->AsLiteral())
5397
return node->AsLiteral()->value().value();
5398
@@ -82,7 +82,7 @@ std::string_view GetStringRepresentation
5399
return node->AsIdentifier()->value().value();
5400
else if (node->AsAccessor())
5401
return node->AsAccessor()->base().value();
5402
- return std::string_view();
5403
+ return std::experimental::string_view();
5407
@@ -148,7 +148,7 @@ base::Value ParseNode::CreateJSONNode(co
5410
base::Value ParseNode::CreateJSONNode(const char* type,
5411
- const std::string_view& value) const {
5412
+ const std::experimental::string_view& value) const {
5413
base::Value dict(base::Value::Type::DICTIONARY);
5414
dict.SetKey(kJsonNodeType, base::Value(type));
5415
dict.SetKey(kJsonNodeValue, base::Value(value));
5416
@@ -742,8 +742,8 @@ void ListNode::SortList(Comparator compa
5417
void ListNode::SortAsStringsList() {
5418
// Sorts alphabetically.
5419
SortList([](const ParseNode* a, const ParseNode* b) {
5420
- std::string_view astr = GetStringRepresentation(a);
5421
- std::string_view bstr = GetStringRepresentation(b);
5422
+ std::experimental::string_view astr = GetStringRepresentation(a);
5423
+ std::experimental::string_view bstr = GetStringRepresentation(b);
5427
@@ -752,8 +752,8 @@ void ListNode::SortAsDepsList() {
5428
// Sorts first relative targets, then absolute, each group is sorted
5430
SortList([](const ParseNode* a, const ParseNode* b) {
5431
- std::string_view astr = GetStringRepresentation(a);
5432
- std::string_view bstr = GetStringRepresentation(b);
5433
+ std::experimental::string_view astr = GetStringRepresentation(a);
5434
+ std::experimental::string_view bstr = GetStringRepresentation(b);
5435
return std::make_pair(GetDepsCategory(astr), SplitAtFirst(astr, ':')) <
5436
std::make_pair(GetDepsCategory(bstr), SplitAtFirst(bstr, ':'));
5438
@@ -837,7 +837,7 @@ Value LiteralNode::Execute(Scope* scope,
5439
case Token::FALSE_TOKEN:
5440
return Value(this, false);
5441
case Token::INTEGER: {
5442
- std::string_view s = value_.value();
5443
+ std::experimental::string_view s = value_.value();
5444
if ((base::StartsWith(s, "0", base::CompareCase::SENSITIVE) &&
5446
base::StartsWith(s, "-0", base::CompareCase::SENSITIVE)) {
5447
--- a/tools/gn/src/gn/parser.cc
5448
+++ b/tools/gn/src/gn/parser.cc
5449
@@ -290,7 +290,7 @@ ParserHelper Parser::expressions_[] = {
5452
Parser::Parser(const std::vector<Token>& tokens, Err* err)
5453
- : invalid_token_(Location(), Token::INVALID, std::string_view()),
5454
+ : invalid_token_(Location(), Token::INVALID, std::experimental::string_view()),
5457
for (const auto& token : tokens) {
5458
--- a/tools/gn/src/gn/path_output.cc
5459
+++ b/tools/gn/src/gn/path_output.cc
5461
#include "util/build_config.h"
5463
PathOutput::PathOutput(const SourceDir& current_dir,
5464
- const std::string_view& source_root,
5465
+ const std::experimental::string_view& source_root,
5466
EscapingMode escaping)
5467
: current_dir_(current_dir) {
5468
inverse_current_dir_ = RebasePath("//", current_dir, source_root);
5469
@@ -65,7 +65,7 @@ void PathOutput::WriteDir(std::ostream&
5471
// DIR_NO_LAST_SLASH mode, just trim the last char.
5473
- std::string_view(dir.value().data(), dir.value().size() - 1));
5474
+ std::experimental::string_view(dir.value().data(), dir.value().size() - 1));
5478
@@ -104,7 +104,7 @@ void PathOutput::WriteDir(std::ostream&
5479
file.value()[file.value().size() - 1] == '/') {
5480
// Trim trailing slash.
5481
EscapeStringToStream(
5482
- out, std::string_view(file.value().data(), file.value().size() - 1),
5483
+ out, std::experimental::string_view(file.value().data(), file.value().size() - 1),
5486
// Doesn't end with a slash, write the whole thing.
5487
@@ -121,7 +121,7 @@ void PathOutput::WriteFile(std::ostream&
5490
void PathOutput::WriteSourceRelativeString(std::ostream& out,
5491
- const std::string_view& str) const {
5492
+ const std::experimental::string_view& str) const {
5493
if (options_.mode == ESCAPE_NINJA_COMMAND) {
5494
// Shell escaping needs an intermediate string since it may end up
5495
// quoting the whole thing.
5496
@@ -132,7 +132,7 @@ void PathOutput::WriteSourceRelativeStri
5497
intermediate.append(str.data(), str.size());
5499
EscapeStringToStream(
5500
- out, std::string_view(intermediate.c_str(), intermediate.size()),
5501
+ out, std::experimental::string_view(intermediate.c_str(), intermediate.size()),
5504
// Ninja (and none) escaping can avoid the intermediate string and
5505
@@ -143,11 +143,11 @@ void PathOutput::WriteSourceRelativeStri
5508
void PathOutput::WritePathStr(std::ostream& out,
5509
- const std::string_view& str) const {
5510
+ const std::experimental::string_view& str) const {
5511
DCHECK(str.size() > 0 && str[0] == '/');
5513
if (str.substr(0, current_dir_.value().size()) ==
5514
- std::string_view(current_dir_.value())) {
5515
+ std::experimental::string_view(current_dir_.value())) {
5516
// The current dir is a prefix of the output file, so we can strip the
5517
// prefix and write out the result.
5518
EscapeStringToStream(out, str.substr(current_dir_.value().size()),
5519
--- a/tools/gn/src/gn/path_output_unittest.cc
5520
+++ b/tools/gn/src/gn/path_output_unittest.cc
5523
TEST(PathOutput, Basic) {
5524
SourceDir build_dir("//out/Debug/");
5525
- std::string_view source_root("/source/root");
5526
+ std::experimental::string_view source_root("/source/root");
5527
PathOutput writer(build_dir, source_root, ESCAPE_NONE);
5529
// Normal source-root path.
5530
@@ -56,7 +56,7 @@ TEST(PathOutput, Basic) {
5531
// Same as basic but the output dir is the root.
5532
TEST(PathOutput, BasicInRoot) {
5533
SourceDir build_dir("//");
5534
- std::string_view source_root("/source/root");
5535
+ std::experimental::string_view source_root("/source/root");
5536
PathOutput writer(build_dir, source_root, ESCAPE_NONE);
5538
// Normal source-root path.
5539
@@ -74,7 +74,7 @@ TEST(PathOutput, BasicInRoot) {
5541
TEST(PathOutput, NinjaEscaping) {
5542
SourceDir build_dir("//out/Debug/");
5543
- std::string_view source_root("/source/root");
5544
+ std::experimental::string_view source_root("/source/root");
5545
PathOutput writer(build_dir, source_root, ESCAPE_NINJA);
5547
// Spaces and $ in filenames.
5548
@@ -92,7 +92,7 @@ TEST(PathOutput, NinjaEscaping) {
5550
TEST(PathOutput, NinjaForkEscaping) {
5551
SourceDir build_dir("//out/Debug/");
5552
- std::string_view source_root("/source/root");
5553
+ std::experimental::string_view source_root("/source/root");
5554
PathOutput writer(build_dir, source_root, ESCAPE_NINJA_COMMAND);
5556
// Spaces in filenames should get quoted on Windows.
5557
@@ -145,7 +145,7 @@ TEST(PathOutput, NinjaForkEscaping) {
5559
TEST(PathOutput, InhibitQuoting) {
5560
SourceDir build_dir("//out/Debug/");
5561
- std::string_view source_root("/source/root");
5562
+ std::experimental::string_view source_root("/source/root");
5563
PathOutput writer(build_dir, source_root, ESCAPE_NINJA_COMMAND);
5564
writer.set_inhibit_quoting(true);
5566
@@ -169,7 +169,7 @@ TEST(PathOutput, InhibitQuoting) {
5567
TEST(PathOutput, WriteDir) {
5569
SourceDir build_dir("//out/Debug/");
5570
- std::string_view source_root("/source/root");
5571
+ std::experimental::string_view source_root("/source/root");
5572
PathOutput writer(build_dir, source_root, ESCAPE_NINJA);
5574
std::ostringstream out;
5575
@@ -259,7 +259,7 @@ TEST(PathOutput, WriteDir) {
5578
// Empty build dir writer.
5579
- std::string_view source_root("/source/root");
5580
+ std::experimental::string_view source_root("/source/root");
5581
PathOutput root_writer(SourceDir("//"), source_root, ESCAPE_NINJA);
5583
std::ostringstream out;
5584
--- a/tools/gn/src/gn/scope.cc
5585
+++ b/tools/gn/src/gn/scope.cc
5586
@@ -21,7 +21,7 @@ const unsigned kProcessingImportFlag = 2
5587
// Returns true if this variable name should be considered private. Private
5588
// values start with an underscore, and are not imported from "gni" files
5589
// when processing an import.
5590
-bool IsPrivateVar(const std::string_view& name) {
5591
+bool IsPrivateVar(const std::experimental::string_view& name) {
5592
return name.empty() || name[0] == '_';
5595
@@ -74,13 +74,13 @@ bool Scope::HasValues(SearchNested searc
5596
return !values_.empty();
5599
-const Value* Scope::GetValue(const std::string_view& ident,
5600
+const Value* Scope::GetValue(const std::experimental::string_view& ident,
5601
bool counts_as_used) {
5602
const Scope* found_in_scope = nullptr;
5603
return GetValueWithScope(ident, counts_as_used, &found_in_scope);
5606
-const Value* Scope::GetValueWithScope(const std::string_view& ident,
5607
+const Value* Scope::GetValueWithScope(const std::experimental::string_view& ident,
5608
bool counts_as_used,
5609
const Scope** found_in_scope) {
5610
// First check for programmatically-provided values.
5611
@@ -110,7 +110,7 @@ const Value* Scope::GetValueWithScope(co
5615
-Value* Scope::GetMutableValue(const std::string_view& ident,
5616
+Value* Scope::GetMutableValue(const std::experimental::string_view& ident,
5617
SearchNested search_mode,
5618
bool counts_as_used) {
5619
// Don't do programmatic values, which are not mutable.
5620
@@ -129,7 +129,7 @@ Value* Scope::GetMutableValue(const std:
5624
-std::string_view Scope::GetStorageKey(const std::string_view& ident) const {
5625
+std::experimental::string_view Scope::GetStorageKey(const std::experimental::string_view& ident) const {
5626
RecordMap::const_iterator found = values_.find(ident);
5627
if (found != values_.end())
5628
return found->first;
5629
@@ -137,15 +137,15 @@ std::string_view Scope::GetStorageKey(co
5630
// Search in parent scope.
5632
return containing()->GetStorageKey(ident);
5633
- return std::string_view();
5634
+ return std::experimental::string_view();
5637
-const Value* Scope::GetValue(const std::string_view& ident) const {
5638
+const Value* Scope::GetValue(const std::experimental::string_view& ident) const {
5639
const Scope* found_in_scope = nullptr;
5640
return GetValueWithScope(ident, &found_in_scope);
5643
-const Value* Scope::GetValueWithScope(const std::string_view& ident,
5644
+const Value* Scope::GetValueWithScope(const std::experimental::string_view& ident,
5645
const Scope** found_in_scope) const {
5646
RecordMap::const_iterator found = values_.find(ident);
5647
if (found != values_.end()) {
5648
@@ -157,7 +157,7 @@ const Value* Scope::GetValueWithScope(co
5652
-Value* Scope::SetValue(const std::string_view& ident,
5653
+Value* Scope::SetValue(const std::experimental::string_view& ident,
5655
const ParseNode* set_node) {
5656
Record& r = values_[ident]; // Clears any existing value.
5657
@@ -166,7 +166,7 @@ Value* Scope::SetValue(const std::string
5661
-void Scope::RemoveIdentifier(const std::string_view& ident) {
5662
+void Scope::RemoveIdentifier(const std::experimental::string_view& ident) {
5663
RecordMap::iterator found = values_.find(ident);
5664
if (found != values_.end())
5665
values_.erase(found);
5666
@@ -177,7 +177,7 @@ void Scope::RemovePrivateIdentifiers() {
5667
// currently backed by several different vendor-specific implementations and
5668
// I'm not sure if all of them support mutating while iterating. Since this
5669
// is not perf-critical, do the safe thing.
5670
- std::vector<std::string_view> to_remove;
5671
+ std::vector<std::experimental::string_view> to_remove;
5672
for (const auto& cur : values_) {
5673
if (IsPrivateVar(cur.first))
5674
to_remove.push_back(cur.first);
5675
@@ -203,7 +203,7 @@ const Template* Scope::GetTemplate(const
5679
-void Scope::MarkUsed(const std::string_view& ident) {
5680
+void Scope::MarkUsed(const std::experimental::string_view& ident) {
5681
RecordMap::iterator found = values_.find(ident);
5682
if (found == values_.end()) {
5684
@@ -227,7 +227,7 @@ void Scope::MarkAllUsed(const std::set<s
5688
-void Scope::MarkUnused(const std::string_view& ident) {
5689
+void Scope::MarkUnused(const std::experimental::string_view& ident) {
5690
RecordMap::iterator found = values_.find(ident);
5691
if (found == values_.end()) {
5693
@@ -236,7 +236,7 @@ void Scope::MarkUnused(const std::string
5694
found->second.used = false;
5697
-bool Scope::IsSetButUnused(const std::string_view& ident) const {
5698
+bool Scope::IsSetButUnused(const std::experimental::string_view& ident) const {
5699
RecordMap::const_iterator found = values_.find(ident);
5700
if (found != values_.end()) {
5701
if (!found->second.used) {
5702
@@ -298,7 +298,7 @@ bool Scope::NonRecursiveMergeTo(Scope* d
5705
for (const auto& pair : values_) {
5706
- const std::string_view& current_name = pair.first;
5707
+ const std::experimental::string_view& current_name = pair.first;
5708
if (options.skip_private_vars && IsPrivateVar(current_name))
5709
continue; // Skip this private var.
5710
if (!options.excluded_values.empty() &&
5711
--- a/tools/gn/src/gn/scope_per_file_provider.cc
5712
+++ b/tools/gn/src/gn/scope_per_file_provider.cc
5713
@@ -20,7 +20,7 @@ ScopePerFileProvider::ScopePerFileProvid
5714
ScopePerFileProvider::~ScopePerFileProvider() = default;
5716
const Value* ScopePerFileProvider::GetProgrammaticValue(
5717
- const std::string_view& ident) {
5718
+ const std::experimental::string_view& ident) {
5719
if (ident == variables::kCurrentToolchain)
5720
return GetCurrentToolchain();
5721
if (ident == variables::kDefaultToolchain)
5722
--- a/tools/gn/src/gn/scope_unittest.cc
5723
+++ b/tools/gn/src/gn/scope_unittest.cc
5724
@@ -57,7 +57,7 @@ TEST(Scope, NonRecursiveMergeTo) {
5725
// Add some values to the scope.
5726
Value old_value(&assignment, "hello");
5727
setup.scope()->SetValue("v", old_value, &assignment);
5728
- std::string_view private_var_name("_private");
5729
+ std::experimental::string_view private_var_name("_private");
5730
setup.scope()->SetValue(private_var_name, old_value, &assignment);
5732
// Add some templates to the scope.
5733
--- a/tools/gn/src/gn/setup.cc
5734
+++ b/tools/gn/src/gn/setup.cc
5735
@@ -206,7 +206,7 @@ void DecrementWorkCount() {
5739
-std::u16string SysMultiByteTo16(std::string_view mb) {
5740
+std::u16string SysMultiByteTo16(std::experimental::string_view mb) {
5742
return std::u16string();
5744
@@ -285,7 +285,7 @@ base::FilePath FindWindowsPython() {
5746
// Search for python.exe in the path.
5747
for (const auto& component : base::SplitStringPiece(
5748
- std::u16string_view(full_path.get(), path_length), u";",
5749
+ std::experimental::u16string_view(full_path.get(), path_length), u";",
5750
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) {
5751
base::FilePath candidate_exe =
5752
base::FilePath(component).Append(kPythonExeName);
5753
@@ -790,7 +790,7 @@ bool Setup::FillOtherConfig(const base::
5757
- root_target_label = Label::Resolve(current_dir, std::string_view(), Label(),
5758
+ root_target_label = Label::Resolve(current_dir, std::experimental::string_view(), Label(),
5760
if (err.has_error()) {
5761
err.PrintToStdout();
5762
--- a/tools/gn/src/gn/source_dir.cc
5763
+++ b/tools/gn/src/gn/source_dir.cc
5764
@@ -77,7 +77,7 @@ std::string SourceDir::ResolveRelativeAs
5765
const Value& blame_input_value,
5766
const StringType& input_value,
5768
- const std::string_view& source_root) const {
5769
+ const std::experimental::string_view& source_root) const {
5770
if (!ValidateResolveInput<StringType>(as_file, blame_input_value, input_value,
5772
return std::string();
5773
@@ -88,7 +88,7 @@ std::string SourceDir::ResolveRelativeAs
5774
SourceFile SourceDir::ResolveRelativeFile(
5777
- const std::string_view& source_root) const {
5778
+ const std::experimental::string_view& source_root) const {
5781
if (!p.VerifyTypeIs(Value::STRING, err))
5782
@@ -105,7 +105,7 @@ SourceFile SourceDir::ResolveRelativeFil
5783
std::string SourceDir::ResolveRelativeAs(bool as_file,
5786
- const std::string_view& source_root,
5787
+ const std::experimental::string_view& source_root,
5788
const std::string* v_value) const {
5789
if (!v.VerifyTypeIs(Value::STRING, err))
5790
return std::string();
5791
@@ -123,7 +123,7 @@ std::string SourceDir::ResolveRelativeAs
5792
SourceDir SourceDir::ResolveRelativeDir(
5795
- const std::string_view& source_root) const {
5796
+ const std::experimental::string_view& source_root) const {
5797
if (!v.VerifyTypeIs(Value::STRING, err))
5800
@@ -140,11 +140,11 @@ template std::string SourceDir::ResolveR
5801
const Value& blame_input_value,
5802
const std::string& input_value,
5804
- const std::string_view& source_root) const;
5805
+ const std::experimental::string_view& source_root) const;
5807
template std::string SourceDir::ResolveRelativeAs(
5809
const Value& blame_input_value,
5810
- const std::string_view& input_value,
5811
+ const std::experimental::string_view& input_value,
5813
- const std::string_view& source_root) const;
5814
+ const std::experimental::string_view& source_root) const;
5815
--- a/tools/gn/src/gn/source_dir_unittest.cc
5816
+++ b/tools/gn/src/gn/source_dir_unittest.cc
5817
@@ -13,9 +13,9 @@ TEST(SourceDir, ResolveRelativeFile) {
5819
SourceDir base("//base/");
5821
- std::string_view source_root("C:/source/root");
5822
+ std::experimental::string_view source_root("C:/source/root");
5824
- std::string_view source_root("/source/root");
5825
+ std::experimental::string_view source_root("/source/root");
5828
// Empty input is an error.
5829
@@ -116,9 +116,9 @@ TEST(SourceDir, ResolveRelativeDir) {
5831
SourceDir base("//base/");
5833
- std::string_view source_root("C:/source/root");
5834
+ std::experimental::string_view source_root("C:/source/root");
5836
- std::string_view source_root("/source/root");
5837
+ std::experimental::string_view source_root("/source/root");
5840
// Empty input is an error.
5841
--- a/tools/gn/src/gn/source_file.cc
5842
+++ b/tools/gn/src/gn/source_file.cc
5843
@@ -22,7 +22,7 @@ void AssertValueSourceFileString(const s
5846
SourceFile::Type GetSourceFileType(const std::string& file) {
5847
- std::string_view extension = FindExtension(&file);
5848
+ std::experimental::string_view extension = FindExtension(&file);
5849
if (extension == "cc" || extension == "cpp" || extension == "cxx")
5850
return SourceFile::SOURCE_CPP;
5851
if (extension == "h" || extension == "hpp" || extension == "hxx" ||
5852
--- a/tools/gn/src/gn/string_utils.cc
5853
+++ b/tools/gn/src/gn/string_utils.cc
5854
@@ -117,7 +117,7 @@ bool AppendInterpolatedIdentifier(Scope*
5856
std::string* output,
5858
- std::string_view identifier(&input[begin_offset], end_offset - begin_offset);
5859
+ std::experimental::string_view identifier(&input[begin_offset], end_offset - begin_offset);
5860
const Value* value = scope->GetValue(identifier, true);
5862
// We assume the input points inside the token.
5863
@@ -225,7 +225,7 @@ bool AppendHexByte(Scope* scope,
5867
- if (!base::HexStringToInt(std::string_view(&input[*i + 2], 2), &value)) {
5868
+ if (!base::HexStringToInt(std::experimental::string_view(&input[*i + 2], 2), &value)) {
5869
*err = ErrInsideStringToken(token, dollars_index, *i - dollars_index + 1,
5870
"Could not convert hex value.");
5872
@@ -287,8 +287,8 @@ bool ExpandStringLiteral(Scope* scope,
5876
-size_t EditDistance(const std::string_view& s1,
5877
- const std::string_view& s2,
5878
+size_t EditDistance(const std::experimental::string_view& s1,
5879
+ const std::experimental::string_view& s2,
5880
size_t max_edit_distance) {
5881
// The algorithm implemented below is the "classic"
5882
// dynamic-programming algorithm for computing the Levenshtein
5883
@@ -329,13 +329,13 @@ size_t EditDistance(const std::string_vi
5887
-std::string_view SpellcheckString(const std::string_view& text,
5888
- const std::vector<std::string_view>& words) {
5889
+std::experimental::string_view SpellcheckString(const std::experimental::string_view& text,
5890
+ const std::vector<std::experimental::string_view>& words) {
5891
const size_t kMaxValidEditDistance = 3u;
5893
size_t min_distance = kMaxValidEditDistance + 1u;
5894
- std::string_view result;
5895
- for (std::string_view word : words) {
5896
+ std::experimental::string_view result;
5897
+ for (std::experimental::string_view word : words) {
5898
size_t distance = EditDistance(word, text, kMaxValidEditDistance);
5899
if (distance < min_distance) {
5900
min_distance = distance;
5901
--- a/tools/gn/src/gn/string_utils_unittest.cc
5902
+++ b/tools/gn/src/gn/string_utils_unittest.cc
5903
@@ -144,7 +144,7 @@ TEST(StringUtils, EditDistance) {
5906
TEST(StringUtils, SpellcheckString) {
5907
- std::vector<std::string_view> words;
5908
+ std::vector<std::experimental::string_view> words;
5909
words.push_back("your");
5910
words.push_back("bravado");
5911
words.push_back("won\'t");
5912
--- a/tools/gn/src/gn/target_unittest.cc
5913
+++ b/tools/gn/src/gn/target_unittest.cc
5914
@@ -1154,12 +1154,12 @@ TEST(TargetTest, CollectMetadataNoRecurs
5915
Value a_expected(nullptr, Value::LIST);
5916
a_expected.list_value().push_back(Value(nullptr, "foo"));
5917
one.metadata().contents().insert(
5918
- std::pair<std::string_view, Value>("a", a_expected));
5919
+ std::pair<std::experimental::string_view, Value>("a", a_expected));
5921
Value b_expected(nullptr, Value::LIST);
5922
b_expected.list_value().push_back(Value(nullptr, true));
5923
one.metadata().contents().insert(
5924
- std::pair<std::string_view, Value>("b", b_expected));
5925
+ std::pair<std::experimental::string_view, Value>("b", b_expected));
5927
one.metadata().set_source_dir(SourceDir("/usr/home/files/"));
5929
@@ -1189,18 +1189,18 @@ TEST(TargetTest, CollectMetadataWithRecu
5930
Value a_expected(nullptr, Value::LIST);
5931
a_expected.list_value().push_back(Value(nullptr, "foo"));
5932
one.metadata().contents().insert(
5933
- std::pair<std::string_view, Value>("a", a_expected));
5934
+ std::pair<std::experimental::string_view, Value>("a", a_expected));
5936
Value b_expected(nullptr, Value::LIST);
5937
b_expected.list_value().push_back(Value(nullptr, true));
5938
one.metadata().contents().insert(
5939
- std::pair<std::string_view, Value>("b", b_expected));
5940
+ std::pair<std::experimental::string_view, Value>("b", b_expected));
5942
TestTarget two(setup, "//foo:two", Target::SOURCE_SET);
5943
Value a_2_expected(nullptr, Value::LIST);
5944
a_2_expected.list_value().push_back(Value(nullptr, "bar"));
5945
two.metadata().contents().insert(
5946
- std::pair<std::string_view, Value>("a", a_2_expected));
5947
+ std::pair<std::experimental::string_view, Value>("a", a_2_expected));
5949
one.public_deps().push_back(LabelTargetPair(&two));
5951
@@ -1231,25 +1231,25 @@ TEST(TargetTest, CollectMetadataWithBarr
5952
Value a_expected(nullptr, Value::LIST);
5953
a_expected.list_value().push_back(Value(nullptr, "foo"));
5954
one.metadata().contents().insert(
5955
- std::pair<std::string_view, Value>("a", a_expected));
5956
+ std::pair<std::experimental::string_view, Value>("a", a_expected));
5958
Value walk_expected(nullptr, Value::LIST);
5959
walk_expected.list_value().push_back(
5960
Value(nullptr, "two"));
5961
one.metadata().contents().insert(
5962
- std::pair<std::string_view, Value>("walk", walk_expected));
5963
+ std::pair<std::experimental::string_view, Value>("walk", walk_expected));
5965
TestTarget two(setup, "//foo/two:two", Target::SOURCE_SET);
5966
Value a_2_expected(nullptr, Value::LIST);
5967
a_2_expected.list_value().push_back(Value(nullptr, "bar"));
5968
two.metadata().contents().insert(
5969
- std::pair<std::string_view, Value>("a", a_2_expected));
5970
+ std::pair<std::experimental::string_view, Value>("a", a_2_expected));
5972
TestTarget three(setup, "//foo:three", Target::SOURCE_SET);
5973
Value a_3_expected(nullptr, Value::LIST);
5974
a_3_expected.list_value().push_back(Value(nullptr, "baz"));
5975
three.metadata().contents().insert(
5976
- std::pair<std::string_view, Value>("a", a_3_expected));
5977
+ std::pair<std::experimental::string_view, Value>("a", a_3_expected));
5979
one.private_deps().push_back(LabelTargetPair(&two));
5980
one.public_deps().push_back(LabelTargetPair(&three));
5981
@@ -1280,12 +1280,12 @@ TEST(TargetTest, CollectMetadataWithErro
5982
Value a_expected(nullptr, Value::LIST);
5983
a_expected.list_value().push_back(Value(nullptr, "foo"));
5984
one.metadata().contents().insert(
5985
- std::pair<std::string_view, Value>("a", a_expected));
5986
+ std::pair<std::experimental::string_view, Value>("a", a_expected));
5988
Value walk_expected(nullptr, Value::LIST);
5989
walk_expected.list_value().push_back(Value(nullptr, "//foo:missing"));
5990
one.metadata().contents().insert(
5991
- std::pair<std::string_view, Value>("walk", walk_expected));
5992
+ std::pair<std::experimental::string_view, Value>("walk", walk_expected));
5994
std::vector<std::string> data_keys;
5995
data_keys.push_back("a");
5996
--- a/tools/gn/src/gn/template.cc
5997
+++ b/tools/gn/src/gn/template.cc
5998
@@ -83,7 +83,7 @@ Value Template::Invoke(Scope* scope,
5999
invoker_value->SetScopeValue(std::move(invocation_scope));
6000
template_scope.set_source_dir(scope->GetSourceDir());
6002
- const std::string_view target_name(variables::kTargetName);
6003
+ const std::experimental::string_view target_name(variables::kTargetName);
6004
template_scope.SetValue(
6005
target_name, Value(invocation, args[0].string_value()), invocation);
6007
--- a/tools/gn/src/gn/token.cc
6008
+++ b/tools/gn/src/gn/token.cc
6011
Token::Token() : type_(INVALID), value_() {}
6013
-Token::Token(const Location& location, Type t, const std::string_view& v)
6014
+Token::Token(const Location& location, Type t, const std::experimental::string_view& v)
6015
: type_(t), value_(v), location_(location) {}
6017
bool Token::IsIdentifierEqualTo(const char* v) const {
6018
--- a/tools/gn/src/gn/tokenizer.cc
6019
+++ b/tools/gn/src/gn/tokenizer.cc
6020
@@ -32,7 +32,7 @@ bool IsScoperChar(char c) {
6021
return c == '(' || c == ')' || c == '[' || c == ']' || c == '{' || c == '}';
6024
-Token::Type GetSpecificOperatorType(std::string_view value) {
6025
+Token::Type GetSpecificOperatorType(std::experimental::string_view value) {
6027
return Token::EQUAL;
6029
@@ -106,7 +106,7 @@ std::vector<Token> Tokenizer::Run() {
6031
size_t token_end = cur_;
6033
- std::string_view token_value(&input_.data()[token_begin],
6034
+ std::experimental::string_view token_value(&input_.data()[token_begin],
6035
token_end - token_begin);
6037
if (type == Token::UNCLASSIFIED_OPERATOR) {
6038
@@ -156,7 +156,7 @@ std::vector<Token> Tokenizer::Run() {
6042
-size_t Tokenizer::ByteOffsetOfNthLine(const std::string_view& buf, int n) {
6043
+size_t Tokenizer::ByteOffsetOfNthLine(const std::experimental::string_view& buf, int n) {
6047
@@ -176,7 +176,7 @@ size_t Tokenizer::ByteOffsetOfNthLine(co
6051
-bool Tokenizer::IsNewline(const std::string_view& buffer, size_t offset) {
6052
+bool Tokenizer::IsNewline(const std::experimental::string_view& buffer, size_t offset) {
6053
DCHECK(offset < buffer.size());
6054
// We may need more logic here to handle different line ending styles.
6055
return buffer[offset] == '\n';
6056
--- a/tools/gn/src/gn/visual_studio_writer.cc
6057
+++ b/tools/gn/src/gn/visual_studio_writer.cc
6058
@@ -175,13 +175,13 @@ void ParseLinkerOptions(const Target* ta
6059
// Returns a string piece pointing into the input string identifying the parent
6060
// directory path, excluding the last slash. Note that the input pointer must
6061
// outlive the output.
6062
-std::string_view FindParentDir(const std::string* path) {
6063
+std::experimental::string_view FindParentDir(const std::string* path) {
6064
DCHECK(path && !path->empty());
6065
for (int i = static_cast<int>(path->size()) - 2; i >= 0; --i) {
6066
if (IsSlash((*path)[i]))
6067
- return std::string_view(path->data(), i);
6068
+ return std::experimental::string_view(path->data(), i);
6070
- return std::string_view();
6071
+ return std::experimental::string_view();
6074
bool FilterTargets(const BuildSettings* build_settings,
6075
@@ -699,7 +699,7 @@ void VisualStudioWriter::WriteFiltersFil
6076
filter_path_output.WriteFile(target_relative_out, *file_and_type.file);
6077
std::string target_relative_path = target_relative_out.str();
6078
ConvertPathToSystem(&target_relative_path);
6079
- std::string_view filter_path = FindParentDir(&target_relative_path);
6080
+ std::experimental::string_view filter_path = FindParentDir(&target_relative_path);
6082
if (!filter_path.empty()) {
6083
std::string filter_path_str(filter_path);
6084
@@ -808,9 +808,9 @@ void VisualStudioWriter::ResolveSolution
6085
root_folder_path_.clear();
6087
// Get all project directories. Create solution folder for each directory.
6088
- std::map<std::string_view, SolutionEntry*> processed_paths;
6089
+ std::map<std::experimental::string_view, SolutionEntry*> processed_paths;
6090
for (const std::unique_ptr<SolutionProject>& project : projects_) {
6091
- std::string_view folder_path = project->label_dir_path;
6092
+ std::experimental::string_view folder_path = project->label_dir_path;
6093
if (IsSlash(folder_path[folder_path.size() - 1]))
6094
folder_path = folder_path.substr(0, folder_path.size() - 1);
6095
auto it = processed_paths.find(folder_path);
6096
@@ -858,7 +858,7 @@ void VisualStudioWriter::ResolveSolution
6099
SolutionEntry* folder = solution_folder.get();
6100
- std::string_view parent_path;
6101
+ std::experimental::string_view parent_path;
6102
while ((parent_path = FindParentDir(&folder->path)) != root_folder_path_) {
6103
auto it = processed_paths.find(parent_path);
6104
if (it != processed_paths.end()) {
6105
--- a/tools/gn/src/gn/xcode_object.cc
6106
+++ b/tools/gn/src/gn/xcode_object.cc
6107
@@ -141,7 +141,7 @@ const SourceTypeForExt kSourceTypeForExt
6108
{"y", "sourcecode.yacc"},
6111
-const char* GetSourceType(const std::string_view& ext) {
6112
+const char* GetSourceType(const std::experimental::string_view& ext) {
6113
for (size_t i = 0; i < std::size(kSourceTypeForExt); ++i) {
6114
if (kSourceTypeForExt[i].ext == ext)
6115
return kSourceTypeForExt[i].source_type;
6116
@@ -150,11 +150,11 @@ const char* GetSourceType(const std::str
6120
-bool HasExplicitFileType(const std::string_view& ext) {
6121
+bool HasExplicitFileType(const std::experimental::string_view& ext) {
6122
return ext == "dart";
6125
-bool IsSourceFileForIndexing(const std::string_view& ext) {
6126
+bool IsSourceFileForIndexing(const std::experimental::string_view& ext) {
6127
return ext == "c" || ext == "cc" || ext == "cpp" || ext == "cxx" ||
6128
ext == "m" || ext == "mm";
6130
@@ -468,7 +468,7 @@ void PBXFileReference::Print(std::ostrea
6131
PrintProperty(out, rules, "explicitFileType", type_);
6132
PrintProperty(out, rules, "includeInIndex", 0u);
6134
- std::string_view ext = FindExtension(&name_);
6135
+ std::experimental::string_view ext = FindExtension(&name_);
6136
if (HasExplicitFileType(ext))
6137
PrintProperty(out, rules, "explicitFileType", GetSourceType(ext));
6139
@@ -548,7 +548,7 @@ PBXFileReference* PBXGroup::AddSourceFil
6142
PBXGroup* group = nullptr;
6143
- std::string_view component(navigator_path.data(), sep);
6144
+ std::experimental::string_view component(navigator_path.data(), sep);
6145
for (const auto& child : children_) {
6146
if (child->Class() != PBXGroupClass)
6148
@@ -693,7 +693,7 @@ void PBXProject::AddSourceFile(const std
6149
PBXNativeTarget* target) {
6150
PBXFileReference* file_reference =
6151
sources_->AddSourceFile(navigator_path, source_path);
6152
- std::string_view ext = FindExtension(&source_path);
6153
+ std::experimental::string_view ext = FindExtension(&source_path);
6154
if (!IsSourceFileForIndexing(ext))
6157
@@ -737,7 +737,7 @@ PBXNativeTarget* PBXProject::AddNativeTa
6158
const std::string& output_type,
6159
const std::string& shell_script,
6160
const PBXAttributes& extra_attributes) {
6161
- std::string_view ext = FindExtension(&output_name);
6162
+ std::experimental::string_view ext = FindExtension(&output_name);
6163
PBXFileReference* product = static_cast<PBXFileReference*>(
6164
products_->AddChild(std::make_unique<PBXFileReference>(
6165
std::string(), output_name,
6166
--- a/tools/gn/src/gn/xml_element_writer.cc
6167
+++ b/tools/gn/src/gn/xml_element_writer.cc
6170
XmlAttributes::XmlAttributes() = default;
6172
-XmlAttributes::XmlAttributes(const std::string_view& attr_key,
6173
- const std::string_view& attr_value) {
6174
+XmlAttributes::XmlAttributes(const std::experimental::string_view& attr_key,
6175
+ const std::experimental::string_view& attr_value) {
6176
add(attr_key, attr_value);
6179
-XmlAttributes& XmlAttributes::add(const std::string_view& attr_key,
6180
- const std::string_view& attr_value) {
6181
+XmlAttributes& XmlAttributes::add(const std::experimental::string_view& attr_key,
6182
+ const std::experimental::string_view& attr_value) {
6183
push_back(std::make_pair(attr_key, attr_value));
6186
@@ -50,7 +50,7 @@ XmlElementWriter::~XmlElementWriter() {
6190
-void XmlElementWriter::Text(const std::string_view& content) {
6191
+void XmlElementWriter::Text(const std::experimental::string_view& content) {
6192
StartContent(false);
6195
--- a/tools/gn/src/gn/rust_values_generator.cc
6196
+++ b/tools/gn/src/gn/rust_values_generator.cc
6197
@@ -184,7 +184,7 @@ bool RustTargetGenerator::FillAliasedDep
6199
// Insert into the aliased_deps map.
6200
target_->rust_values().aliased_deps().emplace(std::move(dep_label),
6202
+ std::string(pair.first.data(), pair.first.size()));
6206
--- a/tools/gn/src/gn/ninja_rust_binary_target_writer.cc
6207
+++ b/tools/gn/src/gn/ninja_rust_binary_target_writer.cc
6208
@@ -259,7 +259,7 @@ void NinjaRustBinaryTargetWriter::WriteR
6210
EscapeOptions lib_escape_opts;
6211
lib_escape_opts.mode = ESCAPE_NINJA_COMMAND;
6212
- const std::string_view lib_prefix("lib");
6213
+ const std::experimental::string_view lib_prefix("lib");
6215
// Non-Rust native dependencies.
6216
for (const auto& nonrustdep : nonrustdeps) {
6217
@@ -267,7 +267,7 @@ void NinjaRustBinaryTargetWriter::WriteR
6218
path_output_.WriteDir(
6219
out_, nonrustdep.AsSourceFile(settings_->build_settings()).GetDir(),
6220
PathOutput::DIR_NO_LAST_SLASH);
6221
- std::string_view file = FindFilenameNoExtension(&nonrustdep.value());
6222
+ std::experimental::string_view file = FindFilenameNoExtension(&nonrustdep.value());
6223
if (!file.compare(0, lib_prefix.size(), lib_prefix)) {
6225
EscapeStringToStream(out_, file.substr(lib_prefix.size()),
6226
--- a/tools/gn/src/gn/config_values_generator.cc
6227
+++ b/tools/gn/src/gn/config_values_generator.cc
6228
@@ -114,7 +114,7 @@ void ConfigValuesGenerator::Run() {
6230
// All strings must end with ".frameworks".
6231
for (const std::string& framework : frameworks) {
6232
- std::string_view framework_name = GetFrameworkName(framework);
6233
+ std::experimental::string_view framework_name = GetFrameworkName(framework);
6234
if (framework_name.empty()) {
6235
*err_ = Err(*frameworks_value,
6236
"This frameworks value is wrong."
6237
--- a/tools/gn/src/gn/frameworks_utils.cc
6238
+++ b/tools/gn/src/gn/frameworks_utils.cc
6239
@@ -13,13 +13,13 @@ const char kFrameworkExtension[] = "fram
6241
} // anonymous namespace
6243
-std::string_view GetFrameworkName(const std::string& file) {
6244
+std::experimental::string_view GetFrameworkName(const std::string& file) {
6245
if (FindFilenameOffset(file) != 0)
6246
- return std::string_view();
6247
+ return std::experimental::string_view();
6249
- std::string_view extension = FindExtension(&file);
6250
+ std::experimental::string_view extension = FindExtension(&file);
6251
if (extension != kFrameworkExtension)
6252
- return std::string_view();
6253
+ return std::experimental::string_view();
6255
return FindFilenameNoExtension(&file);
6257
--- a/tools/gn/src/gn/frameworks_utils.h
6258
+++ b/tools/gn/src/gn/frameworks_utils.h
6260
#define TOOLS_GN_FRAMEWORKS_UTILS_H_
6263
-#include <string_view>
6264
+#include <experimental/string_view>
6266
// Returns the name of the framework from a file name. This returns an empty
6267
// string_view if the name is incorrect (does not ends in ".framework", ...).
6268
-std::string_view GetFrameworkName(const std::string& file);
6269
+std::experimental::string_view GetFrameworkName(const std::string& file);
6271
#endif // TOOLS_GN_FRAMEWORKS_UTILS_H_
6272
--- a/tools/gn/src/gn/ninja_binary_target_writer.cc
6273
+++ b/tools/gn/src/gn/ninja_binary_target_writer.cc
6274
@@ -281,7 +281,7 @@ void NinjaBinaryTargetWriter::WriteLibs(
6275
for (size_t i = 0; i < all_libs.size(); i++) {
6276
const LibFile& lib_file = all_libs[i];
6277
const std::string& lib_value = lib_file.value();
6278
- std::string_view framework_name = GetFrameworkName(lib_value);
6279
+ std::experimental::string_view framework_name = GetFrameworkName(lib_value);
6280
if (lib_file.is_source_file()) {
6281
out << " " << tool->linker_arg();
6282
path_output_.WriteFile(out, lib_file.source_file());
6283
--- a/tools/gn/src/gn/ninja_target_command_util.h
6284
+++ b/tools/gn/src/gn/ninja_target_command_util.h
6285
@@ -69,7 +69,7 @@ struct FrameworksWriter {
6287
void operator()(const std::string& s, std::ostream& out) const {
6288
out << " " << tool_switch_;
6289
- std::string_view framework_name = GetFrameworkName(s);
6290
+ std::experimental::string_view framework_name = GetFrameworkName(s);
6292
if (escape_strings_) {
6294
--- a/tools/gn/src/gn/analyzer.cc
6295
+++ b/tools/gn/src/gn/analyzer.cc
6296
@@ -116,7 +116,7 @@ Label AbsoluteOrSourceAbsoluteStringToLa
6297
"\"" + s + "\" is not a source-absolute or absolute path.");
6300
- return Label::Resolve(SourceDir("//"), std::string_view(), default_toolchain,
6301
+ return Label::Resolve(SourceDir("//"), std::experimental::string_view(), default_toolchain,
6302
Value(nullptr, s), err);
6305
--- a/tools/gn/src/gn/header_checker_unittest.cc
6306
+++ b/tools/gn/src/gn/header_checker_unittest.cc
6307
@@ -405,7 +405,7 @@ TEST_F(HeaderCheckerTest, Friend) {
6308
// List A as a friend of C.
6310
c_.friends().push_back(LabelPattern::GetPattern(
6311
- SourceDir("//"), std::string_view(), Value(nullptr, "//a:*"), &err));
6312
+ SourceDir("//"), std::experimental::string_view(), Value(nullptr, "//a:*"), &err));
6313
ASSERT_FALSE(err.has_error());
6315
// Must be after setting everything up for it to find the files.
6316
--- a/tools/gn/src/gn/label_pattern_unittest.cc
6317
+++ b/tools/gn/src/gn/label_pattern_unittest.cc
6318
@@ -76,7 +76,7 @@ TEST(LabelPattern, PatternParse) {
6319
const PatternCase& cur = cases[i];
6321
LabelPattern result = LabelPattern::GetPattern(
6322
- current_dir, std::string_view(), Value(nullptr, cur.input), &err);
6323
+ current_dir, std::experimental::string_view(), Value(nullptr, cur.input), &err);
6325
EXPECT_EQ(cur.success, !err.has_error()) << i << " " << cur.input;
6326
EXPECT_EQ(cur.type, result.type()) << i << " " << cur.input;
6327
--- a/tools/gn/src/gn/label_unittest.cc
6328
+++ b/tools/gn/src/gn/label_unittest.cc
6329
@@ -82,7 +82,7 @@ TEST(Label, Resolve) {
6331
Value v(nullptr, Value::STRING);
6332
v.string_value() = cur.str;
6333
- Label result = Label::Resolve(SourceDir(cur.cur_dir), std::string_view(),
6334
+ Label result = Label::Resolve(SourceDir(cur.cur_dir), std::experimental::string_view(),
6335
default_toolchain, v, &err);
6336
EXPECT_EQ(cur.success, !err.has_error()) << i << " " << cur.str;
6337
if (!err.has_error() && cur.success) {
6338
@@ -108,7 +108,7 @@ TEST(Label, ResolveAboveRootBuildDir) {
6339
std::string source_root("/foo/bar/baz");
6341
// No source root given, should not go above the root build dir.
6342
- Label result = Label::Resolve(cur_dir, std::string_view(), default_toolchain,
6343
+ Label result = Label::Resolve(cur_dir, std::experimental::string_view(), default_toolchain,
6344
Value(nullptr, "../../..:target"), &err);
6345
EXPECT_FALSE(err.has_error());
6346
EXPECT_EQ("//", result.dir().value()) << result.dir().value();
6347
--- a/tools/gn/src/gn/string_atom.cc
6348
+++ b/tools/gn/src/gn/string_atom.cc
6349
@@ -28,7 +28,7 @@ namespace {
6351
// - a mutex to ensure correct thread-safety.
6353
-// - a find() method that takes an std::string_view argument, and uses it
6354
+// - a find() method that takes an std::experimental::string_view argument, and uses it
6355
// to find a matching entry in the string tree. If none is available,
6356
// a new std::string is allocated and its address inserted into the tree
6357
// before being returned.
6358
@@ -65,8 +65,8 @@ struct KeySet {
6361
// Compute hash for |str|. Replace with faster hash function if available.
6362
- static size_t Hash(std::string_view str) {
6363
- return std::hash<std::string_view>()(str);
6364
+ static size_t Hash(std::experimental::string_view str) {
6365
+ return std::hash<std::experimental::string_view>()(str);
6368
// Lookup for |str| with specific |hash| value.
6369
@@ -78,7 +78,7 @@ struct KeySet {
6370
// state of the KeySet, it returns a *mutable* node pointer, to be
6371
// passed to Insert() in case of a miss.
6373
- Node* Lookup(size_t hash, std::string_view str) const {
6374
+ Node* Lookup(size_t hash, std::experimental::string_view str) const {
6375
size_t index = hash & (size_ - 1);
6376
const Node* nodes = &buckets_[0];
6377
const Node* nodes_limit = nodes + size_;
6378
@@ -144,7 +144,7 @@ class StringAtomSet {
6381
// Find the unique constant string pointer for |key|.
6382
- const std::string* find(std::string_view key) {
6383
+ const std::string* find(std::experimental::string_view key) {
6384
std::lock_guard<std::mutex> lock(mutex_);
6385
size_t hash = set_.Hash(key);
6386
auto* node = set_.Lookup(hash, key);
6387
@@ -185,7 +185,7 @@ class StringAtomSet {
6389
// Init the n-th string in the slab with |str|.
6390
// Return its location as well.
6391
- std::string* init(size_t index, const std::string_view& str) {
6392
+ std::string* init(size_t index, const std::experimental::string_view& str) {
6393
std::string* result = &items_[index].str;
6394
new (result) std::string(str);
6396
@@ -212,7 +212,7 @@ class ThreadLocalCache {
6398
// Find the unique constant string pointer for |key| in this cache,
6399
// and fallback to the global one in case of a miss.
6400
- KeyType find(std::string_view key) {
6401
+ KeyType find(std::experimental::string_view key) {
6402
size_t hash = local_set_.Hash(key);
6403
auto* node = local_set_.Lookup(hash, key);
6405
@@ -233,5 +233,5 @@ thread_local ThreadLocalCache s_local_ca
6407
StringAtom::StringAtom() : value_(kEmptyString) {}
6409
-StringAtom::StringAtom(std::string_view str) noexcept
6410
+StringAtom::StringAtom(std::experimental::string_view str) noexcept
6411
: value_(*s_local_cache.find(str)) {}
6412
--- a/tools/gn/src/gn/string_atom.h
6413
+++ b/tools/gn/src/gn/string_atom.h
6416
#include <functional>
6418
+#include <experimental/string_view>
6420
// A StringAtom models a pointer to a globally unique constant string.
6423
// std::string was used.
6425
// In addition, _ordered_ containers support heterogeneous lookups (i.e.
6426
-// using an std::string_view, and by automatic conversion, a const char*
6427
+// using an std::experimental::string_view, and by automatic conversion, a const char*
6428
// of const char[] literal) as a key type.
6430
// Additionally, it is also possible to implement very fast _unordered_
6431
@@ -62,7 +63,7 @@ class StringAtom {
6432
~StringAtom() = default;
6434
// Non-explicit constructors.
6435
- StringAtom(std::string_view str) noexcept;
6436
+ StringAtom(std::experimental::string_view str) noexcept;
6438
// Copy and move operations.
6439
StringAtom(const StringAtom& other) noexcept : value_(other.value_) {}
6440
@@ -89,7 +90,7 @@ class StringAtom {
6441
const std::string& str() const { return value_; }
6443
// Implicit conversions.
6444
- operator std::string_view() const { return {value_}; }
6445
+ operator std::experimental::string_view() const { return {value_}; }
6447
// Returns true iff this is the same key.
6448
// Note that the default comparison functions compare the value instead
6449
@@ -147,7 +148,7 @@ class StringAtom {
6453
-// Ensure default heterogeneous lookups with other types like std::string_view.
6454
+// Ensure default heterogeneous lookups with other types like std::experimental::string_view.
6456
struct less<StringAtom> {
6457
using is_transparent = int;
6458
--- a/tools/gn/src/gn/string_atom_unittest.cc
6459
+++ b/tools/gn/src/gn/string_atom_unittest.cc
6460
@@ -43,9 +43,9 @@ TEST(StringAtomTest, DefaultCompare) {
6462
TEST(StringAtomTest, NormalSet) {
6463
std::set<StringAtom> set;
6464
- auto foo_ret = set.insert(std::string_view("foo"));
6465
- auto bar_ret = set.insert(std::string_view("bar"));
6466
- auto zoo_ret = set.insert(std::string_view("zoo"));
6467
+ auto foo_ret = set.insert(std::experimental::string_view("foo"));
6468
+ auto bar_ret = set.insert(std::experimental::string_view("bar"));
6469
+ auto zoo_ret = set.insert(std::experimental::string_view("zoo"));
6471
StringAtom foo_key("foo");
6472
EXPECT_EQ(*foo_ret.first, foo_key);
6473
@@ -54,8 +54,8 @@ TEST(StringAtomTest, NormalSet) {
6474
EXPECT_NE(foo_it, set.end());
6475
EXPECT_EQ(*foo_it, foo_key);
6477
- EXPECT_EQ(set.find(std::string_view("bar")), bar_ret.first);
6478
- EXPECT_EQ(set.find(std::string_view("zoo")), zoo_ret.first);
6479
+ EXPECT_EQ(set.find(std::experimental::string_view("bar")), bar_ret.first);
6480
+ EXPECT_EQ(set.find(std::experimental::string_view("zoo")), zoo_ret.first);
6482
// Normal sets are always ordered according to the key value.
6483
auto it = set.begin();
6484
@@ -74,9 +74,9 @@ TEST(StringAtomTest, NormalSet) {
6485
TEST(StringAtomTest, FastSet) {
6486
std::set<StringAtom, StringAtom::PtrCompare> set;
6488
- auto foo_ret = set.insert(std::string_view("foo"));
6489
- auto bar_ret = set.insert(std::string_view("bar"));
6490
- auto zoo_ret = set.insert(std::string_view("zoo"));
6491
+ auto foo_ret = set.insert(std::experimental::string_view("foo"));
6492
+ auto bar_ret = set.insert(std::experimental::string_view("bar"));
6493
+ auto zoo_ret = set.insert(std::experimental::string_view("zoo"));
6495
StringAtom foo_key("foo");
6496
EXPECT_EQ(*foo_ret.first, foo_key);
6497
@@ -85,8 +85,8 @@ TEST(StringAtomTest, FastSet) {
6498
EXPECT_NE(foo_it, set.end());
6499
EXPECT_EQ(*foo_it, foo_key);
6501
- EXPECT_EQ(set.find(std::string_view("bar")), bar_ret.first);
6502
- EXPECT_EQ(set.find(std::string_view("zoo")), zoo_ret.first);
6503
+ EXPECT_EQ(set.find(std::experimental::string_view("bar")), bar_ret.first);
6504
+ EXPECT_EQ(set.find(std::experimental::string_view("zoo")), zoo_ret.first);
6506
// Fast sets are ordered according to the key pointer.
6507
// Because of the underlying bump allocator, addresses
6508
--- a/tools/gn/src/gn/test_with_scope.cc
6509
+++ b/tools/gn/src/gn/test_with_scope.cc
6510
@@ -40,7 +40,7 @@ TestWithScope::~TestWithScope() = defaul
6512
Label TestWithScope::ParseLabel(const std::string& str) const {
6514
- Label result = Label::Resolve(SourceDir("//"), std::string_view(),
6515
+ Label result = Label::Resolve(SourceDir("//"), std::experimental::string_view(),
6516
toolchain_.label(), Value(nullptr, str), &err);
6517
CHECK(!err.has_error());
6519
--- a/tools/gn/src/gn/visibility.h
6520
+++ b/tools/gn/src/gn/visibility.h
6522
#define TOOLS_GN_VISIBILITY_H_
6525
-#include <string_view>
6526
+#include <experimental/string_view>
6529
#include "base/macros.h"
6530
@@ -32,7 +32,7 @@ class Visibility {
6531
// Set the visibility to the thing specified by the given value. On failure,
6532
// returns false and sets the error.
6533
bool Set(const SourceDir& current_dir,
6534
- const std::string_view& source_root,
6535
+ const std::experimental::string_view& source_root,
6539
--- a/tools/gn/src/gn/visibility_unittest.cc
6540
+++ b/tools/gn/src/gn/visibility_unittest.cc
6541
@@ -17,7 +17,7 @@ TEST(Visibility, CanSeeMe) {
6545
- ASSERT_TRUE(vis.Set(SourceDir("//"), std::string_view(), list, &err));
6546
+ ASSERT_TRUE(vis.Set(SourceDir("//"), std::experimental::string_view(), list, &err));
6548
EXPECT_FALSE(vis.CanSeeMe(Label(SourceDir("//random/"), "thing")));
6549
EXPECT_FALSE(vis.CanSeeMe(Label(SourceDir("//my/"), "notname")));
6550
@@ -37,7 +37,7 @@ TEST(Visibility, Public) {
6552
Value list(nullptr, Value::LIST);
6553
list.list_value().push_back(Value(nullptr, "*"));
6554
- ASSERT_TRUE(vis.Set(SourceDir("//"), std::string_view(), list, &err));
6555
+ ASSERT_TRUE(vis.Set(SourceDir("//"), std::experimental::string_view(), list, &err));
6557
EXPECT_TRUE(vis.CanSeeMe(Label(SourceDir("//random/"), "thing")));
6558
EXPECT_TRUE(vis.CanSeeMe(Label(SourceDir("//"), "")));
6559
@@ -46,7 +46,7 @@ TEST(Visibility, Public) {
6560
TEST(Visibility, Private) {
6563
- ASSERT_TRUE(vis.Set(SourceDir("//"), std::string_view(),
6564
+ ASSERT_TRUE(vis.Set(SourceDir("//"), std::experimental::string_view(),
6565
Value(nullptr, Value::LIST), &err));
6567
EXPECT_FALSE(vis.CanSeeMe(Label(SourceDir("//random/"), "thing")));