我在这里有一些遗留代码,它使用1.34.1版本中的boost :: filesystem。我孤立它变成一个小的测试程序:boost :: filesystem:从1.34.1更新为当前
#include <iostream>
#include <boost/filesystem/path.hpp>
int main()
{
// note the second parameter
boost::filesystem::path p("/tmp/foo", boost::filesystem::native);
std::cout << p.string() << std::endl;
return 0;
}
当我尝试编译这段代码升压的电流(1.46.1)版本,我得到以下错误:
test.cpp: In function ‘int main()’:
test.cpp:7: error: invalid conversion from ‘bool (*)(const std::string&)’ to ‘void*’
test.cpp:7: error: initializing argument 2 of ‘boost::filesystem3::path::path(const Source&, typename boost::enable_if<boost::filesystem3::path_traits::is_pathable<typename boost::decay<T>::type>, void>::type*) [with Source = char [9]]’
我试图制作Boost文档的正面或反面,但我似乎无法弄清楚第二个参数是好还是什么,或者用什么来代替它。任何人都可以对此有所了解吗?
更新:我对要求并不十分清楚。对于至少一个过渡期,我将不得不支持版本(1.34.1和1.46.1)两个版本。有没有兼容的方式来覆盖两个版本的Boost使用相同的代码,或者我将不得不求助于#if BOOST_VERSION
魔法?
UPDATE 2:使用#if BOOST_VERSION ...
因为没有进一步的意见即将到来。谢谢您的帮助。
这非常有帮助,如果我对这些要求不是太模糊的话,它会获得“正确答案”复选标记。查看更新的问题。 – DevSolar 2011-04-06 14:43:17