[Rcpp-devel] How to efficiently remove some words from a big vector of strings.

contact AG STUDY contact at ag-study.com
Sun Dec 22 14:46:00 CET 2013

I am trying to write an efficient c++ function to remove some words from a
big vector of strings.
Here my code using stl :

vector<std::string> stripWords(vector<std::string>& input,
                  std::set<std::string>& toRemove){
     remove_if(input.begin(), input.end(),
                 [&toRemove](const std::string& x) -> bool {
                     return toRemove.find(x) != toRemove.end();

But I get this warning about using lambda expression and this template

 warning: lambda expressions only available with -std=c++0x or -std=gnu++0x
[enabled by default]
 error: no matching function for call to
'remove_if(std::vector<std::basic_string<char> >::iterator,
std::vector<std::basic_string<char> >::iterator,
stripWords(std::vector<std::basic_string<char> >&,
std::set<std::basic_string<char> >&)::<lambda(const string&)>)'

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20131222/7e911c1a/attachment.html>

More information about the Rcpp-devel mailing list