Fix warnings in array and assoc containers

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242629 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2015-07-18 23:56:04 +00:00
parent 47c5dae573
commit 02bb4bdb49
22 changed files with 96 additions and 29 deletions

View File

@@ -17,16 +17,36 @@
// http://llvm.org/bugs/show_bug.cgi?id=16549
#include <map>
#include <utility>
#include <cassert>
struct Key {
template <typename T> Key(const T&) {}
bool operator< (const Key&) const { return false; }
};
int
main()
int main()
{
std::map<Key, int>::iterator it = std::map<Key, int>().find(Key(0));
std::pair<std::map<Key, int>::iterator, bool> result =
std::map<Key, int>().insert(std::make_pair(Key(0), 0));
typedef std::map<Key, int> MapT;
typedef MapT::iterator Iter;
typedef std::pair<Iter, bool> IterBool;
{
MapT m_empty;
MapT m_contains;
m_contains[Key(0)] = 42;
Iter it = m_empty.find(Key(0));
assert(it == m_empty.end());
it = m_contains.find(Key(0));
assert(it != m_contains.end());
}
{
MapT map;
IterBool result = map.insert(std::make_pair(Key(0), 42));
assert(result.second);
assert(result.first->second = 42);
IterBool result2 = map.insert(std::make_pair(Key(0), 43));
assert(!result2.second);
assert(map[Key(0)] == 42);
}
}