简体   繁体   中英

How to use boost::algorithm::join with std::vector of objects?

I understand the use of boost::algorithm::join on a vector of std::string but how do I use it for an std::vector<std::unique_ptr<Foo>> ?

I guess I'm looking for some kind of apply function that I can pass in a lambda so I can transform the std::unique_ptr to std::string.

Looking are the source code of join , it seems there's no way to do that. The return value must be of range_value<SequenceSequenceT>::type type which maps to std::unique_ptr<Foo> in your case. You can std::transform your vector to std::vector<std::string> , which is a bit of a waste. Alternatively you could implement your own version of join that applies the transformation itself as it goes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM