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
22using std::experimental::propagate_const;
23using std::nullptr_t;
24
25constexpr bool operator==(const X &lhs, const X &rhs) {
26 return lhs.i_ == rhs.i_;
27}
28
29constexpr bool operator==(const X &, const nullptr_t &) {
30 return false;
31}
32
33constexpr bool operator==(const nullptr_t &, const X &) {
34 return false;
35}
36
37int 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 == x1_1, "");
43 static_assert(x1_1 == x2_1, "");
44 static_assert(!(x1_1 == x3_2), "");
45
46 typedef propagate_const<X> P;
47
48 constexpr P p1_1(1);
49 constexpr P p2_1(1);
50 constexpr P p3_2(2);
51
52 static_assert(p1_1 == p1_1, "");
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/equal.pass.cpp