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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:17:00+00:00 2026-06-04T06:17:00+00:00

I have a situation where some object has to be passed as an argument

  • 0

I have a situation where some object has to be passed as an argument of a thread callback function. Object is created dynamically and after it is passed to the thread, object is not needed/used in that context (in a method which starts a thread) any more. Thread function is now the only context which should own the object.

Assuming I want to use some Boost smart pointer (instead of passing to the thread a raw pointer), which one would be the most appropriate here? What is the best practice in this case?

What I actually need is std::auto_ptr with its move semantics through copy constructor. I believe that this smart pointer would perfectly fit here but it is deprecated for well-known reasons (and I cannot rely on tr1 and C++11 pointers; must (and want to) use Boost only as this code is shared between projects that must compile both in Visual Studio 2008 and 2010).

boost::shared_ptr is an option – I could pass it by value but think it would be overkilling. Is there any chance of emulating move semantics (in a safe way) with boost::scoped_ptr? I don’t need reference counting here as am not sharing object between two contexts, I just want to transfer the ownership over object from one context to another.

  • 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-04T06:17:02+00:00Added an answer on June 4, 2026 at 6:17 am

    You could use boost::interprocess::unique_ptr, or write your own unique_ptr using Boost.Move.

    boost::interprocess::unique_ptr uses Boost.Move in its implementation, and Boost.Move emulates C++11 move semantics C++03.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation like this: start(); <Some code> end(); I want start() function
I have a situation where I would like to dynamically create an object through
Situation: I have some persons with certain skills and they can/might belong to more
I have a situation where I need to notify some users when something in
I have a situation in which a managed DLL calls some unmanaged DLL. I
I have a situation where I want my program to read in some numbers
We have a situation where we want to use filter for URL's containing some
I have following Situation, Server A sends some data (HTML form) to server B,
Common situation: I have a client on my server who may update some of
I have the following situation: I have an application that collects some data from

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.