Fix for unique_future in c++03 having private ctor

This commit is contained in:
Strahinja Val Markovic 2012-08-13 10:13:51 -07:00
parent d099492a0f
commit 0903d5151b
2 changed files with 10 additions and 7 deletions

View File

@ -243,7 +243,8 @@ ClangCompleter::CandidatesForQueryAndLocationInFileAsync(
// the sorting task needs to be set before the clang task (if any) just in
// case the clang task finishes (and therefore notifies a sorting thread to
// consume a sorting task) before the sorting task is set
unique_future< AsyncCompletions > future = CreateSortingTask( query );
unique_future< AsyncCompletions > future;
CreateSortingTask( query, future );
if ( skip_clang_result_cache )
{
@ -270,8 +271,11 @@ bool ClangCompleter::ShouldSkipClangResultCache( const std::string &query,
}
unique_future< AsyncCompletions > ClangCompleter::CreateSortingTask(
const std::string &query )
// Copy-ctor for unique_future is private in C++03 mode so we need to take it as
// an out param
void ClangCompleter::CreateSortingTask(
const std::string &query,
unique_future< AsyncCompletions > &future )
{
// Careful! The code in this function may burn your eyes.
@ -292,9 +296,8 @@ unique_future< AsyncCompletions > ClangCompleter::CreateSortingTask(
bind( ReturnValueAsShared< std::vector< CompletionData > >,
boost::move( operate_on_completion_data_functor ) ) );
unique_future< AsyncCompletions > future = task->get_future();
future = task->get_future();
sorting_task_.Set( task );
return future;
}

View File

@ -115,8 +115,8 @@ private:
int line,
int column );
boost::unique_future< AsyncCompletions > CreateSortingTask(
const std::string &query );
void CreateSortingTask( const std::string &query,
boost::unique_future< AsyncCompletions > &future );
// NOTE: params are taken by value on purpose! With a C++11 compiler we can
// avoid internal copies if params are taken by value (move ctors FTW)