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 8672033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:06:03+00:00 2026-06-12T19:06:03+00:00

I’m receiving a strange compilation error when trying to use construct<T>() method of a

  • 0

I’m receiving a strange compilation error when trying to use construct<T>() method of a boost::interprocess::managed_shared_memory class. I’m using the Boost library in 1.48 version and GCC in 4.6.3 version.

The problem is that when I’m creating a managed_shared_memory object (which is not a member of the struct) and then I’m trying to construct any object by using it’s construct<T>() method, the compilation succeeds:

#include <boost/interprocess/managed_shared_memory.hpp>
namespace proc = boost::interprocess;

template <typename _T>
void TFunc() {
    proc::managed_shared_memory mem;
    mem = proc::managed_shared_memory(proc::create_only, "mem1", 1024);
    int* ob1 = mem.construct<int>("i1") ();
}

Although, when the managed_shared_memory object is defined inside a struct and then created, the compilation of usage of construct<T>() method fails :

#include <boost/interprocess/managed_shared_memory.hpp>
namespace proc = boost::interprocess;

template <typename _T>
void TFunc() { 
    struct MemoryHandler {
        proc::managed_shared_memory mem;
    } handler;

    handler.mem = proc::managed_shared_memory(proc::create_only, "mem2", 1024);
    int* ob2 = handler.mem.construct<int>("i2") ();  // failure
}

with the following GCC error, pointing at the line with construct usage method:

error: expected primary-expression before 'int'
error: expected ',' or ';' before 'int'

Unfortunately I have not tested it against another versions of Boost and GCC, so I don’t know if it’s a bug of Boost/GCC or a feature.

Has anyone struggled with similar error or know what can be the cause?

  • 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-12T19:06:04+00:00Added an answer on June 12, 2026 at 7:06 pm

    You haven’t shown a complete example that demonstrates the error, so I can only guess, but I suspect the line that fails is inside a template and handler is a dependent type.

    To fix it you need to tell the compiler that construct is a function template:

    int* ob2 = handler.mem.template construct<int>("i2") ();
                           ^^^^^^^^
    

    See the C++ Templates FAQ for more information.

    And next time please post a complete example so others can reproduce the exact problem, instead of making people guess. For example, here is a minimal, complete example that shows the same error:

    #include <boost/interprocess/managed_shared_memory.hpp>
    
    namespace proc = boost::interprocess;
    
    struct MemoryHandler{
            proc::managed_shared_memory mem;
    } handler;
    
    template<typename T> void f(T handler)
    {
      handler.mem = proc::managed_shared_memory(proc::create_only, "mem2", 10);
      int* ob2 = handler.mem.construct<int>("i2") ();  // failure
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:

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.