Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing boost::iostreams::mapped_file_source with wide character strings
    primarykey
    data
    text
    <p>If I instantiate a mapped_file_source (boost 1.46.1 ) with a narrow character string as in the following I don't have a problem:</p> <pre><code>boost::iostreams::mapped_file_source m_file_( "testfile.txt" ); </code></pre> <p>However if I try to use a wide string:</p> <pre><code>boost::iostreams::mapped_file_source m_file_( L"testfile.txt" ); </code></pre> <p>I get the following compiler error in VC2010 SP1:</p> <pre><code>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'&gt; P:\libs\boost_1_46_1\boost/iostreams/detail/path.hpp(37) : see declaration of 'boost::iostreams::detail::path' </code></pre> <p>If I instead try to pass the constructor a boost::filesystem::path I get the following error:</p> <pre><code>P:\libs\boost_1_46_1\boost/iostreams/device/mapped_file.hpp(128): error C2664: 'boost::iostreams::detail::path::path(const std::string &amp;)' : cannot convert parameter 1 from 'const boost::filesystem3::path' to 'const std::string &amp;' Reason: cannot convert from 'const boost::filesystem3::path' to 'const std::string' </code></pre> <p>I feel like I'm missing something obvious, but I'm just running around in circles trying to figure out what the compiler is trying to tell me, but I'm just getting lost. That palm to forehead moment is just not happening.. What is it that I am doing incorrectly? </p> <p>The constructor defined in mapped_file.hpp looks like the following:</p> <pre><code>// Constructor taking a parameters object template&lt;typename Path&gt; explicit mapped_file_source(const basic_mapped_file_params&lt;Path&gt;&amp; p); </code></pre> <p>The basic_mapped_file_params class constructors look like this:</p> <pre><code>// Construction from a Path explicit basic_mapped_file_params(const Path&amp; p) : path(p) { } // Construction from a path of a different type template&lt;typename PathT&gt; explicit basic_mapped_file_params(const PathT&amp; p) : path(p) { } </code></pre> <p>Where the template class is defined as:</p> <pre><code>// 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&lt;typename Path&gt; struct basic_mapped_file_params : detail::mapped_file_params_base { </code></pre> <p>There is some additional help in the header that says:</p> <pre><code>// For wide paths, instantiate basic_mapped_file_params // with boost::filesystem::wpath </code></pre> <p>If I take this approach with:</p> <pre><code>boost::iostreams::basic_mapped_file_params&lt;boost::filesystem::wpath&gt; _tmp(L"test.txt"); boost::iostreams::mapped_file_source m_file_( _tmp ); </code></pre> <p>I get the same <strong>C2664</strong> error mentioned above..</p> <p>I know the compiler is telling me what the problem is, but looking at the header source and the comments leads me to believe that what I'm trying to accomplish is supported, it's just my approach that is incorrect. Am I misinterpreting what the header file is telling me? I know there is probably a good lesson about template instantiation and explicit/implicit conversion in here somewhere.</p> <p>Interestingly enough, upgrading my boost install to 1.47.0 seems to cleared up <strong>C2664</strong> error but I'm still getting the <strong>C2248</strong> error about access to the private member.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload