How to make std::vector from other vector with specific filter?

后端 未结 2 1296
梦谈多话
梦谈多话 2021-01-07 22:34

I have a std::vector filled with objects. I want to filter and copy all the elements for which some predicate returns true in to a new std::v

相关标签:
2条回答
  • 2021-01-07 22:43

    If you have C++11 then use std::copy_if as suggested in Eugen's answer. Otherwise, you can use std::remove_copy_if with appropriate modifications to your predicate's logic.

    0 讨论(0)
  • 2021-01-07 23:04

    you can use the std::copy_if method. See here.

    0 讨论(0)
提交回复
热议问题