зеркало из https://github.com/mozilla/gecko-dev.git
a48326552c
Delete Span's implicit constructors for char* and char16_t* pointers to avoid accidental construction in cases where a pointer does not point to a zero-terminated string. Use the MakeStringSpan() function instead. I deleted both the const and non-const char* and char16_t* constructors, in the name of cross-compiler consistency. If we only delete the const char* and char16_t* constructors, for some reason, MSVC complains that `Span<char> s(charArray)` uses a deleted constructor while clang nor gcc permit it. I don't know if this is a compiler bug in MSVC or clang and gcc. Also, do not permit MakeSpan() for string literals (const char and char16_t arrays) because the Span length would include the zero terminator, which may surprise callers. Use MakeStringSpan() to create a Span whose length that excludes the string literal's zero terminator or use the MakeSpan() overload that accepts a pointer and length and specify the string literal's full length. The following Span usages are prevented: Span<const char> span("literal"); // error Span<char> span(charArray); // error Span<const char> span; span = "literal"; // error span = charArray; // error MakeSpan("literal"); // error The following Span usages are still permitted: assert(MakeStringSpan("literal") == 8); // OK: span length is calculated with strlen() and excludes the zero terminator MakeStringSpan(charArray); // OK: span length is calculated with strlen() and excludes the zero terminator MakeSpan(charArray); // OK: span length is the char array size including any zero terminator MozReview-Commit-ID: Et71CpjsiyI --HG-- extra : rebase_source : f6f8bdb28726f0f2368fdfdd039fb1d7dcf2914e extra : source : 0547d8924ffc7713d6cf32cc06eeeaf00e0d69a3 |
||
---|---|---|
.. | ||
gtest | ||
TestArray.cpp | ||
TestArrayUtils.cpp | ||
TestAtomics.cpp | ||
TestBinarySearch.cpp | ||
TestBloomFilter.cpp | ||
TestBufferList.cpp | ||
TestCasting.cpp | ||
TestCeilingFloor.cpp | ||
TestCheckedInt.cpp | ||
TestCountPopulation.cpp | ||
TestCountZeroes.cpp | ||
TestDefineEnum.cpp | ||
TestDoublyLinkedList.cpp | ||
TestEndian.cpp | ||
TestEnumSet.cpp | ||
TestEnumTypeTraits.cpp | ||
TestEnumeratedArray.cpp | ||
TestFastBernoulliTrial.cpp | ||
TestFloatingPoint.cpp | ||
TestIntegerPrintfMacros.cpp | ||
TestIntegerRange.cpp | ||
TestJSONWriter.cpp | ||
TestLinkedList.cpp | ||
TestMacroArgs.cpp | ||
TestMacroForEach.cpp | ||
TestMathAlgorithms.cpp | ||
TestMaybe.cpp | ||
TestNotNull.cpp | ||
TestPair.cpp | ||
TestPoisonArea.cpp | ||
TestRange.cpp | ||
TestRefPtr.cpp | ||
TestResult.cpp | ||
TestRollingMean.cpp | ||
TestSHA1.cpp | ||
TestSaturate.cpp | ||
TestScopeExit.cpp | ||
TestSegmentedVector.cpp | ||
TestSmallPointerArray.cpp | ||
TestSplayTree.cpp | ||
TestTemplateLib.cpp | ||
TestTuple.cpp | ||
TestTypeTraits.cpp | ||
TestTypedEnum.cpp | ||
TestUniquePtr.cpp | ||
TestVariant.cpp | ||
TestVector.cpp | ||
TestWeakPtr.cpp | ||
TestXorShift128PlusRNG.cpp | ||
moz.build |