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

contact AG STUDY contact at ag-study.com
Sun Dec 22 16:57:02 CET 2013


Sorry, I am new to this list, I sent again the mail to you rather to the
mailing list.
I prefer to ask my question in SO but I don't want to to bother others with
too specific rcpp questions.


My bad. I did that (std::) but  I had to fix the the warning before.
I am developing a package so I add

PKG_CXXFLAGS = "-std=c++0x"

to both : makevars and makevars.win.

Thanks.


On Sun, Dec 22, 2013 at 4:48 PM, contact AG STUDY <contact at ag-study.com>wrote:

> My bad. I did that (std::) but  I had to fix the the warning before.
> I am developing a package so I add
>
> PKG_CXXFLAGS = "-std=c++0x"
>
> to both : makevars and makevars.win.
>
> Thanks.
>
>
>
> On Sun, Dec 22, 2013 at 3:31 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
>>
>> Please keep follow-up questions on the list where I am replying to now.
>>
>> On 22 December 2013 at 15:20, contact AG STUDY wrote:
>> | Impressive!Thanks for this fast answer.
>> |
>> | |  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&)>)'
>> |
>> | You said : Try prefixing it with  std::  as you did with the things
>> from the
>> | std
>> | namespace.
>> |
>> | I am afraid to say , I don't understand what do you mean here? How can
>> I fix
>> | it?
>>
>> Instead of calling
>>
>>         remove_if( ... many arguments ... )
>>
>> call
>>
>>         std::remove_if( ... many arguments ... )
>>
>> Dirk
>>
>>
>> | On Sun, Dec 22, 2013 at 3:14 PM, Dirk Eddelbuettel <edd at debian.org>
>> wrote:
>> |
>> |
>> |     On 22 December 2013 at 14:46, contact AG STUDY wrote:
>> |     | 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){
>> |     | input.erase(
>> |     |      remove_if(input.begin(), input.end(),
>> |     |                  [&toRemove](const std::string& x) -> bool {
>> |     |                      return toRemove.find(x) != toRemove.end
>> |     ();
>> |     |                  }),input.end());
>> |     | }
>> |     |
>> |     | But I get this warning about using lambda expression and this
>> template
>> |     error.
>> |     |
>> |     |
>> |     |  warning: lambda expressions only available with -std=c++0x or
>> -std=
>> |     gnu++0x
>> |     | [enabled by default]
>> |
>> |     R is (by default) not configured to use C++11. We are slowly moving
>> towards
>> |     getting that changed (ie see NEWS in the R-devel sources).
>> |
>> |     For the time being you can either
>> |
>> |      i)   for all R sessions, set the required option as an argument to
>> |     CXXFLAGS in
>> |           ~/.R/Makevars, or its system-wide equivalent, or another
>> script
>> |     where
>> |           you set environment variables
>> |
>> |      ii)  if you use Rcpp Attributes, use `[[Rcpp::plugins(cpp11)]]`
>> and see
>> |           `help(pluginsAttribute)`  for details
>> |
>> |      iii) for a package use src/Makevars or src/Makevars.win
>> |
>> |     |  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&)>)'
>> |
>> |     Try prefixing it with  std::  as you did with the things from the
>> std
>> |     namespace.
>> |
>> |     Dirk
>> |
>> |     --
>> |     Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
>> |
>> |
>>
>> --
>> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20131222/379248b1/attachment.html>


More information about the Rcpp-devel mailing list