Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8804781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:41:41+00:00 2026-06-14T01:41:41+00:00

I have a cpp file that grabs lines and trims them but i’m getting

  • 0

I have a cpp file that grabs lines and trims them but i’m getting an error.

The error says:

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 'overloaded function type' from 'overloaded function type'

I’m not sure what it means… but this is the script…:

#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <cctype>
#include "settings.h"

using namespace std;

// trim from start
static inline std::string& line_trim(std::string& s) {

    //erase 
    s.erase(
            //pointer start location
            s.begin(),

            //find from pointer which is set to begin
                std::find_if( s.begin(), 
            //check to the end
                s.end(), 
            //look for spaces
                std::not1( std::ptr_fun<int, int>(std::isspace) ) ) );

    //return the result
        return s;
}

// trim from end
static inline std::string& end_trim(std::string& s) {

    //erase   
    s.erase(

            //find from the pointer set to end of line
                std::find_if(s.rbegin(),

            //check to the beginning (because were starting from end of line
                s.rend(), 

            //look for spaces
                std::not1(std::ptr_fun<int, int>(std::isspace))).base(),
                s.end());
        return s;
}


static inline std::string& trim(std::string &s) {
    return line_trim(end_trim(s));
}

ifstream file(std::string file_path){
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 error is occuring in the 3rd function on this like:

while(std::getline(file, line))

EDIT: This is my settings.h

#include <map>
using namespace std;

static inline std::string &line_trim(std::string&);

static inline std::string &end_trim(std::string&);

static inline std::string &trim(std::string&);

std::map<string, string> loadSettings(std::string);

Any ideas what I’m doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:41:42+00:00Added an answer on June 14, 2026 at 1:41 am

    I’m piecing two and two together based on your settings.h file… I think you’ve forgotten to write out your function header. This bit:

    ifstream file(std::string file_path){
    string line;
    
        std::map<string, string> config;
    

    should be:

    std::map<string, string> loadSettings(std::string file_path) {
        ifstream file(file_path);
        string line;
        std::map<string, string> config;
    

    With your current implementation, file is a function (because it has scope from the opening {), so it is not the expected argument to getline.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using autoconf. Right now I have an intermediate .cpp file that is
Let's assume that I have files a.cpp b.cpp and file c.h. Both of the
I have a c++ implementation file (my.cpp) that indirectly includes a header file (b.h)
I have a CPP source file that uses #if / #endif to compile out
I have a .cpp source file that contains both C and C++ code. The
I have a cpp file that contains a huge array. I get a fatal
So I have a .cpp file that uses OpenCV. I've been having some problems
I have one .cpp file that includes a few header files. These header files
I have a cpp file with functions that I'm using in python with SWIG.
I have a cpp file that contains the following: char const* types[] = {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.