no instance of overloaded function getline c++
- by Dave
I'm a bit confused as to what i have incorrect with my script that is causing this error.
I have a function which calls a fill for game settings but it doesn't like my getline.
Also i should mention these are the files i have included for it:
#include <fstream>
#include <cctype>
#include <map>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;'
This is what i have:
std::map<string, string> loadSettings(std::string file){
ifstream file(file);
string line;
std::map<string, string> config;
while(std::getline(file, line))
{
int pos = line.find('=');
if(pos != string::npos)
{
string key = line.substr(0, pos);
string value = line.substr(pos + 1);
config[trim(key)] = trim(value);
}
}
return (config);
}
The function is called like this from my main.cpp
//load settings for game
std::map<string, string> config = loadSettings("settings.txt");
//load theme for game
std::map<string, string> theme = loadSettings("theme.txt");
Where did i go wrong ? Please help!
The error:
settings.h(61): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::string'