diff --git a/include/map b/include/map index df174daa..d0cd0c6b 100644 --- a/include/map +++ b/include/map @@ -389,7 +389,6 @@ template ::valu class __map_value_compare : private _Compare { - typedef pair::type, _Tp> _Pp; typedef pair _CP; public: _LIBCPP_INLINE_VISIBILITY @@ -406,29 +405,11 @@ public: bool operator()(const _CP& __x, const _CP& __y) const {return static_cast(*this)(__x.first, __y.first);} _LIBCPP_INLINE_VISIBILITY - bool operator()(const _CP& __x, const _Pp& __y) const - {return static_cast(*this)(__x.first, __y.first);} - _LIBCPP_INLINE_VISIBILITY bool operator()(const _CP& __x, const _Key& __y) const {return static_cast(*this)(__x.first, __y);} _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Pp& __x, const _CP& __y) const - {return static_cast(*this)(__x.first, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Pp& __x, const _Pp& __y) const - {return static_cast(*this)(__x.first, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Pp& __x, const _Key& __y) const - {return static_cast(*this)(__x.first, __y);} - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _CP& __y) const {return static_cast(*this)(__x, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Key& __x, const _Pp& __y) const - {return static_cast(*this)(__x, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Key& __x, const _Key& __y) const - {return static_cast(*this)(__x, __y);} }; template @@ -436,7 +417,6 @@ class __map_value_compare<_Key, _Tp, _Compare, false> { _Compare comp; - typedef pair::type, _Tp> _Pp; typedef pair _CP; public: @@ -455,29 +435,11 @@ public: bool operator()(const _CP& __x, const _CP& __y) const {return comp(__x.first, __y.first);} _LIBCPP_INLINE_VISIBILITY - bool operator()(const _CP& __x, const _Pp& __y) const - {return comp(__x.first, __y.first);} - _LIBCPP_INLINE_VISIBILITY bool operator()(const _CP& __x, const _Key& __y) const {return comp(__x.first, __y);} _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Pp& __x, const _CP& __y) const - {return comp(__x.first, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Pp& __x, const _Pp& __y) const - {return comp(__x.first, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Pp& __x, const _Key& __y) const - {return comp(__x.first, __y);} - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _CP& __y) const {return comp(__x, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Key& __x, const _Pp& __y) const - {return comp(__x, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Key& __x, const _Key& __y) const - {return comp(__x, __y);} }; template diff --git a/include/unordered_map b/include/unordered_map index 772c44b6..cc30d763 100644 --- a/include/unordered_map +++ b/include/unordered_map @@ -333,7 +333,6 @@ template ::value class __unordered_map_hasher : private _Hash { - typedef pair::type, _Tp> _Pp; typedef pair _Cp; public: _LIBCPP_INLINE_VISIBILITY @@ -347,9 +346,6 @@ public: _LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const _NOEXCEPT {return *this;} _LIBCPP_INLINE_VISIBILITY - size_t operator()(const _Pp& __x) const - {return static_cast(*this)(__x.first);} - _LIBCPP_INLINE_VISIBILITY size_t operator()(const _Cp& __x) const {return static_cast(*this)(__x.first);} _LIBCPP_INLINE_VISIBILITY @@ -362,7 +358,6 @@ class __unordered_map_hasher<_Key, _Tp, _Hash, false> { _Hash __hash_; - typedef pair::type, _Tp> _Pp; typedef pair _Cp; public: _LIBCPP_INLINE_VISIBILITY @@ -376,9 +371,6 @@ public: _LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const _NOEXCEPT {return __hash_;} _LIBCPP_INLINE_VISIBILITY - size_t operator()(const _Pp& __x) const - {return __hash_(__x.first);} - _LIBCPP_INLINE_VISIBILITY size_t operator()(const _Cp& __x) const {return __hash_(__x.first);} _LIBCPP_INLINE_VISIBILITY @@ -394,7 +386,6 @@ template ::value class __unordered_map_equal : private _Pred { - typedef pair::type, _Tp> _Pp; typedef pair _Cp; public: _LIBCPP_INLINE_VISIBILITY @@ -408,32 +399,14 @@ public: _LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const _NOEXCEPT {return *this;} _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Pp& __x, const _Pp& __y) const - {return static_cast(*this)(__x.first, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Pp& __x, const _Cp& __y) const - {return static_cast(*this)(__x.first, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Pp& __x, const _Key& __y) const - {return static_cast(*this)(__x.first, __y);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Cp& __x, const _Pp& __y) const - {return static_cast(*this)(__x.first, __y.first);} - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Cp& __x, const _Cp& __y) const {return static_cast(*this)(__x.first, __y.first);} _LIBCPP_INLINE_VISIBILITY bool operator()(const _Cp& __x, const _Key& __y) const {return static_cast(*this)(__x.first, __y);} _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Key& __x, const _Pp& __y) const - {return static_cast(*this)(__x, __y.first);} - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _Cp& __y) const {return static_cast(*this)(__x, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Key& __x, const _Key& __y) const - {return static_cast(*this)(__x, __y);} }; template @@ -441,7 +414,6 @@ class __unordered_map_equal<_Key, _Tp, _Pred, false> { _Pred __pred_; - typedef pair::type, _Tp> _Pp; typedef pair _Cp; public: _LIBCPP_INLINE_VISIBILITY @@ -455,32 +427,14 @@ public: _LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const _NOEXCEPT {return __pred_;} _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Pp& __x, const _Pp& __y) const - {return __pred_(__x.first, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Pp& __x, const _Cp& __y) const - {return __pred_(__x.first, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Pp& __x, const _Key& __y) const - {return __pred_(__x.first, __y);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Cp& __x, const _Pp& __y) const - {return __pred_(__x.first, __y.first);} - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Cp& __x, const _Cp& __y) const {return __pred_(__x.first, __y.first);} _LIBCPP_INLINE_VISIBILITY bool operator()(const _Cp& __x, const _Key& __y) const {return __pred_(__x.first, __y);} _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Key& __x, const _Pp& __y) const - {return __pred_(__x, __y.first);} - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _Cp& __y) const {return __pred_(__x, __y.first);} - _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Key& __x, const _Key& __y) const - {return __pred_(__x, __y);} }; template diff --git a/test/containers/associative/map/compare.pass.cpp b/test/containers/associative/map/compare.pass.cpp new file mode 100644 index 00000000..f5e69173 --- /dev/null +++ b/test/containers/associative/map/compare.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template , +// class Allocator = allocator>> +// class map + +// http://llvm.org/bugs/show_bug.cgi?id=16538 + +#include + +struct Key { + template Key(const T&) {} + bool operator< (const Key&) const { return false; } +}; + +int +main() +{ + std::map::iterator it = std::map().find(Key(0)); +} diff --git a/test/containers/unord/unord.map/compare.pass.cpp b/test/containers/unord/unord.map/compare.pass.cpp new file mode 100644 index 00000000..814c40f2 --- /dev/null +++ b/test/containers/unord/unord.map/compare.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// http://llvm.org/bugs/show_bug.cgi?id=16538 + +#include + +struct Key { + template Key(const T&) {} + bool operator== (const Key&) const { return true; } +}; + +namespace std +{ + template <> + struct hash + { + size_t operator()(Key const &) const {return 0;} + }; +} + +int +main() +{ + std::unordered_map::iterator it = + std::unordered_map().find(Key(0)); +}