I have a piece of code which loads text file contents into a char *. (I know it's an odd mix of C++ and C but please bear with me.)
std::ifstream filestream1(filename);
std::string str1(std::istreambuf_iterator<char>(filestream1),
(std::istreambuf_iterator<char>()) );
GLchar * code1 = (GLchar *) malloc(sizeof(GLchar) * str1.length());
strcpy(code1, str1.c_str());
Previously I was getting an "expression musy have class type" error on str1 variable after this version of the line:
std::string str1(std::istreambuf_iterator<char>(filestream1),
std::istreambuf_iterator<char>() );
//str1 causes "expression must have class type" errors
Clearly, adding extra brackets (which seemed redundant to me, to be honest), fixed the problem. Question is, what exactly changed between one and the other? This isn't one of those "declaring a function instead of instantiating a class" mistakes, is it? I mean can one even declare a function with no name and inside a function call, and no [] like a lambda?