【发布时间】:2017-02-01 14:08:36
【问题描述】:
我正在尝试使用 Borland 的 32 位编译器编译 MySql++。众所周知,此编译器在某些模板语法方面存在问题。编译器也几乎过时了,因为它正在被 clang 编译器所取代。
但是,如果可以将以下代码修复为可编译版本,则可以节省时间。
编译器错误发生在以下行:
template <> MYSQLPP_EXPORT bool String::conv(bool) const;
编译错误是:
[bcc32 错误] mystring.h(726): E2506 'String::conv
(Type) const' 的显式特化不明确:必须指定模板参数
完整的解析器上下文
transaction.cpp(32): #include lib\query.h
query.h(37): #include lib\result.h
结果.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());
}
我尝试了各种修改,但都没有成功。
【问题讨论】:
-
template <> MYSQLPP_EXPORT bool String::conv<bool>(bool) const;工作吗? -
感谢内森奥利弗。效果很好!如何让您的评论成为正确答案?
-
mike,我在看那个 embarcadero 的帮助。我很困惑它只给出了一半的答案,也就是说 foo
而不是完整的答案,foo (int)。对我来说并不明显。 -
@TotteKarlsson:“我怎样才能让你的评论成为正确答案?”——你不能。您或 Nathan 都必须发布单独的答案(是的,您可以针对自己的问题发布自己的答案)。
标签: c++ c++builder mysql++