~ubuntu-branches/ubuntu/wily/davix/wily

« back to all changes in this revision

Viewing changes to deps/boost_intern/src/thread/test/threads/thread/constr/FrvalueArgs_pass.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2015-07-31 13:17:55 UTC
  • mfrom: (5.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20150731131755-mizprbmn7ogv33te
Tags: 0.4.1-1
* Update to version 0.4.1
* Implement Multi-Arch support

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//===----------------------------------------------------------------------===//
2
 
//
3
 
//                     The LLVM Compiler Infrastructure
4
 
//
5
 
// This file is dual licensed under the MIT and the University of Illinois Open
6
 
// Source Licenses. See LICENSE.TXT for details.
7
 
//
8
 
//===----------------------------------------------------------------------===//
9
 
// Copyright (C) 2011 Vicente J. Botet Escriba
10
 
//
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)
13
 
 
14
 
// <boost/thread/thread.hpp>
15
 
 
16
 
// class thread
17
 
 
18
 
// template <class F, class ...Args> thread(F&& f, Args&&... args);
19
 
 
20
 
#define BOOST_THREAD_VERSION 4
21
 
 
22
 
#include <boost/thread/thread_only.hpp>
23
 
#include <new>
24
 
#include <cstdlib>
25
 
#include <cassert>
26
 
#include <boost/detail/lightweight_test.hpp>
27
 
 
28
 
class MoveOnly
29
 
{
30
 
public:
31
 
  BOOST_THREAD_MOVABLE_ONLY(MoveOnly)
32
 
  MoveOnly()
33
 
  {
34
 
  }
35
 
  MoveOnly(BOOST_THREAD_RV_REF(MoveOnly))
36
 
  {}
37
 
 
38
 
  void operator()(BOOST_THREAD_RV_REF(MoveOnly))
39
 
  {
40
 
  }
41
 
};
42
 
 
43
 
class M
44
 
{
45
 
 
46
 
public:
47
 
  long data_;
48
 
  static int n_moves;
49
 
 
50
 
  BOOST_THREAD_MOVABLE_ONLY(M)
51
 
  static void reset() {
52
 
    n_moves=0;
53
 
  }
54
 
  explicit M(long i) : data_(i)
55
 
  {
56
 
  }
57
 
  M(BOOST_THREAD_RV_REF(M) a) : data_(BOOST_THREAD_RV(a).data_)
58
 
  {
59
 
    BOOST_THREAD_RV(a).data_ = -1;
60
 
    ++n_moves;
61
 
  }
62
 
  M& operator=(BOOST_THREAD_RV_REF(M) a)
63
 
  {
64
 
    data_ = BOOST_THREAD_RV(a).data_;
65
 
    BOOST_THREAD_RV(a).data_ = -1;
66
 
    ++n_moves;
67
 
    return *this;
68
 
  }
69
 
  ~M()
70
 
  {
71
 
  }
72
 
 
73
 
  void operator()(int) const
74
 
  { }
75
 
  long operator()() const
76
 
  { return data_;}
77
 
  long operator()(long i, long j) const
78
 
  { return data_ + i + j;}
79
 
};
80
 
 
81
 
int M::n_moves = 0;
82
 
 
83
 
void fct(BOOST_THREAD_RV_REF(M) v)
84
 
{
85
 
  BOOST_TEST_EQ(v.data_, 1);
86
 
}
87
 
 
88
 
int main()
89
 
{
90
 
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
91
 
  {
92
 
    boost::thread t = boost::thread( MoveOnly(), MoveOnly() );
93
 
    t.join();
94
 
  }
95
 
  {
96
 
    M::reset();
97
 
    boost::thread t = boost::thread( fct, M(1) );
98
 
    t.join();
99
 
    BOOST_TEST_EQ(M::n_moves, 2);
100
 
  }
101
 
#endif
102
 
  return boost::report_errors();
103
 
}