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 <cassert>
19#include <cstddef>
20
21#include "test_macros.h"
22#include "propagate_const_helpers.h"
23
24using std::experimental::propagate_const;
25using std::nullptr_t;
26
27constexpr bool operator!=(const X &lhs, const X &rhs) {
28 return lhs.i_ != rhs.i_;
29}
30
31constexpr bool operator!=(const X &, const nullptr_t &) {
32 return true;
33}
34
35constexpr bool operator!=(const nullptr_t &, const X &) {
36 return true;
37}
38
39int main(int, char**) {
40 constexpr X x1_1(1);
41 constexpr X x2_1(1);
42 constexpr X x3_2(2);
43
44 static_assert(!(x1_1 != x2_1), "");
45 static_assert(x1_1 != x3_2, "");
46
47 typedef propagate_const<X> P;
48
49 constexpr P p1_1(1);
50 constexpr P p2_1(1);
51 constexpr P p3_2(2);
52
53 static_assert(!(p1_1 != p2_1), "");
54 static_assert(p1_1 != p3_2, "");
55
56 static_assert(!(x1_1 != p1_1), "");
57 static_assert(x1_1 != p3_2, "");
58
59 static_assert(!(p1_1 != x1_1), "");
60 static_assert(p1_1 != x3_2, "");
61
62 static_assert(p1_1!=nullptr,"");
63 static_assert(nullptr!=p1_1,"");
64
65 return 0;
66}
67

source code of libcxx/test/std/experimental/utilities/propagate_const/propagate_const.nonmembers/propagate_const.relops/not_equal.pass.cpp