smallB
smallB

Reputation: 17148

Cannot create a path using boost::filesystem

I'm trying to create a one path from another:

path;//this is somewhere else correctly created path from a string

but when I try this:

boost::filesystem3::path project_path(path.begin(),path.end());  

I'm getting an error:

error: no matching function for call to 'convert(const   
boost::filesystem3::path*, const boost::filesystem3::path*,   
boost::filesystem3::path::string_type&, const codecvt_type&)'  

Anyone knows what's going on?

EDIT

auto beg_ = path.begin();
        auto end_ = path.end() - 1;//this line causes no advance defined error.  
//    If I try to do:  
    boost::filesystem3::path some_path(path.begin(),path.end() - 1); I'm getting the before mentioned (original error). 

I have nowhere defined any macro on my own.

Upvotes: 1

Views: 1964

Answers (1)

hatboyzero
hatboyzero

Reputation: 1937

It sounds like path is of the type boost::filesystem3::path and not a std::string. The constructor in Boost getting called is likely

template <class InputIterator>
path(InputIterator begin, InputIterator end)
{ 
  if (begin != end)
  {
    std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
      s(begin, end);
    path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, codecvt());
  }
}

If I'm not mistaken, InputIterator is being interpreted as boost::filesystem3::path*. If that's the case, then yes, the call to path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, codecvt()) will likely not match any existing method signatures for path_traits::convert()

See if using a std::string for the path variable works instead -- like so

std::string somePath = "/some/path";

boost::filesystem3::path project_path(somePath.begin(), somePath.end());

Although if you're going to do that, it'd be easier to just do

boost::filesystem3::path(somePath);

Upvotes: 2

Related Questions