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 true; 31} 32 33constexpr bool operator!=(const nullptr_t &, const X &) { 34 return true; 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 != 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