mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1309466 - Enable Array and EnumeratedArray to be brace-initialized with initial contents. r=froydnj
MozReview-Commit-ID: 9sD9Rg4qsy1 --HG-- extra : rebase_source : bef928bca14e6d1a0a207359acfa56ecd93d605b
This commit is contained in:
parent
0819c4e347
commit
6178d3ca29
11
mfbt/Array.h
11
mfbt/Array.h
@ -11,6 +11,7 @@
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Move.h"
|
||||
#include "mozilla/ReverseIterator.h"
|
||||
|
||||
#include <stddef.h>
|
||||
@ -23,6 +24,16 @@ class Array
|
||||
T mArr[Length];
|
||||
|
||||
public:
|
||||
Array() {}
|
||||
|
||||
template <typename... Args>
|
||||
MOZ_IMPLICIT Array(Args&&... aArgs)
|
||||
: mArr{mozilla::Forward<Args>(aArgs)...}
|
||||
{
|
||||
static_assert(sizeof...(aArgs) == Length,
|
||||
"The number of arguments should be equal to the template parameter Length");
|
||||
}
|
||||
|
||||
T& operator[](size_t aIndex)
|
||||
{
|
||||
MOZ_ASSERT(aIndex < Length);
|
||||
|
@ -54,6 +54,11 @@ private:
|
||||
public:
|
||||
EnumeratedArray() {}
|
||||
|
||||
template <typename... Args>
|
||||
MOZ_IMPLICIT EnumeratedArray(Args&&... aArgs)
|
||||
: mArray{mozilla::Forward<Args>(aArgs)...}
|
||||
{}
|
||||
|
||||
explicit EnumeratedArray(const EnumeratedArray& aOther)
|
||||
{
|
||||
for (size_t i = 0; i < kSize; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user