Fix bug 20740 - std::set/std::map don't support heterogeneous lookup for count(). Thanks to Jim Porter for the bug report

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@216353 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2014-08-24 23:54:16 +00:00
parent a564dc53dd
commit 4de32048f5
6 changed files with 307 additions and 2 deletions

View File

@@ -17,6 +17,7 @@
#include <cassert>
#include "min_allocator.h"
#include "private_constructor.hpp"
int main()
{
@@ -89,4 +90,70 @@ int main()
}
}
#endif
#if _LIBCPP_STD_VER > 11
{
typedef std::multimap<int, double, std::less<>> M;
typedef M::size_type R;
V ar[] =
{
V(5, 1),
V(5, 2),
V(5, 3),
V(7, 1),
V(7, 2),
V(7, 3),
V(9, 1),
V(9, 2),
V(9, 3)
};
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
R r = m.count(4);
assert(r == 0);
r = m.count(5);
assert(r == 3);
r = m.count(6);
assert(r == 0);
r = m.count(7);
assert(r == 3);
r = m.count(8);
assert(r == 0);
r = m.count(9);
assert(r == 3);
r = m.count(10);
assert(r == 0);
}
{
typedef PrivateConstructor PC;
typedef std::multimap<PC, double, std::less<>> M;
typedef M::size_type R;
M m;
m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
R r = m.count(4);
assert(r == 0);
r = m.count(5);
assert(r == 3);
r = m.count(6);
assert(r == 0);
r = m.count(7);
assert(r == 3);
r = m.count(8);
assert(r == 0);
r = m.count(9);
assert(r == 3);
r = m.count(10);
assert(r == 0);
}
#endif
}