バージョン 1.34.1 の boost::filesystem を使用するレガシー コードをここにいくつか持っています。私はそれを小さなテストプログラムに分離しました:
#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) バージョンの Boost でコンパイルしようとすると、次のエラーが発生します。
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 ドキュメントの表と裏を作成しようとしましたが、その 2 番目のパラメーターが何に適しているのか、何に置き換えればよいのかわかりません。誰でもこれに光を当てることができますか?
更新:要件についてはよくわかりませんでした。少なくとも移行期間中は、両方のバージョン (1.34.1 と 1.46.1) をサポートする必要があります。Boost の両方のバージョンを同じコードでカバーする互換性のある方法はありますか、それとも#if BOOST_VERSION
魔法に頼る必要がありますか?
更新 2:#if BOOST_VERSION ...
これ以上の意見は出されていないため使用されます。助けてくれてありがとう。