Issue
I'm using ROOT in jupyter notebook and have a problem when defining the following function:
#include <vector>
#include <string>
#include <iostream>
//---cell separation---
using namespace std;
//---cell separation---
vector<string> split(string input, char delim){
vector<string> ret;
string temp;
for(char letter:input){
if(letter!=delim){
temp+= letter;
}else{
ret.push_back(temp);
temp.clear();
}
}
ret.push_back(temp);
return ret;
}
The jupyter cell returns an error message as follows:
error: function definition is not allowed here
vector< string> split(string input, char delim){ ^
and the split function isn't defined. I however write the same code and can compile it by local g++, and it works normally.
Is it a known ROOT bug? I think the function definition may be interpreted as some instanciation of a vector object.
I'm looking for alternative ways to avoid this problem.
Solution
This board (https://github.com/QuantStack/xeus-cling/issues/40) gives me an alternative way such as using auto or typedef to replace "vector< string>" and it works.
Answered By - user10680480
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.