I am working on replacing multiple overrides of a function within a legacy code base (all of which are virtual), with a single template signature.
My template function is as follows:
Code:
template <typename T1, typename T2> void fn_data_access_base::var_fld_add(T1 nam, T2 val)
{
// Set the db field up
sis_db_fld tmp_sis_db_fld( val, nam );
assert( !selector_impl_ptr_ ||
( selector_impl_ptr_ &&
selector_impl_ptr_->fld_find( tmp_sis_db_fld ) ) );
// Update the field
input_fld_rpl_or_append( tmp_sis_db_fld );
}
The Sun compiler complains as follows...
Code:
"/vobs/VDPS_Dev/online/base_src/Server/fn/fndal/dabase.cpp", line 1610: Error: Overloading ambiguity between "sis_db_fld::sis_db_fld(const bool, const sis_c_str&)" and "sis_db_fld::sis_db_fld(const char, const sis_c_str&)".
"/vobs/VDPS_Dev/online/base_src/Server/fn/fndal/fndbase.cpp", line 75: Where: While instantiating "fn_data_access_base::var_fld_add<const char*, int>(const char*, int)".
"/vobs/VDPS_Dev/online/base_src/Server/fn/fndal/fndbase.cpp", line 75: Where: Instantiated from fn_data_abstract_base::var_fld_add<const char*, int>(const char*, int).
"/vobs/VDPS_Dev/online/base_src/Server/fn/fnelog/elog.cpp", line 268: Where: Instantiated from non-template code.
1 Error(s) and 1 Warning(s) detected.
*** Error code 1
It is my understanding that the compiler ought to be able to distinguish between all native types within the template when calling the sis_db_fld constructor, thus I should not experience ambiguity.
I have tried making the sis_db_fld constructors that match the ambiguous signatures 'explicit' but this keywork has no effect when construction is from within a template.
I have tried retaining non template versions of var_fld_add that use the specific types identified as ambiguous. Again this does not work?
I do not understand why it fails to do so?
Please help. I have hit a brick wall with this one!