1ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe//===----------------------------------------------------------------------===// 2ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe// 3ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe// The LLVM Compiler Infrastructure 4ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe// 5ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe// This file is dual licensed under the MIT and the University of Illinois Open 6ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe// Source Licenses. See LICENSE.TXT for details. 7ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe// 8ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe//===----------------------------------------------------------------------===// 9ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 10ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe// UNSUPPORTED: c++98, c++03, c++11 11ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 12ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe// <propagate_const> 13ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 14ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe// template <class T> constexpr bool operator!=(const propagate_const<T>& x, const propagate_const<T>& y); 15ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe// template <class T> constexpr bool operator!=(const T& x, const propagate_const<T>& y); 16ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe// template <class T> constexpr bool operator!=(const propagate_const<T>& x, const T& y); 17ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 18ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe#include <experimental/propagate_const> 19ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe#include "propagate_const_helpers.h" 20ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe#include <cassert> 21ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 22ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coeusing std::experimental::propagate_const; 23ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coeusing std::nullptr_t; 24ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 25ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coeconstexpr bool operator!=(const X &lhs, const X &rhs) { 26ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe return lhs.i_ != rhs.i_; 27ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe} 28ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 29ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coeconstexpr bool operator!=(const X &, const nullptr_t &) { 30ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe return true; 31ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe} 32ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 33ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coeconstexpr bool operator!=(const nullptr_t &, const X &) { 34ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe return true; 35ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe} 36ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 37ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coeint main() { 38ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe constexpr X x1_1(1); 39ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe constexpr X x2_1(1); 40ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe constexpr X x3_2(2); 41ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 42ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe static_assert(!(x1_1 != x2_1), ""); 43ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe static_assert(x1_1 != x3_2, ""); 44ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 45ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe typedef propagate_const<X> P; 46ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 47ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe constexpr P p1_1(1); 48ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe constexpr P p2_1(1); 49ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe constexpr P p3_2(2); 50ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 51ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe static_assert(!(p1_1 != p2_1), ""); 52ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe static_assert(p1_1 != p3_2, ""); 53ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 54ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe static_assert(!(x1_1 != p1_1), ""); 55ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe static_assert(x1_1 != p3_2, ""); 56ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 57ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe static_assert(!(p1_1 != x1_1), ""); 58ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe static_assert(p1_1 != x3_2, ""); 59ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe 60ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe static_assert(p1_1!=nullptr,""); 61ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe static_assert(nullptr!=p1_1,""); 62ee49613ff465e6f7627ec6d70b8930e9a3f72423Jonathan Coe} 63