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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:26:00+00:00 2026-06-06T20:26:00+00:00

I am looking for a way to pass an object ( vector<long> in my

  • 0

I am looking for a way to pass an object (vector<long> in my case) as a WPARAM in C++11 style.

The tutorials I found used a C-style cast or a reinterpret_cast to pass a pointer to the object. This requires that the recipient of the message properly disposes the object after receiving it.

Is there a way to pass the object using a unique_ptr? The recipient can take full ownership of the object.

  • 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-06T20:26:02+00:00Added an answer on June 6, 2026 at 8:26 pm

    If you pass a pointer to an object with a windows message then you need to ensure 2 things:

    1. The source doesn’t destroy the object before the message has been handled
    2. The destination correctly destroys the object if necessary

    If you know that the message will definitely be handled then you can call .release() on the source unique_ptr when sending the message, and then take ownership in the handler with another unique_ptr.

    The problem comes with ensuring it is cleaned up if the message is NOT handled. This is tricky, as there isn’t usually a clean way to check unless you use SendMessage (not PostMessage) and use the return value to communicate that the parameter has been claimed.

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

Sidebar

Related Questions

I am looking for a way to pass NumPy arrays to Matlab. I've managed
I'm looking for a way to pass different options as a parameter to a
I am looking for a way to pass a string containg the * character
I'm looking for a way to pass a variable or string or anything into
im looking for a way to print the array as is after each pass.
I'm looking a way to enable IP logging with log4net in ASP.NET. I found
I am looking for a way to pass values to a couple of elements,
I'm looking for a way to pass in a FILE * to some function
I am looking for a way to obfuscate (in the object code) a test
I am looking for a way to create a basic python object which I

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.