我有以下代码,其中 Boost.Local 使用函数回调来加载 mo 文件。该函数对我来说称为 findMo,我正在尝试将它绑定到一个对象,这样我就可以保留我放在 moFinder 的私有成员中的副作用。
class moFinder
{
public:
moFinder(string const& wantedFormat)
: format(wantedFormat)
{
// ...
}
std::vector<char> findMo(std::string const& filePath, std::string const& encoding)
{
// ...
}
};
std::locale createLocale(string const& name, string const& customTranslation,
string const& path, string const& domain, string const& pathFormat)
{
// ...
namespace blg = boost::locale::gnu_gettext;
blg::messages_info info;
info.paths.push_back(path);
info.domains.push_back(blg::messages_info::domain(domain));
moFinder finder(pathFormat);
blg::messages_info::callback_type callbackFunc;
callbackFunc = boost::bind(moFinder::findMo, boost::ref(finder));
info.callback = callbackFunc;
// ...
}
编译时出现以下错误:
错误:无效使用非静态成员函数'std::vector moFinder::findMo(const std::string&, const std::string&)'</p>
在我调用 boost::bind 的那一行。
我在做什么才值得这个错误?