self.cxx.addCompileFlagIfSupported('-Wno-pessimizing-move')
self.cxx.addCompileFlagIfSupported('-Wno-c++11-extensions')
self.cxx.addCompileFlagIfSupported('-Wno-user-defined-literals')
+ std = self.get_lit_conf('std', None)
+ if std in ['c++98', 'c++03']:
+ # The '#define static_assert' provided by libc++ in C++03 mode
+ # causes an unused local typedef whenever it is used.
+ self.cxx.addCompileFlagIfSupported('-Wno-unused-local-typedef')
def configure_sanitizer(self):
san = self.get_lit_conf('use_sanitizer', '').strip()
#include <string>
#include <cassert>
+#include "test_macros.h"
#include "min_allocator.h"
int main()
{
{
typedef std::unordered_map<int, std::string> C;
- typedef C::const_iterator I;
- typedef std::pair<int, std::string> P;
const C c;
assert(c.bucket_count() == 0);
}
{
typedef std::unordered_map<int, std::string> C;
- typedef C::const_iterator I;
typedef std::pair<int, std::string> P;
P a[] =
{
const C c(std::begin(a), std::end(a));
assert(c.bucket_count() >= 11);
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
- typedef C::const_iterator I;
- typedef std::pair<int, std::string> P;
const C c;
assert(c.bucket_count() == 0);
}
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
- typedef C::const_iterator I;
typedef std::pair<int, std::string> P;
P a[] =
{
// http://llvm.org/bugs/show_bug.cgi?id=16549
#include <unordered_map>
+#include <cassert>
struct Key {
template <typename T> Key(const T&) {}
int
main()
{
- std::unordered_map<Key, int>::iterator it =
- std::unordered_map<Key, int>().find(Key(0));
- std::pair<std::unordered_map<Key, int>::iterator, bool> result =
- std::unordered_map<Key, int>().insert(std::make_pair(Key(0), 0));
+ typedef std::unordered_map<Key, int> MapT;
+ typedef MapT::iterator Iter;
+ MapT map;
+ Iter it = map.find(Key(0));
+ assert(it == map.end());
+ std::pair<Iter, bool> result = map.insert(std::make_pair(Key(0), 42));
+ assert(result.second);
+ assert(result.first->second == 42);
}
#include <cassert>
#include <cfloat>
+#include "test_macros.h"
#include "min_allocator.h"
int main()
}
{
typedef std::unordered_map<int, std::string> C;
- typedef std::pair<int, std::string> P;
const C c;
assert(c.load_factor() == 0);
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
- typedef std::pair<int, std::string> P;
const C c;
assert(c.load_factor() == 0);
}
#include <string>
#include <cassert>
+#include "test_macros.h"
#include "min_allocator.h"
int main()
{
{
typedef std::unordered_map<int, std::string> C;
- typedef C::const_iterator I;
- typedef std::pair<int, std::string> P;
const C c;
assert(c.max_bucket_count() > 0);
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
- typedef C::const_iterator I;
- typedef std::pair<int, std::string> P;
const C c;
assert(c.max_bucket_count() > 0);
}
// float max_load_factor() const;
// void max_load_factor(float mlf);
-#ifdef _LIBCPP_DEBUG
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-#endif
-
#include <unordered_map>
#include <string>
#include <cassert>
+#include "test_macros.h"
#include "min_allocator.h"
int main()
{
{
typedef std::unordered_map<int, std::string> C;
- typedef std::pair<int, std::string> P;
const C c;
assert(c.max_load_factor() == 1);
}
{
typedef std::unordered_map<int, std::string> C;
- typedef std::pair<int, std::string> P;
C c;
assert(c.max_load_factor() == 1);
c.max_load_factor(2.5);
assert(c.max_load_factor() == 2.5);
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
- typedef std::pair<int, std::string> P;
const C c;
assert(c.max_load_factor() == 1);
}
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
- typedef std::pair<int, std::string> P;
C c;
assert(c.max_load_factor() == 1);
c.max_load_factor(2.5);
#include "../../test_compare.h"
#include "../../test_hash.h"
+#include "test_macros.h"
#include "test_allocator.h"
#include "min_allocator.h"
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
- typedef std::pair<int, std::string> P;
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
- typedef std::pair<int, std::string> P;
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef min_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
- typedef std::pair<int, std::string> P;
C c1(0, Hash(1), Compare(1), Alloc());
C c2(0, Hash(2), Compare(2), Alloc());
c2.max_load_factor(2);
// unordered_map(unordered_map&& u);
+// UNSUPPORTED: c++98, c++03
+
#include <unordered_map>
#include <string>
#include <cassert>
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
test_allocator<std::pair<const int, std::string> >
> C;
- typedef std::pair<int, std::string> P;
- P a[] =
- {
- P(1, "one"),
- P(2, "two"),
- P(3, "three"),
- P(4, "four"),
- P(1, "four"),
- P(2, "four"),
- };
C c0(7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
assert(c0.empty());
}
-#if __cplusplus >= 201103L
{
typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >,
test_compare<std::equal_to<int> >,
min_allocator<std::pair<const int, std::string> >
> C;
- typedef std::pair<int, std::string> P;
- P a[] =
- {
- P(1, "one"),
- P(2, "two"),
- P(3, "three"),
- P(4, "four"),
- P(1, "four"),
- P(2, "four"),
- };
C c0(7,
test_hash<std::hash<int> >(8),
test_compare<std::equal_to<int> >(9),
assert(c0.empty());
}
-#endif
#if _LIBCPP_DEBUG >= 1
{
std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
assert(s2.size() == 2);
}
#endif
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#include <string>
#include <cassert>
+#include "test_macros.h"
#include "min_allocator.h"
struct TemplateConstructor
};
C c(a, a + sizeof(a)/sizeof(a[0]));
C::const_iterator i = c.find(2);
- C::iterator j = c.erase(i);
+ c.erase(i);
assert(c.size() == 3);
assert(c.at(1) == "one");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
};
C c(a, a + sizeof(a)/sizeof(a[0]));
C::const_iterator i = c.find(2);
- C::iterator j = c.erase(i);
+ c.erase(i);
assert(c.size() == 3);
assert(c.at(1) == "one");
assert(c.at(3) == "three");
assert(c.at(4) == "four");
}
#endif
-#if __cplusplus >= 201402L
+#if TEST_STD_VER >= 14
{
// This is LWG #2059
typedef TemplateConstructor T;
#include <string>
#include <cassert>
+#include "test_macros.h"
#include "min_allocator.h"
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
template <typename Unordered>
bool only_deletions ( const Unordered &whole, const Unordered &part ) {
typename Unordered::const_iterator w = whole.begin();
typename Unordered::const_iterator p = part.begin();
-
- while ( w != whole.end () && p != part.end()) {
+
+ while ( w != whole.end () && p != part.end()) {
if ( *w == *p )
p++;
w++;
assert(c.erase(3) == 0);
assert(c.size() == 0);
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
m[i] = i;
m2[i] = i;
}
-
+
C::iterator i = m2.begin();
int ctr = 0;
while (i != m2.end()) {
//
//===----------------------------------------------------------------------===//
//
-// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: c++98, c++03, c++11, c++14
// <unordered_map>
// template <class M>
// iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17
-#include <__config>
#include <unordered_map>
#include <cassert>
#include <tuple>
-#include <iostream>
class Moveable
{
bool operator<(const Moveable& x) const
{return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);}
size_t hash () const { return std::hash<int>()(int_) + std::hash<double>()(double_); }
-
+
int get() const {return int_;}
bool moved() const {return int_ == -1;}
};
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
{ // pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
typedef std::unordered_map<int, Moveable> M;
assert(r->second.get() == 5); // value
}
-#endif // _LIBCPP_HAS_NO_VARIADICS
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
\ No newline at end of file
//
//===----------------------------------------------------------------------===//
//
-// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: c++98, c++03, c++11, c++14
// <unordered_map>
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
{ // pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
typedef std::unordered_map<int, Moveable> M;
assert(r.first->second.get() == -1); // value
}
- { // pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
+ { // pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
typedef std::unordered_map<Moveable, Moveable> M;
typedef std::pair<M::iterator, bool> R;
M m;
m.try_emplace ( i, Moveable(i, (double) i));
assert(m.size() == 10);
M::const_iterator it = m.find(2);
-
+
Moveable mv1(3, 3.0);
for (int i=0; i < 20; i += 2)
{
assert(r->first.get() == 3); // key
assert(r->second.get() == 4); // value
}
-
-#endif // _LIBCPP_HAS_NO_VARIADICS
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#include "../../../test_compare.h"
#include "../../../test_hash.h"
+#include "test_macros.h"
#include "test_allocator.h"
#include "min_allocator.h"
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
- typedef std::pair<int, std::string> P;
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
typedef test_compare<std::equal_to<int> > Compare;
typedef other_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
- typedef std::pair<int, std::string> P;
C c1(0, Hash(1), Compare(1), Alloc(1));
C c2(0, Hash(2), Compare(2), Alloc(2));
c2.max_load_factor(2);
assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
assert(c2.max_load_factor() == 1);
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef min_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
- typedef std::pair<int, std::string> P;
C c1(0, Hash(1), Compare(1), Alloc());
C c2(0, Hash(2), Compare(2), Alloc());
c2.max_load_factor(2);