]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/experimental/memory/observer_ptr/relops/relops.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / experimental / memory / observer_ptr / relops / relops.cc
CommitLineData
0402a64a 1// { dg-options "-std=gnu++14" }
2// { dg-do run }
3
f1717362 4// Copyright (C) 2015-2016 Free Software Foundation, Inc.
0402a64a 5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 3, or (at your option)
10// any later version.
11
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16
17// You should have received a moved_to of the GNU General Public License along
18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
20
21#include <experimental/memory>
22#include <testsuite_hooks.h>
23
24using std::experimental::observer_ptr;
25
26void test01()
27{
28 observer_ptr<int> a, b;
29 VERIFY(a == b);
30}
31
32void test02()
33{
34 int x[2]{};
35 observer_ptr<int> a{&x[0]};
36 observer_ptr<int> b{&x[1]};
37 VERIFY(a != b);
38 VERIFY(a < b);
39 VERIFY(a <= b);
40 VERIFY(b >= a);
41 VERIFY(b > a);
42}
43
44void test03()
45{
46 int x{};
47 observer_ptr<int> a{&x};
48 observer_ptr<int> b{&x};
49 VERIFY(a == b);
50}
51
52void test04()
53{
54 static constexpr int x[2]{};
55 constexpr observer_ptr<const int> a{&x[0]};
56 constexpr observer_ptr<const int> b{&x[1]};
57 VERIFY(a != b);
58 VERIFY(a < b);
59 VERIFY(a <= b);
60 VERIFY(b >= a);
61 VERIFY(b > a);
62}
63
64void test05()
65{
66 static constexpr int x{};
67 constexpr observer_ptr<const int> a{&x};
68 constexpr observer_ptr<const int> b{&x};
69 VERIFY(a == b);
70}
71
72
73int main()
74{
75 test01();
76 test02();
77 test03();
78 test04();
79 test05();
80}