1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// UNSUPPORTED: c++98, c++03, c++11 11 12// <propagate_const> 13 14// template <class T> constexpr bool operator==(const propagate_const<T>& x, const propagate_const<T>& y); 15// template <class T> constexpr bool operator==(const T& x, const propagate_const<T>& y); 16// template <class T> constexpr bool operator==(const propagate_const<T>& x, const T& y); 17 18#include <experimental/propagate_const> 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() { 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