Totte Karlsson Totte Karlsson - 25 days ago 4x
C++ Question

How to rewrite C++ template code for CodeGear compiler

I'm trying to compile MySql++ using borlands 32 bit compiler. This compiler is well known to have problems with some template syntax. The compiler is also almost obsolete as it is being replaced with clang compiler. However, if the following code can be fixed into a compilable version, time would be saved.

The compiler error occurs at the following line:

template <> MYSQLPP_EXPORT bool String::conv(bool) const;

and compiler error is

[bcc32 Error] mystring.h(726): E2506 Explicit specialization of 'String::conv<Type>(Type) const' is ambiguous: must specify template arguments
Full parser context
transaction.cpp(32): #include lib\query.h
query.h(37): #include lib\result.h
result.h(40): #include lib\row.h
row.h(33): #include lib\mystring.h
mystring.h(46): namespace mysqlpp

String is a custom string class, and the conv function is an inline template function within the String class:

/// \brief Template for converting the column data to most any
/// numeric data type.
template <class Type>
Type conv(Type) const
// Conversions are done using one of double/long/ulong/llong/ullong
// so we call a helper function to do the work using that type.
// This reduces the amount of template code instantiated.
typedef typename detail::conv_promotion<Type>::type conv_type;
return do_conv<conv_type>(typeid(Type).name());

I've tried various modifications with no success.


This answer was given by nathanoliver

 template <> MYSQLPP_EXPORT bool String::conv<bool>(bool) const;

This silence the bcc32 compiler...!