Hi,
I like to run simple macros directly within the CINT interpreter, and rather often while in development phase. However, when using functions from c++ standard library, I get errors when running a macro two (or more) times within the same CINT session. This is something really annoying because I need to quit and restart the session every time I want to rerun the macro…
For example, for the macro below:
#include <sstream>
#include <string>
using namespace std;
void test(){
istringstream is("a,e,i,o,u");
string st;
while(getline(is,st,','))
cout << st << endl;
}
this is the output when run two times in a row within the same session:
root [0] .x test.C
a
e
i
o
u
root [1] .x test.C
In file included from input_line_13:1:
/Users/sevilla/cernbox/Documents/UNIGE/TEACHING/COURS/Electronics/WORK/macros/scope/test.C:8:17: error: no matching constructor for initialization of 'std::__1::istringstream' (aka 'basic_istringstream<char>')
istringstream is("a,e,i,o,u");
^ ~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/iosfwd:120:32: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const char [10]' to 'const std::__1::basic_istringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >' for 1st argument
class _LIBCPP_TEMPLATE_VIS basic_istringstream;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/sstream:649:14: note: candidate constructor not viable: no known conversion from 'const char [10]' to 'ios_base::openmode' (aka 'unsigned int') for 1st argument
explicit basic_istringstream(ios_base::openmode __wch = ios_base::in);
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/sstream:655:5: note: candidate constructor not viable: no known conversion from 'const char [10]' to 'std::__1::basic_istringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >' for 1st argument
basic_istringstream(basic_istringstream&& __rhs);
^
ROOT Version: 6.22/08
Platform: macosx64, x86_64-apple-darwin18.7.0
Compiler: clang version 11.0.0 (clang-1100.0.33.17)