This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
problems with conversion function
- From: Oliver Kullmann <O dot Kullmann at Swansea dot ac dot uk>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 21 Nov 2002 22:33:59 +0000
- Subject: problems with conversion function
Hi,
nearly every time I'm using a conversion function it does not work, so I basically
stopped using conversion functions, but this evening I'm pretty determined --- I have
to know what's going on!
Unfortunately, I have never been able to reproduce the error with a small example, so
here's the error message I get (I'm using gcc version 3.0.4 (SuSE)):
submission.cpp: In function `CgiHandling::Transfer_codes transfer(const
CgiHandling::ValueMap&, const std::string&)':
submission.cpp:257: no matching function for call to
`SystemHandling::PidType::PidType(AutomatedCompilation::Compilation<AutomatedCompilation::gpc_delphi_transfer,
AutomatedCompilation::Environment_wwwrun,
AutomatedCompilation::both_outputs,
AutomatedCompilation::unchanged_source_file,
AutomatedCompilation::transfer_source_name> (&)(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >))'
SystemHandling.hpp:317: candidates
are: SystemHandling::PidType::PidType(const SystemHandling::PidType&)
SystemHandling.hpp:319:
SystemHandling::PidType::PidType()
the offending line 257 (in submission.cpp) is:
Pid = (PidType) C;
(where I get the same error for other forms:
Pid = C; Pid = PidType(C);),
where we have the declaration
PidType Pid;
and
Compilation
<gpc_delphi_transfer, Environment_wwwrun, both_outputs, unchanged_source_file, transfer_source_name>
C (unchanged_source_file::Source_file_data(program_full_name), transfer_source_name::Executable_file_data(base_compilation));
(sorry for the mess, but I don't know what's wrong here, so I included everything)
while in the class template Compilation a conversion function is declared:
template
< class Compiler, class Environment, class Compiler_Output, class Source, class Executable >
class Compilation : public Compiler, public Environment, public Compiler_Output, public Source, public Executable {
public :
operator SystemHandling::PidType() const { return Pid; }
private :
SystemHandling::PidType Pid;
};
One sees, that the compiler, when seeing
Pid = (PidType) C;
only looks out for a constructor for class PidType (there is an explicitely defined default constructor,
while the copy assignment operator is defined implicitly), but ignores the conversion function
defined in class Compilation. WHY???
I would be glad for any help!
Oliver