* decl.c (make_typename_type): s/parameters/arguments/.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-tuple.C
blobf59cd845304278c5f9c76a699e487acd6f893bf7
1 // PR c++/53202
2 // { dg-do run { target c++11 } }
4 #include <tuple>
6 template<typename Callable>
7   struct Bind_simple
8   {
9     explicit
10     Bind_simple(const Callable& callable)
11     : _M_bound(callable)
12     { }
14     Bind_simple(const Bind_simple&) = default;
15     Bind_simple(Bind_simple&&) = default;
17     auto operator()() -> decltype((*(Callable*)0)())
18     {
19       return std::get<0>(_M_bound)();
20     }
22   private:
24     std::tuple<Callable> _M_bound;
25   };
27 template<typename Callable>
28   Bind_simple<Callable>
29   bind_simple(Callable& callable)
30   {
31     return Bind_simple<Callable>(callable);
32   }
34 struct thread
36   struct ImplBase { };
38   template<typename T>
39     struct Impl : ImplBase {
40       T t;
41       Impl(T&& t) : t(std::move(t)) { }
42     };
44   template<typename T>
45     thread(T& t)
46     {
47       auto p = make_routine(bind_simple(t));
49       p->t();
51       delete p;
52     }
54   template<typename Callable>
55     Impl<Callable>*
56     make_routine(Callable&& f)
57     {
58       return new Impl<Callable>(std::forward<Callable>(f));
59     }
63 int c;
64 class background_hello
66 public:
67     background_hello()
68     {
69       __builtin_printf("default ctor called, this=%p\n", this);
70       ++c;
71     }
73     background_hello(const background_hello &)
74     {
75       __builtin_printf("copy ctor called\n");
76       ++c;
77     }
79     background_hello(background_hello &&)
80     {
81       __builtin_printf("move ctor called\n");
82       ++c;
83     }
85     void operator ()() const
86     {
87       __builtin_printf("void background_hello::operator()() called, this=%p\n", this);
88     }
90     ~background_hello()
91     {
92       __builtin_printf("destructor called, this=%p\n", this);
93       --c;
94     }
98 int main()
100   {
101     background_hello bh;
102     thread t(bh);
103   }
104   if (c != 0)
105     __builtin_abort ();