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

  • SEARCH
  • Home
  • 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 7921193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:29:41+00:00 2026-06-03T16:29:41+00:00

I plan to process large compressed files and I would like to memory map

  • 0

I plan to process large compressed files and I would like to memory map the files to speedup reading. I adopted the existing example with regular file input but cannot get it either compile nor work 🙂 I’m using C++ Boost 1.49

Any suggestion welcome!

#include<iostream>
#include<boost/iostreams/filtering_streambuf.hpp>
#include<boost/iostreams/copy.hpp>
#include<boost/iostreams/filter/zlib.hpp>
#include<boost/iostreams/device/file.hpp>
#include<boost/iostreams/device/mapped_file.hpp>

void test_decoder_mmf()
{
   using namespace std;
   using namespace boost::iostreams;
   //ifstream file("my_file.txt", ios_base::in | ios_base::binary);
   mapped_file_source file( "my_file.txt" );
   filtering_streambuf< input > in;
   in.push(zlib_decompressor());
   in.push(file);
   copy(in,cout);
}

int main()
{   
   test_decoder_mmf();
   return 0;
}

In file included from /usr/local/include/boost/iostreams/operations.hpp:20:0,
                 from /usr/local/include/boost/iostreams/detail/adapter/mode_adapter.hpp:24,
                 from /usr/local/include/boost/iostreams/detail/resolve.hpp:19,
                 from /usr/local/include/boost/iostreams/detail/push.hpp:24,
                 from /usr/local/include/boost/iostreams/chain.hpp:29,
                 from /usr/local/include/boost/iostreams/filtering_streambuf.hpp:17,
                 from test_boost_iostreams2.cc:2:
/usr/local/include/boost/iostreams/optimal_buffer_size.hpp: In function ‘std::streamsize boost::iostreams::optimal_buffer_size(const T&) [with T = boost::iostreams::mapped_file_source, std::streamsize = long int]’:
/usr/local/include/boost/iostreams/chain.hpp:248:9:   instantiated from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::mapped_file_source, Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >, Ch = char, Tr = std::char_traits<char>, Alloc = std::allocator<char>, Mode = boost::iostreams::input, std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:216:1:   instantiated from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::mapped_file_source, Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >, Ch = char, Tr = std::char_traits<char>, Alloc = std::allocator<char>, Mode = boost::iostreams::input, std::streamsize = long int, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
/usr/local/include/boost/iostreams/chain.hpp:500:7:   instantiated from ‘void boost::iostreams::detail::chain_client<Chain>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::mapped_file_source, Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >, std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:488:1:   instantiated from ‘void boost::iostreams::detail::chain_client<Chain>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::mapped_file_source, Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >, std::streamsize = long int, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
test_boost_iostreams2.cc:17:17:   instantiated from here
/usr/local/include/boost/iostreams/optimal_buffer_size.hpp:39:55: error: ‘optimal_buffer_size’ is not a member of ‘impl {aka boost::iostreams::detail::optimal_buffer_size_impl<boost::iostreams::mapped_file_source>}’
  • 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-06-03T16:29:43+00:00Added an answer on June 3, 2026 at 4:29 pm

    For those who might be interested here is the working code:

    #include<iostream>
    #include<boost/iostreams/copy.hpp>
    #include<boost/iostreams/device/mapped_file.hpp>
    #include<boost/iostreams/filter/zlib.hpp>
    #include<boost/iostreams/filtering_streambuf.hpp>
    #include<boost/iostreams/filtering_stream.hpp>
    #include<boost/iostreams/stream.hpp>
    
    using namespace std;
    using namespace boost::iostreams;
    
    void test_decoder_mmf(const std::string&filename)
    {
        stream<mapped_file_source> file;
        filtering_streambuf< input > in;
        file.open(mapped_file_source(filename));
        in.push(zlib_decompressor());
        in.push(file);
        copy(in,cout);
    }
    
    int main()
    {
       test_decoder_mmf("zlib-compressed-file");
       return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to write a Node.js UDP server on Heroku and plan to
I'm in the process of starting up a web site project. My plan is
I plan to make an pretty big application on Facebook. Would it be a
I have an Xcode project with a large number of targets where I would
I am in the process of migrating a large scale web service to be
I don't plan to write applications without IB, I'm just in the process of
I am currently in the process of rewriting an application whereby teachers can plan
I need to automate the process of upgrading the existing deployments of an application
I plan to use Unix named pipes (mkfifo) for simple multi-process messaging. A message
I have a maintenance plan that looks like this... Client 1 Import Data (Success)

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.