diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-04-09 12:05:39 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-04-09 13:09:24 +0100 |
commit | 40ccb47b505b528244ee305923681c0ae3b6f4d5 (patch) | |
tree | 62953d42d3a187906e35d20d2dbd0f09760efb26 /libstdc++-v3/include/bits/hashtable.h | |
parent | 72ddd861d3881eba141c41c1ccbb4e8b3be159a5 (diff) | |
download | gcc-40ccb47b505b528244ee305923681c0ae3b6f4d5.zip gcc-40ccb47b505b528244ee305923681c0ae3b6f4d5.tar.gz gcc-40ccb47b505b528244ee305923681c0ae3b6f4d5.tar.bz2 |
libstdc++: Fix invalid constexpr function in C++11 mode [PR 99985]
I keep forgetting that a constexpr function in C++11 has to be a single
return statement.
libstdc++-v3/ChangeLog:
PR libstdc++/99985
* include/bits/hashtable.h (_Hashtable::_S_nothrow_move()): Fix
to be a valid constexpr function in C++11.
* testsuite/23_containers/unordered_set/cons/99985.cc: New test.
Diffstat (limited to 'libstdc++-v3/include/bits/hashtable.h')
-rw-r--r-- | libstdc++-v3/include/bits/hashtable.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index 39872ce..6711d08 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -476,10 +476,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr bool _S_nothrow_move() { - if _GLIBCXX17_CONSTEXPR (_No_realloc) - if _GLIBCXX17_CONSTEXPR (is_nothrow_copy_constructible<_Hash>()) +#if __cplusplus <= 201402L + return __and_<__bool_constant<_No_realloc>, + is_nothrow_copy_constructible<_Hash>, + is_nothrow_copy_constructible<_Equal>>::value; +#else + if constexpr (_No_realloc) + if constexpr (is_nothrow_copy_constructible<_Hash>()) return is_nothrow_copy_constructible<_Equal>(); return false; +#endif } _Hashtable(_Hashtable&& __ht, __node_alloc_type&& __a, |