1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // UNSUPPORTED: c++03, c++11 |
10 | |
11 | // <propagate_const> |
12 | |
13 | // template <class T> constexpr bool operator!=(const propagate_const<T>& x, const propagate_const<T>& y); |
14 | // template <class T> constexpr bool operator!=(const T& x, const propagate_const<T>& y); |
15 | // template <class T> constexpr bool operator!=(const propagate_const<T>& x, const T& y); |
16 | |
17 | #include <experimental/propagate_const> |
18 | #include "test_macros.h" |
19 | #include "propagate_const_helpers.h" |
20 | #include <cassert> |
21 | |
22 | using std::experimental::propagate_const; |
23 | using std::nullptr_t; |
24 | |
25 | constexpr bool operator!=(const X &lhs, const X &rhs) { |
26 | return lhs.i_ != rhs.i_; |
27 | } |
28 | |
29 | constexpr bool operator!=(const X &, const nullptr_t &) { |
30 | return true; |
31 | } |
32 | |
33 | constexpr bool operator!=(const nullptr_t &, const X &) { |
34 | return true; |
35 | } |
36 | |
37 | int main(int, char**) { |
38 | constexpr X x1_1(1); |
39 | constexpr X x2_1(1); |
40 | constexpr X x3_2(2); |
41 | |
42 | static_assert(!(x1_1 != x2_1), "" ); |
43 | static_assert(x1_1 != x3_2, "" ); |
44 | |
45 | typedef propagate_const<X> P; |
46 | |
47 | constexpr P p1_1(1); |
48 | constexpr P p2_1(1); |
49 | constexpr P p3_2(2); |
50 | |
51 | static_assert(!(p1_1 != p2_1), "" ); |
52 | static_assert(p1_1 != p3_2, "" ); |
53 | |
54 | static_assert(!(x1_1 != p1_1), "" ); |
55 | static_assert(x1_1 != p3_2, "" ); |
56 | |
57 | static_assert(!(p1_1 != x1_1), "" ); |
58 | static_assert(p1_1 != x3_2, "" ); |
59 | |
60 | static_assert(p1_1!=nullptr,"" ); |
61 | static_assert(nullptr!=p1_1,"" ); |
62 | |
63 | return 0; |
64 | } |
65 | |