次のコードがあります。
boost::filesystem::path p = boost::filesystem::current_path();
しかし、g ++からこのエラーが発生します:
filesystem.cc: In function ‘int main(int, char**)’:
filesystem.cc:11: error: no matching function for call to ‘current_path()’
/usr/include/boost/filesystem/operations.hpp:769: note: candidates are: void boost::filesystem::current_path(const boost::filesystem::path&)
/usr/include/boost/filesystem/operations.hpp:771: note: void boost::filesystem::current_path(const boost::filesystem::wpath&)
/usr/include/boost/filesystem/operations.hpp には、次のものがあります。
template< class Path >
Path current_path()
{
typename Path::external_string_type ph;
system::error_code ec( detail::get_current_path_api( ph ) );
if ( ec )
boost::throw_exception( basic_filesystem_error<Path>(
"boost::filesystem::current_path", ec ) );
return Path( Path::traits_type::to_internal( ph ) );
}
だから機能はそこにあります。ブーストのドキュメントの例と同じように使用しています。ここで私が見逃している愚かなものはありますか?「.」でパスを作成すると機能しますが、「.」だけでなく完全なパス名が必要です。
RedHat Enterprise 6.2 に g++ 4.4.6 とブースト 1.41.0 があります (古いことはわかっていますが、アップグレードするオプションはありません)。