为char数组添加文件系统路径附加

时间:2015-01-23 17:49:34

标签: c++ boost boost-filesystem

代码的片段是:

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

使用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");
                                                                 ^

使用boost 1.57时有方法

path& append(const value_type* ptr);

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

版本1.54中存在这些方法的位置?

1 个答案:

答案 0 :(得分:3)

标题(和文档)表明append当时需要codecvt参数(告诉追加函数如何进行字符集转换)。

这适用于1.54:

#include <boost/filesystem.hpp>

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

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