1
//===----------------------------------------------------------------------===//
3
// The LLVM Compiler Infrastructure
5
// This file is dual licensed under the MIT and the University of Illinois Open
6
// Source Licenses. See LICENSE.TXT for details.
8
//===----------------------------------------------------------------------===//
9
// Copyright (C) 2011 Vicente J. Botet Escriba
11
// Distributed under the Boost Software License, Version 1.0. (See accompanying
12
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
14
// <boost/thread/thread.hpp>
18
// template <class F, class ...Args> thread(F&& f, Args&&... args);
20
#define BOOST_THREAD_VERSION 4
22
#include <boost/thread/thread_only.hpp>
26
#include <boost/detail/lightweight_test.hpp>
31
BOOST_THREAD_MOVABLE_ONLY(MoveOnly)
35
MoveOnly(BOOST_THREAD_RV_REF(MoveOnly))
38
void operator()(BOOST_THREAD_RV_REF(MoveOnly))
50
BOOST_THREAD_MOVABLE_ONLY(M)
54
explicit M(long i) : data_(i)
57
M(BOOST_THREAD_RV_REF(M) a) : data_(BOOST_THREAD_RV(a).data_)
59
BOOST_THREAD_RV(a).data_ = -1;
62
M& operator=(BOOST_THREAD_RV_REF(M) a)
64
data_ = BOOST_THREAD_RV(a).data_;
65
BOOST_THREAD_RV(a).data_ = -1;
73
void operator()(int) const
75
long operator()() const
77
long operator()(long i, long j) const
78
{ return data_ + i + j;}
83
void fct(BOOST_THREAD_RV_REF(M) v)
85
BOOST_TEST_EQ(v.data_, 1);
90
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
92
boost::thread t = boost::thread( MoveOnly(), MoveOnly() );
97
boost::thread t = boost::thread( fct, M(1) );
99
BOOST_TEST_EQ(M::n_moves, 2);
102
return boost::report_errors();