Boost filesystem path append for char array

点点圈 提交于 2020-01-21 12:42:55

问题


The snippet of the code is:

boost::filesystem::path petscConfigurationPath;
petscConfigurationPath.append("FluidPetsc/Basic.conf");

It results in the following errors with boost 1.54:

error: no matching function for call to ‘boost::filesystem::path::append(const char [22])’
     petscConfigurationPath.append("FluidPetsc/Basic.conf");
                                                          ^
note: candidates are:
In file included from /usr/include/boost/filesystem.hpp:16:0,
/usr/include/boost/filesystem/path.hpp:305:11: note: boost::filesystem::path& boost::filesystem::path::append(const value_type*, const codecvt_type&)
     path& append(const value_type* ptr, const codecvt_type&)  // required in case ptr overlaps *this
           ^
/usr/include/boost/filesystem/path.hpp:305:11: note:   candidate expects 2 arguments, 1 provided
/usr/include/boost/filesystem/path.hpp:312:11: note: template<class Source> boost::filesystem::path& boost::filesystem::path::append(const Source&, const codecvt_type&)
     path& append(Source const& source, const codecvt_type& cvt);
           ^
/usr/include/boost/filesystem/path.hpp:312:11: note:   template argument deduction/substitution failed:
100:58: note:   candidate expects 2 arguments, 1 provided
     petscConfigurationPath.append("FluidPetsc/Basic.conf");
                                                          ^
In file included from /usr/include/boost/filesystem.hpp:16:0,
/usr/include/boost/filesystem/path.hpp:315:11: note: template<class InputIterator> boost::filesystem::path& boost::filesystem::path::append(InputIterator, InputIterator)
     path& append(InputIterator begin, InputIterator end)
           ^
/usr/include/boost/filesystem/path.hpp:315:11: note:   template argument deduction/substitution failed:
100:58: note:   candidate expects 2 arguments, 1 provided
     petscConfigurationPath.append("FluidPetsc/Basic.conf");
                                                          ^
In file included from /usr/include/boost/filesystem.hpp:16:0,
/usr/include/boost/filesystem/path.hpp:321:11: note: template<class InputIterator> boost::filesystem::path& boost::filesystem::path::append(InputIterator, InputIterator, const codecvt_type&)
     path& append(InputIterator begin, InputIterator end, const codecvt_type& cvt);
           ^
/usr/include/boost/filesystem/path.hpp:321:11: note:   template argument deduction/substitution failed:
100:58: note:   candidate expects 3 arguments, 1 provided
     petscConfigurationPath.append("FluidPetsc/Basic.conf");
                                                          ^
102:78: error: no matching function for call to ‘boost::filesystem::path::append(const char [40])’
     preciceConfigurationPath.append("Precice/SketchOfGeometryModeInFluid.xml");
                                                                              ^
102:78: note: candidates are:
In file included from /usr/include/boost/filesystem.hpp:16:0,
/usr/include/boost/filesystem/path.hpp:305:11: note: boost::filesystem::path& boost::filesystem::path::append(const value_type*, const codecvt_type&)
     path& append(const value_type* ptr, const codecvt_type&)  // required in case ptr overlaps *this
           ^
/usr/include/boost/filesystem/path.hpp:305:11: note:   candidate expects 2 arguments, 1 provided
/usr/include/boost/filesystem/path.hpp:312:11: note: template<class Source> boost::filesystem::path& boost::filesystem::path::append(const Source&, const codecvt_type&)
     path& append(Source const& source, const codecvt_type& cvt);
           ^
/usr/include/boost/filesystem/path.hpp:312:11: note:   template argument deduction/substitution failed:
102:78: note:   candidate expects 2 arguments, 1 provided
     preciceConfigurationPath.append("Precice/SketchOfGeometryModeInFluid.xml");
                                                                              ^
In file included from /usr/include/boost/filesystem.hpp:16:0,
/usr/include/boost/filesystem/path.hpp:315:11: note: template<class InputIterator> boost::filesystem::path& boost::filesystem::path::append(InputIterator, InputIterator)
     path& append(InputIterator begin, InputIterator end)
           ^
