1 // Copyright 2020 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_STRINGS_STRCAT_WIN_H_ 6 #define BASE_STRINGS_STRCAT_WIN_H_ 7 8 #include <initializer_list> 9 #include <string> 10 11 #include "base/base_export.h" 12 #include "base/compiler_specific.h" 13 #include "base/containers/span.h" 14 #include "base/strings/string_piece.h" 15 16 namespace base { 17 18 // The following section contains overloads of the cross-platform APIs for 19 // std::wstring and base::WStringPiece. These are only enabled if std::wstring 20 // and base::string16 are distinct types, as otherwise this would result in an 21 // ODR violation. 22 // TODO(crbug.com/911896): Remove those guards once base::string16 is 23 // std::u16string. 24 #if defined(BASE_STRING16_IS_STD_U16STRING) 25 BASE_EXPORT void StrAppend(std::wstring* dest, span<const WStringPiece> pieces); 26 BASE_EXPORT void StrAppend(std::wstring* dest, span<const std::wstring> pieces); 27 StrAppend(std::wstring * dest,std::initializer_list<WStringPiece> pieces)28inline void StrAppend(std::wstring* dest, 29 std::initializer_list<WStringPiece> pieces) { 30 StrAppend(dest, make_span(pieces)); 31 } 32 33 BASE_EXPORT std::wstring StrCat(span<const WStringPiece> pieces) 34 WARN_UNUSED_RESULT; 35 BASE_EXPORT std::wstring StrCat(span<const std::wstring> pieces) 36 WARN_UNUSED_RESULT; 37 StrCat(std::initializer_list<WStringPiece> pieces)38inline std::wstring StrCat(std::initializer_list<WStringPiece> pieces) { 39 return StrCat(make_span(pieces)); 40 } 41 #endif // defined(BASE_STRING16_IS_STD_U16STRING) 42 43 } // namespace base 44 45 #endif // BASE_STRINGS_STRCAT_WIN_H_ 46