This rebase skips the following patches in upstream: +37025e1b32Make the helper routines in string really be constexpr. This required a bit of refacoring in algorithm as well. Give them better names while we're at it. All of these are internal rotines; no visible functionality change. +164b297099Implement string_view from the library fundamentals TS (n4023). Also works in C++11 and 03, with reduced functionality (mostly in the area of constexpr) +e4694b4129Formatting improvements in the <string_view> synopsis suggested by RSmith. No functionality change. +3a61b30f3aMinor cleanup for string_view; mostly from suggestions by Richard Smith. Also, make the tests pass under c++03 +484728789estring_view enhancements. Move to the correct namespace. Better constexpr support (thanks to Richard for the suggestions). Update the tests to match this. Add <experimental/__config for experimental macros/etc to live. +b1a40264dc[libcxx] Add <experimental/utility> header for LFTS. +3ee7233c80[libcxx] expose experimental::erased_type for all standard versions. +67740670f9NFC. Remove trailing whitespace and tabs. +b9536101dcNFC. Move definition of _LIBCPP_ASSERT into __debug header and remove external include guards. +98c4e404ca. Revert "Turn off extern templates for most uses." Bug: 17255369 Change-Id: I629ff16275d50e4cc8767b253a2c0542468348d8
160 lines
3.7 KiB
C++
160 lines
3.7 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// 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.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// <map>
|
|
|
|
// class multimap
|
|
|
|
// size_type count(const key_type& k) const;
|
|
|
|
#include <map>
|
|
#include <cassert>
|
|
|
|
#include "min_allocator.h"
|
|
#include "private_constructor.hpp"
|
|
|
|
int main()
|
|
{
|
|
typedef std::pair<const int, double> V;
|
|
{
|
|
typedef std::multimap<int, double> 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);
|
|
}
|
|
}
|
|
#if __cplusplus >= 201103L
|
|
{
|
|
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> 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);
|
|
}
|
|
}
|
|
#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
|
|
}
|