/usr/include/boost/filesystem/path.hpp:315:11: note:   template argument deduction/substitution failed:
102:78: note:   candidate expects 2 arguments, 1 provided
     preciceConfigurationPath.append("Precice/SketchOfGeometryModeInFluid.xml");
                                                                              ^
In file included from /usr/include/boost/filesystem.hpp:16:0,
/usr/include/boost/filesystem/path.hpp:321:11: note: template<class InputIterator> boost::filesystem::path& boost::filesystem::path::append(InputIterator, InputIterator, const codecvt_type&)
     path& append(InputIterator begin, InputIterator end, const codecvt_type& cvt);
           ^
/usr/include/boost/filesystem/path.hpp:321:11: note:   template argument deduction/substitution failed:
102:78: note:   candidate expects 3 arguments, 1 provided
     preciceConfigurationPath.append("Precice/SketchOfGeometryModeInFluid.xml");
                                                                              ^
104:69: error: no matching function for call to ‘boost::filesystem::path::append(const char [28])’
     simulationConfigurationPath.append("FluidSimulation/Channel.xml");
                                                                     ^
104:69: note: candidates are:
In file included from /usr/include/boost/filesystem.hpp:16:0,
/usr/include/boost/filesystem/path.hpp:305:11: note: boost::filesystem::path& boost::filesystem::path::append(const value_type*, const codecvt_type&)
     path& append(const value_type* ptr, const codecvt_type&)  // required in case ptr overlaps *this
           ^
/usr/include/boost/filesystem/path.hpp:305:11: note:   candidate expects 2 arguments, 1 provided
/usr/include/boost/filesystem/path.hpp:312:11: note: template<class Source> boost::filesystem::path& boost::filesystem::path::append(const Source&, const codecvt_type&)
     path& append(Source const& source, const codecvt_type& cvt);
           ^
/usr/include/boost/filesystem/path.hpp:312:11: note:   template argument deduction/substitution failed:
104:69: note:   candidate expects 2 arguments, 1 provided
     simulationConfigurationPath.append("FluidSimulation/Channel.xml");
                                                                     ^
In file included from /usr/include/boost/filesystem.hpp:16:0,
/usr/include/boost/filesystem/path.hpp:315:11: note: template<class InputIterator> boost::filesystem::path& boost::filesystem::path::append(InputIterator, InputIterator)
     path& append(InputIterator begin, InputIterator end)
           ^
/usr/include/boost/filesystem/path.hpp:315:11: note:   template argument deduction/substitution failed:
104:69: note:   candidate expects 2 arguments, 1 provided
     simulationConfigurationPath.append("FluidSimulation/Channel.xml");
                                                                     ^
In file included from /usr/include/boost/filesystem.hpp:16:0,
/usr/include/boost/filesystem/path.hpp:321:11: note: template<class InputIterator> boost::filesystem::path& boost::filesystem::path::append(InputIterator, InputIterator, const codecvt_type&)
     path& append(InputIterator begin, InputIterator end, const codecvt_type& cvt);
           ^
/usr/include/boost/filesystem/path.hpp:321:11: note:   template argument deduction/substitution failed:
69: note:   candidate expects 3 arguments, 1 provided
     simulationConfigurationPath.append("FluidSimulation/Channel.xml");
                                                                 ^

When using boost 1.57 there are methods

path& append(const value_type* ptr);

template <class Source>
path& append(Source const& source);

Where does these methods exist in version 1.54?


回答1:


The headers (and the documentation) indicate that append required a codecvt parameter back then (to tell the append function how characterset conversions are to be done).

This works on 1.54:

#include <boost/filesystem.hpp>

int main() {
    boost::filesystem::path petscConfigurationPath;

    petscConfigurationPath.append("FluidPetsc/Basic.conf", boost::filesystem::path::codecvt());
}


来源:https://stackoverflow.com/questions/28115757/boost-filesystem-path-append-for-char-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!