varasm.c (output_constant): Add new parameter merge_strings.
[official-gcc.git] / libstdc++-v3 / testsuite / 20_util / forward / f_neg.cc
blob562adaea35d766fdb1ab071dbdaf798090935c44
1 // { dg-do compile { target c++11 } }
3 // Copyright (C) 2010-2018 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // { dg-error "static assertion failed" "" { target *-*-* } 87 }
22 #include <utility>
24 template <class T>
25 struct C
27 T t_;
29 C() {}
31 explicit C(const T& t) : t_(t) { }
33 template <class U,
34 class = typename std::enable_if
36 std::is_convertible<U, T>::value
37 >::type>
38 C(C<U>&& c) : t_(std::forward<T>(c.t_)) { }
41 class B;
43 class A
45 int data_;
47 friend class B;
48 public:
49 explicit
50 A(int data = 1)
51 : data_(data) { }
53 ~A() { data_ = -1; }
55 void test() const
57 __builtin_abort();
61 class B
63 int data_;
64 public:
65 explicit
66 B(int data = 1)
67 : data_(data) { }
69 B(const A& a) : data_(a.data_) { }
71 B(A&& a) : data_(a.data_) { a.data_ = 100; }
73 ~B() { data_ = -1; }
75 void test() const
77 __builtin_abort();
81 // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html
82 // Test F.
83 int main()
85 A a(3);
86 C<A> ca(a);
87 C<const B&> cb(std::move(ca));
88 cb.t_.test();