diff --git a/uppsrc/Core/Vcont.h b/uppsrc/Core/Vcont.h index a2792c5ef..d9360c246 100644 --- a/uppsrc/Core/Vcont.h +++ b/uppsrc/Core/Vcont.h @@ -98,7 +98,7 @@ public: T& Add(const T& x) { return items < alloc ? *(new(Rdd()) T(clone(x))) : GrowAdd(x); } T& Add(T&& x) { return items < alloc ? *(::new(Rdd()) T(pick(x))) : GrowAddPick(pick(x)); } template - T& Create(Args... args) { if(items >= alloc) GrowF(); return *(::new(Rdd()) T(args...)); } + T& Create(Args&&... args) { if(items >= alloc) GrowF(); return *(::new(Rdd()) T(std::forward(args)...)); } void AddN(int n); const T& operator[](int i) const { return Get(i); } T& operator[](int i) { return Get(i); } @@ -243,7 +243,7 @@ public: T& Add(T&& x) { T *q = new T(pick(x)); vector.Add(q); return *q; } T& Add(T *newt) { vector.Add(newt); return *newt; } template - TT& Create(Args... args) { TT *q = new TT(args...); Add(q); return *q; } + TT& Create(Args&&... args) { TT *q = new TT(std::forward(args)...); Add(q); return *q; } const T& operator[](int i) const { return Get(i); } T& operator[](int i) { return Get(i); } int GetCount() const { return vector.GetCount(); } diff --git a/uppsrc/Core/src.tpp/Array_en-us.tpp b/uppsrc/Core/src.tpp/Array_en-us.tpp index f10bee783..04a2586f3 100644 --- a/uppsrc/Core/src.tpp/Array_en-us.tpp +++ b/uppsrc/Core/src.tpp/Array_en-us.tpp @@ -121,12 +121,11 @@ can be either T or a type derived from T. No constructor is applied. [s7; [*/ Return value]-|Reference to the new element (that is [* `*newt]).&] [s0;*%- &] [s4;%- &] -[s5;:Array`:`:Create`(`):%- [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 TT][@(0.0.255) >]_ -[*@4 TT][@(0.0.255) `&]_[* Create]()&] -[s2; Creates and adds a new element to the Array.&] -[s6; Requires T to have default constructor.&] -[s7; [*C@4 TT]-|Type of the new element.&] -[s7; [*/ Return value]-|Reference to the newly created element.&] +[s5;:Upp`:`:Array`:`:Create`(Args`&`&`.`.`.args`):%- [@(0.0.255) template]_<[@(0.0.255) c +lass]_[*@4 TT], [@(0.0.255) class...]_[*@4 Args]>_[*@4 TT][@(0.0.255) `&]_[* Create]([*@4 Args][@(0.0.255) `& +`&...]_[*@3 args])&] +[s2; Creates and adds a new element to the Array. [%-*@3 args] are +forwarded to constructor.&] [s3;%- &] [s4;%- &] [s5;:Array`:`:operator`[`]`(int`)const:%- [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[* operat diff --git a/uppsrc/Core/src.tpp/Vector_en-us.tpp b/uppsrc/Core/src.tpp/Vector_en-us.tpp index 0bc7e764f..d9882cef8 100644 --- a/uppsrc/Core/src.tpp/Vector_en-us.tpp +++ b/uppsrc/Core/src.tpp/Vector_en-us.tpp @@ -106,6 +106,12 @@ s...]_[*@4 Args]>_[*@4 T][@(0.0.255) `&]_[* Create]([*@4 Args][@(0.0.255) ...]_a &] [s3; &] [s4;%- &] +[s5;:Upp`:`:Vector`:`:Create`(Args`&`&`.`.`.args`):%- [@(0.0.255) template]_<[@(0.0.255) c +lass...]_[*@4 Args]>_[*@4 T][@(0.0.255) `&]_[* Create]([*@4 Args][@(0.0.255) `&`&...]_args)&] +[s2; Creates and adds a new element to the Array. [%-*@3 args] are +forwarded to constructor.&] +[s3; &] +[s4;%- &] [s5;:Vector`:`:AddN`(int`):%- [@(0.0.255) void]_[* AddN]([@(0.0.255) int]_[*@3 n])&] [s2; Adds specified number of default constructed elements to Vector.&] [s6; Requires T to have default constructor.&]