From 1dbf7028fe5fcf462d1fbce0f739ebca4591f665 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Fri, 21 Feb 2014 10:52:18 +0100 Subject: [PATCH] Try to workaround some issues with MSVC lambdas. --- example/lambda_future.cpp | 2 +- example/with_lock_guard.cpp | 10 +++++----- include/boost/thread/with_lock_guard.hpp | 3 ++- .../with_lock_guard/with_lock_guard_lambda.cpp | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/example/lambda_future.cpp b/example/lambda_future.cpp index 3d8684d2..593fe6ca 100644 --- a/example/lambda_future.cpp +++ b/example/lambda_future.cpp @@ -22,7 +22,7 @@ #include #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION \ - && ! defined BOOST_NO_CXX11_LAMBDAS + && ! defined BOOST_NO_CXX11_LAMBDAS && ! (defined BOOST_MSVC && _MSC_VER < 1700) int main() diff --git a/example/with_lock_guard.cpp b/example/with_lock_guard.cpp index b53cbbf5..f3a4cd80 100644 --- a/example/with_lock_guard.cpp +++ b/example/with_lock_guard.cpp @@ -15,7 +15,7 @@ boost::mutex m; // protection for 'x' and 'std::cout' int x; -#if defined(BOOST_NO_CXX11_LAMBDAS) +#if defined(BOOST_NO_CXX11_LAMBDAS) || (defined BOOST_MSVC && _MSC_VER < 1700) void print_x() { ++x; std::cout << "x = " << x << std::endl; @@ -43,11 +43,11 @@ void job() { #endif int main() { -#if defined(BOOST_NO_CXX11_LAMBDAS) +#if defined(BOOST_NO_CXX11_LAMBDAS) || (defined BOOST_MSVC && _MSC_VER < 1700) std::cout << "(no lambdas)" << std::endl; #endif - boost::scoped_thread<> thread_1(job); - boost::scoped_thread<> thread_2(job); - boost::scoped_thread<> thread_3(job); + boost::scoped_thread<> thread_1((boost::thread(job))); + boost::scoped_thread<> thread_2((boost::thread(job))); + boost::scoped_thread<> thread_3((boost::thread(job))); return 0; } diff --git a/include/boost/thread/with_lock_guard.hpp b/include/boost/thread/with_lock_guard.hpp index cf3fdc24..63e7910e 100644 --- a/include/boost/thread/with_lock_guard.hpp +++ b/include/boost/thread/with_lock_guard.hpp @@ -16,7 +16,8 @@ namespace boost { #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \ - !defined(BOOST_NO_CXX11_DECLTYPE) + !defined(BOOST_NO_CXX11_DECLTYPE) && \ + !defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) /** * Utility to run functions in scope protected by mutex. diff --git a/test/sync/mutual_exclusion/with_lock_guard/with_lock_guard_lambda.cpp b/test/sync/mutual_exclusion/with_lock_guard/with_lock_guard_lambda.cpp index 2b04d71a..8eda53de 100644 --- a/test/sync/mutual_exclusion/with_lock_guard/with_lock_guard_lambda.cpp +++ b/test/sync/mutual_exclusion/with_lock_guard/with_lock_guard_lambda.cpp @@ -20,7 +20,7 @@ #include #include -#if defined(BOOST_NO_CXX11_LAMBDAS) +#if defined(BOOST_NO_CXX11_LAMBDAS) || (defined BOOST_MSVC && _MSC_VER < 1700) void test_lambda() { std::cout << "C++11 lambda disabled" << std::endl; }