如果我实例化一个mapped_file_source(升压1.46.1)用窄字符串如下面的我没有一个问题:使用boost ::输入输出流:: mapped_file_source宽字符串
boost::iostreams::mapped_file_source m_file_("testfile.txt");
但是,如果我尝试使用宽字符串:
boost::iostreams::mapped_file_source m_file_(L"testfile.txt");
我得到VC2010 SP1以下编译器错误:
P:\libs\boost_1_46_1\boost/iostreams/device/mapped_file.hpp(128): error C2248: 'boost::iostreams::detail::path::path' : cannot access private member declared in class 'boost::iostreams::detail::path'
P:\libs\boost_1_46_1\boost/iostreams/detail/path.hpp(111) : see declaration of 'boost::iostreams::detail::path::path'>
P:\libs\boost_1_46_1\boost/iostreams/detail/path.hpp(37) : see declaration of 'boost::iostreams::detail::path'
如果我不是试图通过构造一个boost ::文件系统::路径我得到以下错误:
P:\libs\boost_1_46_1\boost/iostreams/device/mapped_file.hpp(128): error C2664: 'boost::iostreams::detail::path::path(const std::string &)' : cannot convert parameter 1 from 'const boost::filesystem3::path' to 'const std::string &'
Reason: cannot convert from 'const boost::filesystem3::path' to 'const std::string'
我觉得我失去了一些东西很明显,但我只是手忙脚乱试图弄清楚编译器试图告诉我什么,但我只是迷了路。那掌心到额头时刻就是没有发生..我做错了什么?
在mapped_file.hpp定义的构造函数如下所示:
// Constructor taking a parameters object
template<typename Path>
explicit mapped_file_source(const basic_mapped_file_params<Path>& p);
的basic_mapped_file_params类的构造是这样的:
// Construction from a Path
explicit basic_mapped_file_params(const Path& p) : path(p) { }
// Construction from a path of a different type
template<typename PathT>
explicit basic_mapped_file_params(const PathT& p) : path(p) { }
当模板类的定义为:
// This template allows Boost.Filesystem paths to be specified when creating or
// reopening a memory mapped file, without creating a dependence on
// Boost.Filesystem. Possible values of Path include std::string,
// boost::filesystem::path, boost::filesystem::wpath,
// and boost::iostreams::detail::path (used to store either a std::string or a
// std::wstring).
template<typename Path>
struct basic_mapped_file_params
: detail::mapped_file_params_base
{
标题中有一些额外的帮助:
// For wide paths, instantiate basic_mapped_file_params
// with boost::filesystem::wpath
如果我采取这种做法:
boost::iostreams::basic_mapped_file_params<boost::filesystem::wpath> _tmp(L"test.txt");
boost::iostreams::mapped_file_source m_file_(_tmp);
我得到上述同样的C2664错误..
我知道的编译器告诉我是什么问题,但看着头源和评论导致我相信,我试图完成的是支持的,这只是我的方法是不正确的。我误解了头文件告诉我什么?我知道在这里某处可能有关于模板实例化和显式/隐式转换的很好的教训。
有趣的是,升级我的提振安装到1.47.0似乎清理C2664错误,但我仍然获取有关访问私有成员C2248错误。
我加入的问题一些额外的信息。我理解编译器告诉我什么,我只是不明白为什么,从mapped_file.hpp头文件的源头 –
@ C.Trauma:如果这是头文件的样子,那么文档就过时了。我发现的文档页是从1.47.0。 –
滚动到文档页面底部显示“2008年2月2日修订”,因此很可能它们已过期。 –