Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Initializing a map...
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Sam, post: 3450592"] You can subclass it, and define an operator function. template<typename keyType, typename valType> class myMap : public std::map<keyType, valType> { public: myMap<keyType, valType> &operator()(keyType k, valType v) { (*this)[k]=v; return *this; }; }; You can initialize these objects as follows: myMap<int, int> z=myMap<int, int>()(3, 4)(5, 6); ... and so on. You can use these objects anywhere std::map is acceptable. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQBHvMUyx9p3GYHlUOIRAr9AAJ0Z1htKkfWKFdWGK/Qi6WDcGYNA3ACbB7mO 8LABhHnbT/QP8M2HfUwxzxM= =4zSY -----END PGP SIGNATURE----- [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Initializing a map...
Top