Core: VectorMap/Array map all operator() variants added (via universal reference)

git-svn-id: svn://ultimatepp.org/upp/trunk@13542 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2019-08-13 15:09:27 +00:00
parent 2ccc34e131
commit 3482045007
3 changed files with 14 additions and 10 deletions

View file

@ -235,7 +235,8 @@ public:
VectorMap() {}
VectorMap(std::initializer_list<std::pair<K, T>> init) : B::AMap(init) {}
VectorMap& operator()(const K& k, const T& v) { B::Add(k, v); return *this; }
template <class KK, class TT>
VectorMap& operator()(KK&& k, TT&& v) { B::Add(std::forward<KK>(k), std::forward<TT>(v)); return *this; }
friend void Swap(VectorMap& a, VectorMap& b) { a.B::Swap(b); }
@ -279,7 +280,8 @@ public:
ArrayMap(std::initializer_list<std::pair<K, T>> init) : B::AMap(init) {}
ArrayMap& operator()(const K& k, const T& v) { Add(k, v); return *this; }
template <class KK, class TT>
ArrayMap& operator()(KK&& k, TT&& v) { Add(std::forward<KK>(k), std::forward<TT>(v)); return *this; }
friend void Swap(ArrayMap& a, ArrayMap& b) { a.B::Swap(b); }

View file

@ -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

View file

@ -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]_