2016-09-23 77 views
3

我想使用Borland的32位编译器编译MySql ++。众所周知,该编译器在某些模板语法方面存在问题。编译器也几乎已经过时,因为它正在被clang编译器取代。如何为Borland编译器重写C++模板代码

但是,如果以下代码可以固定到可编译版本中,则时间将被保存。

在下面的行发生的编译器错误:

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

编译器错误是:

[bcc32错误] mystring.h(726):的“字符串E2506显式专业化:: CONV <类型>(类型)const的”不明确:必须指定模板参数
全解析器上下文
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):命名空间mysqlpp

String是一个自定义字符串类,而conv()功能是String的类内的联模板函数:

/// \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()); 
} 

我已经试过各种修改,但没有成功。

+0

您是否尝试过这些建议?:http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devwin32/compile_errambigtspec_xml.html – mike

+2

是否'模板<> MYSQLPP_EXPORT布尔字符串:: CONV (布尔)const;'工作? – NathanOliver

+0

谢谢NathanOliver。这工作完美!我怎样才能让你的评论是正确的答案? –

回答

0

对此答案予以nathanoliver

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

这种沉默的bcc32编译器给定的...!