when I try to compile this code:
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
using namespace std;
int main()
{
boost::filesystem3::path file_path("C:\\Users\\Art\\Desktop\\ASO.sln");
boost::filesystem3::path new_path(file_path.begin(),file_path.end() - 1);
return 0;
}
I’m getting an error:
C:\Users\Me\boost_path\..\..\..\boost_148\include\boost-1_48\boost\filesystem\v3\path.hpp:163: error: no matching function for call to 'convert(const boost::filesystem3::path*, const boost::filesystem3::path*, boost::filesystem3::path::string_type&, const codecvt_type&)'
Why? I assume there is a bug in boost::filesystem.
The
begin()andend()iterators ofboost::filesystem::pathare not character iterators. They are directory iterators; they iterate over the directories in a path. Thevalue_typeof these iterators arepaths themselves, which contain the directory.So you can’t construct a
pathfrom anotherpath‘s iterators like that.