diff --git a/uppsrc/Core/Map.h b/uppsrc/Core/Map.h index 804d07638..646938376 100644 --- a/uppsrc/Core/Map.h +++ b/uppsrc/Core/Map.h @@ -235,7 +235,8 @@ public: VectorMap() {} VectorMap(std::initializer_list> init) : B::AMap(init) {} - VectorMap& operator()(const K& k, const T& v) { B::Add(k, v); return *this; } + template + VectorMap& operator()(KK&& k, TT&& v) { B::Add(std::forward(k), std::forward(v)); return *this; } friend void Swap(VectorMap& a, VectorMap& b) { a.B::Swap(b); } @@ -279,7 +280,8 @@ public: ArrayMap(std::initializer_list> init) : B::AMap(init) {} - ArrayMap& operator()(const K& k, const T& v) { Add(k, v); return *this; } + template + ArrayMap& operator()(KK&& k, TT&& v) { Add(std::forward(k), std::forward(v)); return *this; } friend void Swap(ArrayMap& a, ArrayMap& b) { a.B::Swap(b); } diff --git a/uppsrc/Core/src.tpp/ArrayMap_en-us.tpp b/uppsrc/Core/src.tpp/ArrayMap_en-us.tpp index 2b0ac23ea..1f86a844c 100644 --- a/uppsrc/Core/src.tpp/ArrayMap_en-us.tpp +++ b/uppsrc/Core/src.tpp/ArrayMap_en-us.tpp @@ -61,11 +61,12 @@ d`::pair]<[*@4 K], [*@4 T]>>_[*@3 init])&] [s2; C`+`+ 11 initialization.&] [s3; &] [s4;%- &] -[s5;:Upp`:`:ArrayMap`:`:operator`(`)`(const K`&`,const T`&`):%- [*_^Upp`:`:ArrayMap^ Ar -rayMap][@(0.0.255) `&]_[* operator()]([@(0.0.255) const]_[*@4 K][@(0.0.255) `&]_[*@3 k], -[@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 v])&] +[s5;:Upp`:`:ArrayMap`:`:operator`(`)`(KK`&`&`,TT`&`&`):%- [@(0.0.255) template]_<[@(0.0.255) c +lass]_[*@4 KK], [@(0.0.255) class]_[*@4 TT]>_[*_^Upp`:`:ArrayMap^ ArrayMap][@(0.0.255) `&]_ +[* operator()]([*@4 KK][@(0.0.255) `&`&]_[*@3 k], [*@4 TT][@(0.0.255) `&`&]_[*@3 v])&] [s2; Same as Add([%-*@3 k], [%-*@3 v]), returns `*this. Syntax sugar -for creating map.&] +for creating map. Note the use of universal reference that gets +resolved to correct Add variant.&] [s3; &] [s4;%- &] [s5;:ArrayMap`:`:ArrayMap`(const ArrayMap`&`,int`):%- [* ArrayMap]([@(0.0.255) const]_[* Ar diff --git a/uppsrc/Core/src.tpp/VectorMap_en-us.tpp b/uppsrc/Core/src.tpp/VectorMap_en-us.tpp index 96a38c255..89a6eb687 100644 --- a/uppsrc/Core/src.tpp/VectorMap_en-us.tpp +++ b/uppsrc/Core/src.tpp/VectorMap_en-us.tpp @@ -62,11 +62,12 @@ td`::pair]<[*@4 K], [*@4 T]>>_[*@3 init])&] [s2; C`+`+ 11 initialization.&] [s3; &] [s4;%- &] -[s5;:Upp`:`:VectorMap`:`:operator`(`)`(const K`&`,const T`&`):%- [*_^Upp`:`:VectorMap^ V -ectorMap][@(0.0.255) `&]_[* operator()]([@(0.0.255) const]_[*@4 K][@(0.0.255) `&]_[*@3 k], -[@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 v])&] +[s5;:Upp`:`:VectorMap`:`:operator`(`)`(KK`&`&`,TT`&`&`):%- [@(0.0.255) template]_<[@(0.0.255) c +lass]_[*@4 KK], [@(0.0.255) class]_[*@4 TT]>_[_^Upp`:`:VectorMap^ VectorMap][@(0.0.255) `&]_ +[* operator()]([*@4 KK][@(0.0.255) `&`&]_[*@3 k], [*@4 TT][@(0.0.255) `&`&]_[*@3 v])&] [s2; Same as Add([%-*@3 k], [%-*@3 v]), returns `*this. Syntax sugar -for creating map.&] +for creating map. Note the use of universal reference that gets +resolved to correct Add variant.&] [s3; &] [s4;%- &] [s5;:VectorMap`:`:VectorMap`(const VectorMap`&`,int`):%- [* VectorMap]([@(0.0.255) const]_