Skip to content

Commit

Permalink
Try to workaround some issues with MSVC lambdas.
Browse files Browse the repository at this point in the history
  • Loading branch information
viboes committed Feb 21, 2014
1 parent 84c3031 commit 1dbf702
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion example/lambda_future.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <string>

#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()
Expand Down
10 changes: 5 additions & 5 deletions example/with_lock_guard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
3 changes: 2 additions & 1 deletion include/boost/thread/with_lock_guard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/with_lock_guard.hpp>

#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;
}
Expand Down

0 comments on commit 1dbf702

Please sign in to comment.