3

I'm trying to compile MySql++ using Borland's 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 the 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;

The 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, but with no success.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Totte Karlsson
  • 1,261
  • 1
  • 20
  • 55
  • Have you tried those suggestions?: http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devwin32/compile_errambigtspec_xml.html – mike Sep 23 '16 at 16:29
  • 2
    Does `template <> MYSQLPP_EXPORT bool String::conv(bool) const;` work? – NathanOliver Sep 23 '16 at 16:29
  • Thanks NathanOliver. That worked perfectly! How can I make your comment the correct answer? – Totte Karlsson Sep 23 '16 at 16:46
  • mike, I was looking at that embarcadero help. I was confused it only giving half the answer, that is saying foo instead of full answer, foo(int). Not obvious to me. – Totte Karlsson Sep 23 '16 at 16:48
  • @TotteKarlsson: "*How can I make your comment the correct answer?*" - you cannot. Either you or Nathan will have to post a separate answer (yes, you can post your own answers to your own questions). – Remy Lebeau Sep 28 '16 at 20:43

1 Answers1

0

This answer was given by nathanoliver

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

This silence the bcc32 compiler...!

Totte Karlsson
  • 1,261
  • 1
  • 20
  • 55