From 0903d5151b3a9c741ec6307f8ae019b8a91bc0c6 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Mon, 13 Aug 2012 10:13:51 -0700 Subject: [PATCH] Fix for unique_future in c++03 having private ctor --- cpp/ycm/ClangCompleter.cpp | 13 ++++++++----- cpp/ycm/ClangCompleter.h | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cpp/ycm/ClangCompleter.cpp b/cpp/ycm/ClangCompleter.cpp index b345306e..e3777de8 100644 --- a/cpp/ycm/ClangCompleter.cpp +++ b/cpp/ycm/ClangCompleter.cpp @@ -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; } diff --git a/cpp/ycm/ClangCompleter.h b/cpp/ycm/ClangCompleter.h index 5979f747..cd876e02 100644 --- a/cpp/ycm/ClangCompleter.h +++ b/cpp/ycm/ClangCompleter.h @@ -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)