【问题标题】:Boost filesystem path append for char array提升字符数组的文件系统路径附加
【发布时间】:2015-01-23 17:49:33
【问题描述】:

代码的sn-p为:

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 版本中的哪些地方存在?

【问题讨论】:

    标签: c++ boost boost-filesystem


    【解决方案1】:

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

    这适用于 1.54:

    #include <boost/filesystem.hpp>
    
    int main() {
        boost::filesystem::path petscConfigurationPath;
    
        petscConfigurationPath.append("FluidPetsc/Basic.conf", boost::filesystem::path::codecvt());
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-27
      • 2014-02-03
      • 2010-11-08
      • 2013-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多