I am calling a function from within a function and passing a parameter as a const reference through both. When I compile I get warned (and also by the intellisense) that it is
binding of reference to type basic_string
What's going on?
I thought I understood the situation, but I guess I'm not clear on it. These answers (1, 2, 3) all touch on forms of this problem.
I thought because the parameter of the calling function is a const &
and it's being passed as a const &
, I should be good. a snippet of my code is below.
My function definition:
std::string joinPathAndFile(const std::string &path, const std::string &fname)
{
boost::filesystem::path b_fname (fname);
boost::filesystem::path b_path (path);
boost::filesystem::path b_full_path = b_path / b_fname;
return b_full_path.string();
}
void myFunction(const std::string &path)
{
std::string file = joinPathAndFile(path, "fname.txt");
std::cout << file << std::endl;
}
int main()
{
myFunction("/path/to/");
}