-1

I have a quick question. I have read about "expected unqualified-id" errors and how they occur when a loop is outside of a method. The issue I am having is that the loop is inside a method and I am still getting this? Any assistance would be greatly appreciated.

The error in compiler:

   expected unqualified-id
for(auto template : filtered) {
         ^

The code:

py::str process(string text){
    //some code...
    for(auto template : filtered) {
        //some more....
    }
    //a return
}
Markyroson
  • 109
  • 10

1 Answers1

3

template is a reserved keyword. It's one of the few names you are not allowed to use. Change the name of your template variable to any legal identifier to fix your problem. For example, try :

py::str process(string text){
    //some code...
    for(auto my_template : filtered) {
        //some more....
    }
    //a return
}
François Andrieux
  • 28,148
  • 6
  • 56
  • 87