Mohan
Mohan

Reputation: 473

No instance of constructor error in CPP

I tried to create a function to identify matched line from a string. My whole string is saved in strStart and strToMatch contains the search string. Following is my code

void ExpertContextUser::removeMatchedString() {
        String line;
        String strStart="Testing\nReturns\nrelated\nresources";
        String strToMatch="Test";
        istringstream streamAddtText(strStart);
        while(std::getline(streamAddtText, line)) {
                cout << line << "Function" << endl;
                if(line.index(strToMatch) > 0) {
                        TraceMessage <<" Test Success" << endl;
                }
        }
}

when i am compiling my code, i am getting following error

"../user_model_impl.cxx", line 234: error #2289: no instance of constructor "std::basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream [with _CharT=char, _Traits=std::char_traits, _Allocator=std::allocator]" matches the argument list argument types are: (RWCString) istringstream streamAddtText(strStart);

I am unable to find reasons for this error.

Upvotes: 1

Views: 3296

Answers (1)

Marius Bancila
Marius Bancila

Reputation: 16318

The error happens because the istringstream constructor takes a std::string, not a RWCString. You need to provide a conversion from RWCString to std::string if you want this to work.

Upvotes: 5

Related Questions