N
Noah Roberts
In a significant code base I'm running into this problem:
This works:
test_service service;
std::string result = job->run_query(service);
This does not.:
std::string result = job->run_query(test_service());
the run_query function expects a const reference to test_service's
base class:
struct location_job
{
virtual ~location_job() {}
virtual std::string run_query(location_service const& service) const
= 0;
};
The error I get from g++4.1.2 is:
pipe_processor_test.cpp:142: error: no matching function for call to
âtest_service::test_service(test_service)â
.../inc/test_service.h:27: note: candidates are:
test_service::test_service(bool)
.../inc/test_service.h:7: note:
test_service::test_service(test_service&)
The bool constructor is made by me, but the non-const copy constructor
is the compiler's. Line 7 is the opening brace for the class.
I can't make any sense of this. Does anyone have ANY idea what might
be going on so I can try to narrow it down and create a minimal
example to get better help? The attempts I've made so far work
fine.
Under what conditions in which the first could work might the second
not when the parameter is const ref? I can't think of any.
Thanks for any help that can be provided. I know it's a reach.
This works:
test_service service;
std::string result = job->run_query(service);
This does not.:
std::string result = job->run_query(test_service());
the run_query function expects a const reference to test_service's
base class:
struct location_job
{
virtual ~location_job() {}
virtual std::string run_query(location_service const& service) const
= 0;
};
The error I get from g++4.1.2 is:
pipe_processor_test.cpp:142: error: no matching function for call to
âtest_service::test_service(test_service)â
.../inc/test_service.h:27: note: candidates are:
test_service::test_service(bool)
.../inc/test_service.h:7: note:
test_service::test_service(test_service&)
The bool constructor is made by me, but the non-const copy constructor
is the compiler's. Line 7 is the opening brace for the class.
I can't make any sense of this. Does anyone have ANY idea what might
be going on so I can try to narrow it down and create a minimal
example to get better help? The attempts I've made so far work
fine.
Under what conditions in which the first could work might the second
not when the parameter is const ref? I can't think of any.
Thanks for any help that can be provided. I know it's a reach.