English 中文(简体)
强化:档案系统: (通过编辑)造成编辑错误
原标题:boost::filesystem::path::append (via iterators) causes compiler error

I m 试图利用boost:filesystem形成如下的新途径:

#include <iostream>
#include <string>
#include <boostfilesystem.hpp>

namespace bf = boost::filesystem;

bf::path o("C:\mir");
bf::path p("C:\mir\dir\beer.txt");
bf::path r("C:\test");

auto pp = std::mismatch(o.begin(), o.end(), p.begin());
r.append(pp.second, p.end()); // this line causes compiler error

我的汇编错误如下:

c:program files (x86)microsoft visual studio 10.0vcincludexutility(2885): warning C4996:  std::_Mismatch1 : Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++  Checked Iterators 
      c:vcincludexutility(2868) : see declaration of  std::_Mismatch1 
      g:copywithpathcopywithpath.cpp(40) : see reference to function template instantiation  std::pair<_Ty1,_Ty2> std::mismatch<boost::filesystem3::path::iterator,boost::filesystem3::path::iterator>(_InIt1,_InIt1,_InIt2)  being compiled
      with
      [
          _Ty1=boost::filesystem3::path::iterator,
          _Ty2=boost::filesystem3::path::iterator,
          _InIt1=boost::filesystem3::path::iterator,
          _InIt2=boost::filesystem3::path::iterator
      ]
c:vcincludexstring(506): error C2621: member  std::_String_val<_Elem,_Alloc>::_Bxty::_Buf  of union  std::_String_val<_Elem,_Alloc>::_Bxty  has copy constructor
      with
      [
          _Elem=boost::filesystem3::path,
          _Alloc=std::allocator<boost::filesystem3::path>
      ]
      c:vcincludexstring(509) : see reference to class template instantiation  std::_String_val<_Elem,_Alloc>::_Bxty  being compiled
      with
      [
          _Elem=boost::filesystem3::path,
          _Alloc=std::allocator<boost::filesystem3::path>
      ]
      c:vcincludexstring(522) : see reference to class template instantiation  std::_String_val<_Elem,_Alloc>  being compiled
      with
      [
          _Elem=boost::filesystem3::path,
          _Alloc=std::allocator<boost::filesystem3::path>
      ]
      f:oostfilesystemv3path.hpp(621) : see reference to class template instantiation  std::basic_string<_Elem>  being compiled
      with
      [
          _Elem=boost::filesystem3::path
      ]
      f:oostfilesystemv3path.hpp(232) : see reference to function template instantiation  boost::filesystem3::path &boost::filesystem3::path::append<InputIterator>(InputIterator,InputIterator,const boost::filesystem3::path::codecvt_type &)  being compiled
      with
      [
          InputIterator=boost::filesystem3::path::iterator
      ]
      g:copywithpathcopywithpath.cpp(42) : see reference to function template instantiation  boost::filesystem3::path &boost::filesystem3::path::append<_Ty2>(InputIterator,InputIterator)  being compiled
      with
      [
          _Ty2=boost::filesystem3::path::iterator,
          InputIterator=boost::filesystem3::path::iterator
      ]
f:oostfilesystemv3path.hpp(622): error C2665:  boost::filesystem3::path_traits::convert  : none of the 8 overloads could convert all the argument types
     f:oostfilesystemv3path_traits.hpp(96): could be  void boost::filesystem3::path_traits::convert(const char *,const char *,std::wstring &,const boost::filesystem3::path_traits::codecvt_type &) 
     f:oostfilesystemv3path_traits.hpp(102): or        void boost::filesystem3::path_traits::convert(const wchar_t *,const wchar_t *,std::string &,const boost::filesystem3::path_traits::codecvt_type &) 
     f:oostfilesystemv3path_traits.hpp(130): or        void boost::filesystem3::path_traits::convert(const char *,const char *,std::string &,const boost::filesystem3::path_traits::codecvt_type &) 
     f:oostfilesystemv3path_traits.hpp(150): or        void boost::filesystem3::path_traits::convert(const wchar_t *,const wchar_t *,std::wstring &,const boost::filesystem3::path_traits::codecvt_type &) 
     while trying to match the argument list  (const boost::filesystem3::path *, const boost::filesystem3::path *, boost::filesystem3::path::string_type, const boost::filesystem3::path::codecvt_type) 

What s wrong with my code and how I can fix it. Thanks in advance.

最佳回答

途径:申请希望具有一系列特点,你提供了各种途径。 你们应该自己对每个要素做出回应:

auto pp = std::mismatch(o.begin(), o.end(), p.begin());
for(auto iter = pp.second; iter != p.end(); ++iter)
    r /= *iter;

Unfortunately boost::filesystem paths don t provide an interface for path arithmetics.

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签