
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Alexander Shyrokov Sent: 19 September 2006 14:19 To: boost-users@lists.boost.org Subject: [Boost-users] converting value before inserting into a list
I want to convert values according to a map before inserting it into the list. What is a proper way to do that? I have this:
map
m; vector<int> a,b; for(vector<int>const_iterator i=a.begin();i!=a.end();++i) b.push_back(m[*i]);
I could use std::copy with std::back_inserter to add elements to b, but how do I convert it first? Should I write my own version of back_inserter for that?
copy(a.begin(),a.end(),my_back_inserter(b,m));
Thanks. -- Regards, Alexander. http://sjcomp.com _______________________________________________
I probably being very anti-modern C++ here, but I think that the for loop takes a lot of beating for readability......its probably the most efficient too (with a bit of cacheing of invarients)...... I do find that some of these so called 'helpers' do make the code more obscure, but that's perhaps because I have spent 15 years doing C then C++, rather than solely starting with C++. James
Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
This message (including any attachments) contains confidential and/or proprietary information intended only for the addressee. Any unauthorized disclosure, copying, distribution or reliance on the contents of this information is strictly prohibited and may constitute a violation of law. If you are not the intended recipient, please notify the sender immediately by responding to this e-mail, and delete the message from your system. If you have any questions about this e-mail please notify the sender immediately.