2019-04-26 Jonathan Wakely <jwakely@redhat.com>
+ * testsuite/20_util/variant/run.cc: Use a new Hashable type to test
+ hashing, because pmr::string depends on _GLIBCXX_USE_CXX11_ABI==1.
+ * testsuite/21_strings/basic_string/hash/hash.cc
+ [!_GLIBCXX_USE_CXX11_ABI]: Don't test pmr strings.
+ * testsuite/21_strings/basic_string/hash/hash_char8_t.cc
+ [!_GLIBCXX_USE_CXX11_ABI]: Likewise.
+
* config/abi/pre/gnu.ver (GLIBCXX_3.4): Replace wildcard that matches
wstring::_M_replace_dispatch with more specific patterns.
* include/bits/fs_path.h (path::_S_convert_loc<_InputIterator>):
#include <string>
#include <vector>
#include <unordered_set>
-#include <memory_resource>
#include <ext/throw_allocator.h>
#include <testsuite_hooks.h>
}
}
+struct Hashable
+{
+ Hashable(const char* s) : s(s) { }
+ // Non-trivial special member functions:
+ Hashable(const Hashable&) { }
+ Hashable(Hashable&&) noexcept { }
+ ~Hashable() { }
+
+ string s;
+
+ bool operator==(const Hashable& rhs) const noexcept
+ { return s == rhs.s; }
+};
+
+namespace std {
+ template<> struct hash<Hashable> {
+ size_t operator()(const Hashable& h) const noexcept
+ { return hash<std::string>()(h.s); }
+ };
+}
+
void test_hash()
{
- unordered_set<variant<int, pmr::string>> s;
+ unordered_set<variant<int, Hashable>> s;
VERIFY(s.emplace(3).second);
VERIFY(s.emplace("asdf").second);
VERIFY(s.emplace().second);
{
struct A
{
- operator pmr::string()
+ operator Hashable()
{
throw nullptr;
}
};
- variant<int, pmr::string> v;
+ variant<int, Hashable> v;
try
{
v.emplace<1>(A{});
test01()
{
VERIFY( test(std::string("a narrow string")) );
- VERIFY( test(std::pmr::string("a narrow string, but with PMR!")) );
VERIFY( test(std::u16string(u"a utf-16 string")) );
- VERIFY( test(std::pmr::u16string(u"a utf-16 string, but with PMR!")) );
VERIFY( test(std::u32string(U"a utf-32 string")) );
- VERIFY( test(std::pmr::u32string(U"a utf-32 string, but with PMR!")) );
#if _GLIBCXX_USE_WCHAR_T
VERIFY( test(std::wstring(L"a wide string")) );
+#endif
+}
+
+void
+test02()
+{
+#if _GLIBCXX_USE_CXX11_ABI
+ VERIFY( test(std::pmr::string("a narrow string, but with PMR!")) );
+ VERIFY( test(std::pmr::u16string(u"a utf-16 string, but with PMR!")) );
+ VERIFY( test(std::pmr::u32string(U"a utf-32 string, but with PMR!")) );
+#if _GLIBCXX_USE_WCHAR_T
VERIFY( test(std::pmr::wstring(L"a wide string, but with PMR!")) );
#endif
+#endif
}
int
main()
{
test01();
+ test02();
}
test01()
{
VERIFY( test(std::string("a narrow string")) );
- VERIFY( test(std::pmr::string("a narrow string, but with PMR!")) );
VERIFY( test(std::u8string(u8"a utf-8 string")) );
+#if _GLIBCXX_USE_CXX11_ABI
+ VERIFY( test(std::pmr::string("a narrow string, but with PMR!")) );
VERIFY( test(std::pmr::u8string(u8"a utf-8 string, but with PMR!")) );
+#endif
}
void