Modify

Ticket #6222 (closed Bugs: fixed)

Opened 2 years ago

Last modified 2 years ago

Compile error with SunStudio: unique_future move

Reported by: anonymous Owned by: viboes
Milestone: Boost 1.50.0 Component: thread
Version: Boost 1.48.0 Severity: Problem
Keywords: move Cc: viboes

Description

// B.cpp
#include <boost/thread.hpp>

static int function() {
  return 42;
}

int main(int argc, const char *argv[]) {
  boost::packaged_task<int> pt(function);
  boost::unique_future<int> future = pt.get_future();
  return 0;
}

When trying to compile this I get this error:

"B.cpp", line 10: Error: boost::unique_future<int>::unique_future(boost::unique_future<int>&) is not accessible from main(int, const char). 1 Error(s) detected.

Attachments

Change History

comment:1 Changed 2 years ago by anonymous

Version of compiler: CC: Sun C++ 5.10 SunOS_sparc 2009/06/03

comment:2 Changed 2 years ago by anonymous

  • Owner set to anthonyw
  • Component changed from None to thread

comment:3 Changed 2 years ago by viboes

  • Summary changed from Compile error with SunStudio to Compile error with SunStudio: unique_future move

comment:4 Changed 2 years ago by viboes

  • Cc viboes added
  • Keywords move added

There is an action point to use Boost.Move. Could we consider this as a duplicate of #6194 Adapt to Boost.Move.

comment:5 Changed 2 years ago by viboes

  • Owner changed from anthonyw to viboes
  • Status changed from new to assigned

comment:6 Changed 2 years ago by viboes

The current implementation doesn't works on SunStudio? as it is preferring the overload to the private constructor instead of the conversion.

I have added a move() member function that should help to force the conversion in trunk. You can add the following

        boost::detail::thread_move_t<unique_future> move()
        {
            return boost::detail::thread_move_t<unique_future>(*this);
        }

Could you try this

  boost::unique_future<int> future = pt.get_future().move();

Let me now if this work for you. I will add some documentation explaining the limitation on SunStudio?.

comment:7 Changed 2 years ago by viboes

  • Severity changed from Showstopper to Problem
  • Milestone changed from To Be Determined to Boost 1.50.0

comment:8 Changed 2 years ago by viboes

  • Status changed from assigned to closed
  • Resolution set to fixed

Committed in release branch at [78543]

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.