From 40bf17c1ea000bf230ae28cd8af9f4c11e458595 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Thu, 15 Feb 2018 15:41:49 +0000 Subject: [PATCH] [clangd] Fixed compilation with MVSC. llvm-svn: 325254 --- clang-tools-extra/unittests/clangd/SyncAPI.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/clang-tools-extra/unittests/clangd/SyncAPI.cpp b/clang-tools-extra/unittests/clangd/SyncAPI.cpp index 837a8bd..9e6ab28 100644 --- a/clang-tools-extra/unittests/clangd/SyncAPI.cpp +++ b/clang-tools-extra/unittests/clangd/SyncAPI.cpp @@ -32,9 +32,11 @@ template struct CaptureProxy { operator UniqueFunction() && { assert(!Future.valid() && "conversion to callback called multiple times"); Future = Promise.get_future(); - return BindWithForward([](std::promise Promise, - T Value) { Promise.set_value(std::move(Value)); }, - std::move(Promise)); + return BindWithForward( + [](std::promise> Promise, T Value) { + Promise.set_value(std::make_shared(std::move(Value))); + }, + std::move(Promise)); } ~CaptureProxy() { @@ -42,13 +44,16 @@ template struct CaptureProxy { return; assert(Future.valid() && "conversion to callback was not called"); assert(!Target->hasValue()); - Target->emplace(Future.get()); + Target->emplace(std::move(*Future.get())); } private: llvm::Optional *Target; - std::promise Promise; - std::future Future; + // Using shared_ptr to workaround compilation errors with MSVC. + // MSVC only allows default-construcitble and copyable objects as future<> + // arguments. + std::promise> Promise; + std::future> Future; }; template CaptureProxy capture(llvm::Optional &Target) { -- 2.7.4