error C2275: 'std::vector<_Ty>' : illegal use of this type as an expression

  • Thread starter Thread starter Jeyatharsini
  • Start date Start date
J

Jeyatharsini

Guest
This is my code:

#include "stdafx.h"

#include <codecvt>
#include <cstdio>
#include <locale>
#include <sstream>
#include <string>
#include <vector>
#include <iostream>

using namespace std;

string toMultiByte(const wstring &original)
{
wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
return converter.to_bytes(original);
}

int main()
{
string original = "This:is\nmy:tst?why I hate";
string separators = ":? \n"

//vector<wstring> results = splitMany(original, separators);
vector <wstring> wordVector;
stringstream stream(original);
string line;

while (getline(stream, line))
{
std::size_t prev = 0, pos;
while ((pos = line.find_first_of(separators, prev)) != std::string::npos)
{
if (pos > prev)
wordVector.push_back(line.substr(prev, pos-prev));
prev = pos + 1;
}
if (prev < line.length())
wordVector.push_back(line.substr(prev, std::string::npos));
}
}

It gives the error error C2275: std::vector<_Ty> : illegal use of this type as an expression. I googled for it. There were issues like not including namespace & headers. But I have added those things. Still its not working. Im pointless of this error. Help me to resolve this.

Continue reading...
 
Back
Top