summaryrefslogtreecommitdiff
path: root/mfbt/Vector.h
diff options
context:
space:
mode:
Diffstat (limited to 'mfbt/Vector.h')
-rw-r--r--mfbt/Vector.h42
1 files changed, 21 insertions, 21 deletions
diff --git a/mfbt/Vector.h b/mfbt/Vector.h
index 6d5c769e9d..b75a5d8a04 100644
--- a/mfbt/Vector.h
+++ b/mfbt/Vector.h
@@ -129,7 +129,7 @@ struct VectorImpl
* aNewCap has not overflowed, and (2) multiplying aNewCap by sizeof(T) will
* not overflow.
*/
- static inline MOZ_MUST_USE bool
+ [[nodiscard]] static inline bool
growTo(Vector<T, N, AP>& aV, size_t aNewCap)
{
MOZ_ASSERT(!aV.usingInlineStorage());
@@ -221,7 +221,7 @@ struct VectorImpl<T, N, AP, true>
}
}
- static inline MOZ_MUST_USE bool
+ [[nodiscard]] static inline bool
growTo(Vector<T, N, AP>& aV, size_t aNewCap)
{
MOZ_ASSERT(!aV.usingInlineStorage());
@@ -290,9 +290,9 @@ class MOZ_NON_PARAM Vector final : private AllocPolicy
friend struct detail::VectorTesting;
- MOZ_MUST_USE bool growStorageBy(size_t aIncr);
- MOZ_MUST_USE bool convertToHeapStorage(size_t aNewCap);
- MOZ_MUST_USE bool maybeCheckSimulatedOOM(size_t aRequestedSize);
+ [[nodiscard]] bool growStorageBy(size_t aIncr);
+ [[nodiscard]] bool convertToHeapStorage(size_t aNewCap);
+ [[nodiscard]] bool maybeCheckSimulatedOOM(size_t aRequestedSize);
/* magic constants */
@@ -618,7 +618,7 @@ public:
* Given that the vector is empty, grow the internal capacity to |aRequest|,
* keeping the length 0.
*/
- MOZ_MUST_USE bool initCapacity(size_t aRequest);
+ [[nodiscard]] bool initCapacity(size_t aRequest);
/**
* Given that the vector is empty, grow the internal capacity and length to
@@ -627,7 +627,7 @@ public:
* rounding that happens in resize and overhead of initialization for elements
* that are about to be overwritten.
*/
- MOZ_MUST_USE bool initLengthUninitialized(size_t aRequest);
+ [[nodiscard]] bool initLengthUninitialized(size_t aRequest);
/**
* If reserve(aRequest) succeeds and |aRequest >= length()|, then appending
@@ -637,7 +637,7 @@ public:
* A request to reserve an amount less than the current length does not affect
* reserved space.
*/
- MOZ_MUST_USE bool reserve(size_t aRequest);
+ [[nodiscard]] bool reserve(size_t aRequest);
/**
* Destroy elements in the range [end() - aIncr, end()). Does not deallocate
@@ -652,18 +652,18 @@ public:
void shrinkTo(size_t aNewLength);
/** Grow the vector by aIncr elements. */
- MOZ_MUST_USE bool growBy(size_t aIncr);
+ [[nodiscard]] bool growBy(size_t aIncr);
/** Call shrinkBy or growBy based on whether newSize > length(). */
- MOZ_MUST_USE bool resize(size_t aNewLength);
+ [[nodiscard]] bool resize(size_t aNewLength);
/**
* Increase the length of the vector, but don't initialize the new elements
* -- leave them as uninitialized memory.
*/
- MOZ_MUST_USE bool growByUninitialized(size_t aIncr);
+ [[nodiscard]] bool growByUninitialized(size_t aIncr);
void infallibleGrowByUninitialized(size_t aIncr);
- MOZ_MUST_USE bool resizeUninitialized(size_t aNewLength);
+ [[nodiscard]] bool resizeUninitialized(size_t aNewLength);
/** Shorthand for shrinkBy(length()). */
void clear();
@@ -693,13 +693,13 @@ public:
* vector, instead of copying it. If it fails, |aU| is left unmoved. ("We are
* not amused.")
*/
- template<typename U> MOZ_MUST_USE bool append(U&& aU);
+ template<typename U> [[nodiscard]] bool append(U&& aU);
/**
* Construct a T in-place as a new entry at the end of this vector.
*/
template<typename... Args>
- MOZ_MUST_USE bool emplaceBack(Args&&... aArgs)
+ [[nodiscard]] bool emplaceBack(Args&&... aArgs)
{
if (!growByUninitialized(1))
return false;
@@ -708,10 +708,10 @@ public:
}
template<typename U, size_t O, class BP>
- MOZ_MUST_USE bool appendAll(const Vector<U, O, BP>& aU);
- MOZ_MUST_USE bool appendN(const T& aT, size_t aN);
- template<typename U> MOZ_MUST_USE bool append(const U* aBegin, const U* aEnd);
- template<typename U> MOZ_MUST_USE bool append(const U* aBegin, size_t aLength);
+ [[nodiscard]] bool appendAll(const Vector<U, O, BP>& aU);
+ [[nodiscard]] bool appendN(const T& aT, size_t aN);
+ template<typename U> [[nodiscard]] bool append(const U* aBegin, const U* aEnd);
+ template<typename U> [[nodiscard]] bool append(const U* aBegin, size_t aLength);
/*
* Guaranteed-infallible append operations for use upon vectors whose
@@ -755,7 +755,7 @@ public:
*
* N.B. Although a T*, only the range [0, length()) is constructed.
*/
- MOZ_MUST_USE T* extractRawBuffer();
+ [[nodiscard]] T* extractRawBuffer();
/**
* If elements are stored in-place, allocate a new buffer, move this vector's
@@ -773,7 +773,7 @@ public:
* If any of these elements are uninitialized (as growByUninitialized
* enables), behavior is undefined.
*/
- MOZ_MUST_USE T* extractOrCopyRawBuffer();
+ [[nodiscard]] T* extractOrCopyRawBuffer();
/**
* Transfer ownership of an array of objects into the vector. The caller
@@ -801,7 +801,7 @@ public:
* This is inherently a linear-time operation. Be careful!
*/
template<typename U>
- MOZ_MUST_USE T* insert(T* aP, U&& aVal);
+ [[nodiscard]] T* insert(T* aP, U&& aVal);
/**
* Removes the element |aT|, which must fall in the bounds [begin, end),