Tag() : val(0), tag("Default") {}
Tag(int a, const char *b) : val(a), tag(b) {}
~Tag() {}
-
+
int val;
const char *tag;
};
-
+
bool eq(const Tag& rhs, const Tag& lhs) { return rhs.val == lhs.val && rhs.tag == lhs.tag; }
// bool operator==(const Tag& rhs, const Tag& lhs) { return rhs.val == lhs.val; }
bool comp (const Tag& rhs, const Tag& lhs) { return rhs.val < lhs.val; }
Tag() : val(0), tag("Default") {}
Tag(int a, const char *b) : val(a), tag(b) {}
~Tag() {}
-
+
int val;
const char *tag;
};
-
+
bool eq(const Tag& rhs, const Tag& lhs) { return rhs.val == lhs.val && rhs.tag == lhs.tag; }
// bool operator==(const Tag& rhs, const Tag& lhs) { return rhs.val == lhs.val; }
bool operator< (const Tag& rhs, const Tag& lhs) { return rhs.val < lhs.val; }
test<std::atomic_uint32_t, uint32_t>();
test<std::atomic_int64_t, int64_t>();
test<std::atomic_uint64_t, uint64_t>();
-
+
test<volatile std::atomic_char, char>();
test<volatile std::atomic_schar, signed char>();
test<volatile std::atomic_uchar, unsigned char>();
// <map>
-// Check that std::map fails to instantiate if the comparison predicate is
+// Check that std::map fails to instantiate if the comparison predicate is
// not copy-constructible. This is LWG issue 2436
#include <map>
int foo{0};
counting_allocatorT(int f) noexcept : foo(f) {}
- using propagate_on_container_copy_assignment = std::true_type;
+ using propagate_on_container_copy_assignment = std::true_type;
template <class U> counting_allocatorT(const counting_allocatorT<U>& other) noexcept {foo = other.foo;}
template <class U> bool operator==(const counting_allocatorT<U>& other) const noexcept { return foo == other.foo; }
template <class U> bool operator!=(const counting_allocatorT<U>& other) const noexcept { return foo != other.foo; }
int foo{0};
counting_allocatorF(int f) noexcept : foo(f) {}
- using propagate_on_container_copy_assignment = std::false_type;
+ using propagate_on_container_copy_assignment = std::false_type;
template <class U> counting_allocatorF(const counting_allocatorF<U>& other) noexcept {foo = other.foo;}
template <class U> bool operator==(const counting_allocatorF<U>& other) const noexcept { return foo == other.foo; }
template <class U> bool operator!=(const counting_allocatorF<U>& other) const noexcept { return foo != other.foo; }
bool balanced_allocs() {
std::vector<int> temp1, temp2;
-
+
std::cout << "Allocations = " << ca_allocs.size() << ", deallocatons = " << ca_deallocs.size() << std::endl;
if (ca_allocs.size() != ca_deallocs.size())
return false;
temp2.clear();
std::unique_copy(temp1.begin(), temp1.end(), std::back_inserter<std::vector<int>>(temp2));
std::cout << "There were " << temp2.size() << " different allocators\n";
-
+
for (std::vector<int>::const_iterator it = temp2.begin(); it != temp2.end(); ++it ) {
std::cout << *it << ": " << std::count(ca_allocs.begin(), ca_allocs.end(), *it) << " vs " << std::count(ca_deallocs.begin(), ca_deallocs.end(), *it) << std::endl;
if ( std::count(ca_allocs.begin(), ca_allocs.end(), *it) != std::count(ca_deallocs.begin(), ca_deallocs.end(), *it))
return false;
}
-
+
temp1 = ca_allocs;
std::sort(temp1.begin(), temp1.end());
temp2.clear();
if ( std::count(ca_allocs.begin(), ca_allocs.end(), *it) != std::count(ca_deallocs.begin(), ca_deallocs.end(), *it))
return false;
}
-
+
return true;
}
#endif
// <map>
-// Check that std::multimap fails to instantiate if the comparison predicate is
+// Check that std::multimap fails to instantiate if the comparison predicate is
// not copy-constructible. This is LWG issue 2436
#include <map>
// <set>
-// Check that std::multiset fails to instantiate if the comparison predicate is
+// Check that std::multiset fails to instantiate if the comparison predicate is
// not copy-constructible. This is LWG issue 2436
#include <set>
// <set>
-// Check that std::set fails to instantiate if the comparison predicate is
+// Check that std::set fails to instantiate if the comparison predicate is
// not copy-constructible. This is LWG issue 2436
#include <set>
Nasty() : i_(0) {}
Nasty(int i) : i_(i) {}
~Nasty() {}
-
+
Nasty * operator&() const { assert(false); return nullptr; }
int i_;
};
Nasty() : i_(0) {}
Nasty(int i) : i_(i) {}
~Nasty() {}
-
+
Nasty * operator&() const { assert(false); return nullptr; }
int i_;
};
// <unordered_map>
-// Check that std::unordered_map fails to instantiate if the comparison predicate is
+// Check that std::unordered_map fails to instantiate if the comparison predicate is
// not copy-constructible. This is LWG issue 2436
#include <unordered_map>
// <unordered_map>
-// Check that std::unordered_map fails to instantiate if the hash function is
+// Check that std::unordered_map fails to instantiate if the hash function is
// not copy-constructible. This is mentioned in LWG issue 2436
#include <unordered_map>
// <unordered_map>
-// Check that std::unordered_multimap fails to instantiate if the comparison predicate is
+// Check that std::unordered_multimap fails to instantiate if the comparison predicate is
// not copy-constructible. This is LWG issue 2436
#include <unordered_map>
// <unordered_map>
-// Check that std::unordered_multimap fails to instantiate if the hash function is
+// Check that std::unordered_multimap fails to instantiate if the hash function is
// not copy-constructible. This is mentioned in LWG issue 2436
#include <unordered_map>
// <unordered_set>
-// Check that std::unordered_set fails to instantiate if the comparison predicate is
+// Check that std::unordered_set fails to instantiate if the comparison predicate is
// not copy-constructible. This is LWG issue 2436
#include <unordered_set>
// <unordered_set>
-// Check that std::unordered_multiset fails to instantiate if the hash function is
+// Check that std::unordered_multiset fails to instantiate if the hash function is
// not copy-constructible. This is mentioned in LWG issue 2436
#include <unordered_set>
// <unordered_set>
-// Check that std::unordered_set fails to instantiate if the comparison predicate is
+// Check that std::unordered_set fails to instantiate if the comparison predicate is
// not copy-constructible. This is LWG issue 2436
#include <unordered_set>
// <unordered_map>
-// Check that std::unordered_set fails to instantiate if the hash function is
+// Check that std::unordered_set fails to instantiate if the hash function is
// not copy-constructible. This is mentioned in LWG issue 2436
#include <unordered_set>
struct is_error_code_enum<A> : public std::true_type {};
}
-
+
int main()
{
test<false, void>();
struct is_error_condition_enum<A> : public std::true_type {};
}
-
+
int main()
{
test<false, void>();
test<false, int>();
test<false, std::nullptr_t>();
test<false, std::string>();
-
+
test<true, A>();
}
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11
// <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11
// <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11
// <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11
// <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11
// <numeric>
FakeIter crbegin(const FakeContainer &) { return 13; }
FakeIter crend (const FakeContainer &) { return 14; }
}
-
+
int main(){
// Bug #28927 - shouldn't find these via ADL
(void) std::cbegin (Foo::FakeContainer());
(void) std::cend (Foo::FakeContainer());
(void) std::crbegin(Foo::FakeContainer());
- (void) std::crend (Foo::FakeContainer());
+ (void) std::crend (Foo::FakeContainer());
}
#endif
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
test(s, s, true);
test(s, s+1, false);
-
+
#if TEST_STD_VER > 14
{
constexpr const char *p = "123456789";
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <numeric>
// template<class _M, class _N>
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
-// Remarks: If either M or N is not an integer type,
+// Remarks: If either M or N is not an integer type,
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
#include <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <numeric>
// template<class _M, class _N>
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
-// Remarks: If either M or N is not an integer type,
+// Remarks: If either M or N is not an integer type,
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
#include <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <numeric>
// template<class _M, class _N>
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
-// Remarks: If either M or N is not an integer type,
+// Remarks: If either M or N is not an integer type,
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
#include <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <numeric>
// template<class _M, class _N>
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
-// Remarks: If either M or N is not an integer type,
+// Remarks: If either M or N is not an integer type,
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
#include <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <numeric>
// template<class _M, class _N>
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
-// Remarks: If either M or N is not an integer type,
+// Remarks: If either M or N is not an integer type,
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
#include <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <numeric>
// template<class _M, class _N>
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
-// Remarks: If either M or N is not an integer type,
+// Remarks: If either M or N is not an integer type,
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
#include <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <numeric>
// template<class _M, class _N>
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
-// Remarks: If either M or N is not an integer type,
+// Remarks: If either M or N is not an integer type,
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
#include <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <numeric>
// template<class _M, class _N>
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
-// Remarks: If either M or N is not an integer type,
+// Remarks: If either M or N is not an integer type,
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
#include <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <numeric>
// template<class _M, class _N>
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
-// Remarks: If either M or N is not an integer type,
+// Remarks: If either M or N is not an integer type,
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
#include <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <numeric>
// template<class _M, class _N>
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
-// Remarks: If either M or N is not an integer type,
+// Remarks: If either M or N is not an integer type,
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
#include <numeric>
// template<class _M, class _N>
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
-// Remarks: If either M or N is not an integer type,
+// Remarks: If either M or N is not an integer type,
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
#include <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <numeric>
// template<class _M, class _N>
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
-// Remarks: If either M or N is not an integer type,
+// Remarks: If either M or N is not an integer type,
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
#include <numeric>
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-//
+//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <numeric>
// <string>
// template<class _Tp>
-// basic_string(const _Tp& __t, size_type __pos, size_type __n,
+// basic_string(const _Tp& __t, size_type __pos, size_type __n,
// const allocator_type& __a = allocator_type());
//
// Mostly we're testing string_view here
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
-
+
s_short.append(s_short.begin(), s_short.end());
assert(s_short == "123/123/");
s_short.append(s_short.begin(), s_short.end());
assert(s_short == "123/123/123/123/");
s_short.append(s_short.begin(), s_short.end());
assert(s_short == "123/123/123/123/123/123/123/123/");
-
+
s_long.append(s_long.begin(), s_long.end());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
}
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
-
+
s_short.append(s_short.c_str());
assert(s_short == "123/123/");
s_short.append(s_short.c_str());
assert(s_short == "123/123/123/123/");
s_short.append(s_short.c_str());
assert(s_short == "123/123/123/123/123/123/123/123/");
-
+
s_long.append(s_long.c_str());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
}
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
-
+
s_short.append(s_short.data(), s_short.size());
assert(s_short == "123/123/");
s_short.append(s_short.data(), s_short.size());
assert(s_short == "123/123/123/123/");
s_short.append(s_short.data(), s_short.size());
assert(s_short == "123/123/123/123/123/123/123/123/");
-
+
s_long.append(s_long.data(), s_long.size());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
}
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
-
+
s_short.assign(s_short.begin(), s_short.end());
assert(s_short == "123/");
s_short.assign(s_short.begin() + 2, s_short.end());
assert(s_short == "3/");
-
+
s_long.assign(s_long.begin(), s_long.end());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/");
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
-
+
s_short.assign(s_short.c_str());
assert(s_short == "123/");
s_short.assign(s_short.c_str() + 2);
assert(s_short == "3/");
-
+
s_long.assign(s_long.c_str() + 30);
assert(s_long == "nsectetur/");
}
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
-
+
s_short.assign(s_short.data(), s_short.size());
assert(s_short == "123/");
s_short.assign(s_short.data() + 2, s_short.size() - 2);
assert(s_short == "3/");
-
+
s_long.assign(s_long.data(), s_long.size());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/");
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
-
+
s_short.insert(s_short.begin(), s_short.begin(), s_short.end());
assert(s_short == "123/123/");
s_short.insert(s_short.begin(), s_short.begin(), s_short.end());
assert(s_short == "123/123/123/123/");
s_short.insert(s_short.begin(), s_short.begin(), s_short.end());
assert(s_short == "123/123/123/123/123/123/123/123/");
-
+
s_long.insert(s_long.begin(), s_long.begin(), s_long.end());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
}
s.insert(0, sv, 0); // calls insert(T, pos, npos)
assert(s == sv);
s.clear();
-
+
s.insert(0, sv, 0, std::string::npos); // calls insert(T, pos, npos)
assert(s == sv);
s.clear();
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
-
+
s_short.insert(0, s_short.c_str());
assert(s_short == "123/123/");
s_short.insert(0, s_short.c_str());
assert(s_short == "123/123/123/123/");
s_short.insert(0, s_short.c_str());
assert(s_short == "123/123/123/123/123/123/123/123/");
-
+
s_long.insert(0, s_long.c_str());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
}
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
-
+
s_short.insert(0, s_short.data(), s_short.size());
assert(s_short == "123/123/");
s_short.insert(0, s_short.data(), s_short.size());
assert(s_short == "123/123/123/123/");
s_short.insert(0, s_short.data(), s_short.size());
assert(s_short == "123/123/123/123/123/123/123/123/");
-
+
s_long.insert(0, s_long.data(), s_long.size());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
}
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
-
+
s_short.replace(s_short.begin(), s_short.begin(), s_short.begin(), s_short.end());
assert(s_short == "123/123/");
s_short.replace(s_short.begin(), s_short.begin(), s_short.begin(), s_short.end());
assert(s_short == "123/123/123/123/");
s_short.replace(s_short.begin(), s_short.begin(), s_short.begin(), s_short.end());
assert(s_short == "123/123/123/123/123/123/123/123/");
-
+
s_long.replace(s_long.begin(), s_long.begin(), s_long.begin(), s_long.end());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
}
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
-
+
s_short.replace(s_short.begin(), s_short.begin(), s_short.c_str());
assert(s_short == "123/123/");
s_short.replace(s_short.begin(), s_short.begin(), s_short.c_str());
assert(s_short == "123/123/123/123/");
s_short.replace(s_short.begin(), s_short.begin(), s_short.c_str());
assert(s_short == "123/123/123/123/123/123/123/123/");
-
+
s_long.replace(s_long.begin(), s_long.begin(), s_long.c_str());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
}
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
-
+
s_short.replace(s_short.begin(), s_short.begin(), s_short.data(), s_short.size());
assert(s_short == "123/123/");
s_short.replace(s_short.begin(), s_short.begin(), s_short.data(), s_short.size());
assert(s_short == "123/123/123/123/");
s_short.replace(s_short.begin(), s_short.begin(), s_short.data(), s_short.size());
assert(s_short == "123/123/123/123/123/123/123/123/");
-
+
s_long.replace(s_long.begin(), s_long.begin(), s_long.data(), s_long.size());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
}
// <string>
// template <class T>
-// basic_string& replace(size_type pos1, size_type n1, const T& t,
+// basic_string& replace(size_type pos1, size_type n1, const T& t,
// size_type pos2, size_type n=npos);
//
// Mostly we're testing string_view here
// <string>
// we get this comparison "for free" because the string implicitly converts to the string_view
-
+
#include <string>
#include <cassert>
static_assert((std::is_same<std::underlying_type<E>::type, int>::value),
"E has the wrong underlying type");
static_assert((std::is_same<std::underlying_type<F>::type, ExpectUnsigned>::value),
- "F has the wrong underlying type");
+ "F has the wrong underlying type");
#if TEST_STD_VER > 11
static_assert((std::is_same<std::underlying_type_t<E>, int>::value), "");
- static_assert((std::is_same<std::underlying_type_t<F>, ExpectUnsigned>::value), "");
+ static_assert((std::is_same<std::underlying_type_t<F>, ExpectUnsigned>::value), "");
#endif
#if TEST_STD_VER >= 11