[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
std::experimental::optional operator!=
From: |
Lars Gullik Bjønnes |
Subject: |
std::experimental::optional operator!= |
Date: |
Sat, 29 Mar 2014 15:48:29 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Hi,
When trying to convert some code using boost::optional to using
std::experimental::optional instead if come over the issue that I had to
implement operator!= for the contained types.
When looking at n3793 it states that operator!= should be implemented
with !(t1 == t2), and not t1 != t2 as the implementation in gcc 4.9 is
doing. This is the case for both the operator!= implementation where
optional<T> is compared against T.
The other operators look ok, and only operator== and operator< are used
in their implementations.
Can this be fixed before 4.9?
(changelog not done)
>From 6a93dcb458f055d94d13386ef68a39893327be84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= <larsbj@gullik.org>
Date: Sat, 29 Mar 2014 15:46:47 +0100
Subject: [PATCH] optional: implement operator!= in terms of operator==
---
libstdc++-v3/include/experimental/optional | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/include/experimental/optional
b/libstdc++-v3/include/experimental/optional
index 5f2d93f..2a3f29d 100644
--- a/libstdc++-v3/include/experimental/optional
+++ b/libstdc++-v3/include/experimental/optional
@@ -736,12 +736,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp>
constexpr bool
operator!=(const optional<_Tp>& __lhs, _Tp const& __rhs)
- { return !__lhs || *__lhs != __rhs; }
+ { return !__lhs || !(*__lhs == __rhs); }
template<typename _Tp>
constexpr bool
operator!=(const _Tp& __lhs, const optional<_Tp>& __rhs)
- { return !__rhs || __lhs != *__rhs; }
+ { return !__rhs || !(__lhs == *__rhs); }
template<typename _Tp>
constexpr bool
--
1.9.1.352.gd393d14
--
Lgb
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- std::experimental::optional operator!=,
Lars Gullik Bjønnes <=