Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7550409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:12:20+00:00 2026-05-30T10:12:20+00:00

If I instantiate a mapped_file_source (boost 1.46.1 ) with a narrow character string as

  • 0

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:

boost::iostreams::mapped_file_source m_file_( "testfile.txt" );

However if I try to use a wide string:

boost::iostreams::mapped_file_source m_file_( L"testfile.txt" );

I get the following compiler error in 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'

If I instead try to pass the constructor a boost::filesystem::path I get the following error:

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'

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?

The constructor defined in mapped_file.hpp looks like the following:

// Constructor taking a parameters object
template<typename Path>
explicit mapped_file_source(const basic_mapped_file_params<Path>& p);

The basic_mapped_file_params class constructors look like this:

// 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) { }

Where the template class is defined as:

// 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 
{

There is some additional help in the header that says:

// For wide paths, instantiate basic_mapped_file_params 
// with boost::filesystem::wpath

If I take this approach with:

boost::iostreams::basic_mapped_file_params<boost::filesystem::wpath> _tmp(L"test.txt");
boost::iostreams::mapped_file_source m_file_( _tmp );

I get the same C2664 error mentioned above..

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.

Interestingly enough, upgrading my boost install to 1.47.0 seems to cleared up C2664 error but I’m still getting the C2248 error about access to the private member.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:12:22+00:00Added an answer on May 30, 2026 at 10:12 am

    With boost 1.48 I can do something like this.

    #include <boost/filesystem.hpp>
    #include <boost/iostreams/device/mapped_file.hpp>
    #include <iostream>
    
    int main()
    { 
      boost::filesystem::path p(L"b.cpp");
      boost::iostreams::mapped_file file(p); // or mapped_file_source
      std::cout << file.data() << std::endl;
    }
    

    or you can do this with mapped_file_params(used create new file)

    boost::filesystem::path p(L"aa");
    basic_mapped_file_params<boost::filesystem::path> param; // template param
    param.path = p;
    param.new_file_size = 1024;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem deserializing a JSON string using Jackson (but I have no
How do I instantiate a class in CoffeeScript when I only have the name
I need to instantiate a new view on a command Imagine I have a
I have big problem with basic of the Hibernate in all my projects. I
I'd like to instantiate a class but I only have its name in a
I have ubuntu 10.04 and want to install the latest boost library 1.44_0 I
I instantiate the HttpWebRequest object: HttpWebRequest httpWebRequest = WebRequest.Create(http://game.stop.com/webservice/services/gameup) as HttpWebRequest; When I post
How can I instantiate a JMS queue listener in java (JRE /JDK / J2EE
Can VBA code instantiate and use .NET objects? The specific class I'm interested in
I try to instantiate an instance of SPSite on the farm server in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.