#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>

using namespace std;

istream& get_cell(istream& is, string& s)
{
  char c;
  is >> c; // skips ws
  is.unget();

  if (c == '\'')
    return is >> quoted(s, '\'', '\\');
  else
    return getline(is, s, ','), is.unget();
}

vector<string> get(const string& s)
{
  istringstream iss{ s };
  string cell;
  vector<string> r;
  while (get_cell(iss, cell))
  {
    r.push_back(cell);
    char comma;
    iss >> comma;
    if (comma != ',')
      break;
  }

  char c; 
  if (iss >> c)
    throw "ill formed";

  return r;
}

int main()
{
  string s = "1, 10, 'abc', 'test, 1'";
  try
  {
    auto v = get(s);
    copy (v.begin(), v.end(), ostream_iterator<string>(cout,"\n"));
   }
  catch (const char* e)
  {
    cout << e;
  }
}