[PATCH] D54705: [libcxx] [test] Portability fix: change header for struct hash.

Andrey Maksimov via Phabricator reviews at reviews.llvm.org
Mon Nov 19 08:48:31 PST 2018

amakc11 created this revision.
Herald added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, ldionne.

The Emplaceble.h test header defines hash function for containers used during testing. For this purpose, it creates a specialization of struct hash template defined in namespace std. However, to get access to struct hash it includes wrong header <utility>. According to C++11 standard, struct hash should be defined in the following standard headers:

1. <system_error> (section [syserr]);
2. <bitset> (section [template.bitset]);
3. <memory> (section [memory.syn]);
4. <functional> (sections [function.objects], [unord.hash]);
5. <typeindex> (section [type.index.synopsis]);
6. <string> (section [string.classes]);
7. <vector> (section [sequences.general]);
8. <thread> (section [thread.thread.id]).

Header <utility> is not in this list even in the later editions of the standard. As a result, tests including Emplaceble.h test header won't compile against some conformant libraries. The choice for <functional> as a substitute is made in accordance with the recommendation to applications <https://en.cppreference.com/w/cpp/utility/hash>.

  rCXX libc++



Index: test/std/containers/Emplaceable.h
--- test/std/containers/Emplaceable.h
+++ test/std/containers/Emplaceable.h
@@ -10,7 +10,7 @@
-#include <utility>
+#include <functional>
 #include "test_macros.h"
 #if TEST_STD_VER >= 11

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54705.174620.patch
Type: text/x-patch
Size: 346 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20181119/355dfbd0/attachment-0001.bin>

More information about the libcxx-commits mailing list