[cfe-dev] Determining whether Container<T>()==Container<T>() can compile?
steveire at gmail.com
Wed May 29 05:23:04 PDT 2013
On 05/29/2013 10:12 AM, Mailing List Email wrote:
> The problem essentially comes from that there exists an operator ==
> that compares two vectors, hence decltype(a == b) would succeed,
> because decltype does not evaluate its arguments.
> Instead, the problem happens inside the operator == when it tries to
> compare the elements.
Yes, I think that's right. Using the type of begin() is a bit of a hack
because it's not really typesafe. I'd prefer the stdlib container
implementations to provide the correct result instead with patches
diff --git a/include/vector b/include/vector
index e04c267..41bd687 100644
@@ -3168,8 +3168,9 @@ struct _LIBCPP_TYPE_VIS hash<vector<bool,
template <class _Tp, class _Allocator>
operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp,
_Allocator>::value_type&>() == std::declval<typename vector<_Tp,
const typename vector<_Tp, _Allocator>::size_type __sz = __x.size();
return __sz == __y.size() && _VSTD::equal(__x.begin(), __x.end(),
I can't actually figure out how to use libcxx on linux, so the above is
More information about the cfe-dev