* [PATCH] Add noexcept to generic std::size, std::empty and std::data
@ 2017-11-15 18:16 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2017-11-15 18:16 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 212 bytes --]
The standard doesn't say these are noexcept, but they can be.
* include/bits/range_access.h (size, empty, data): Add conditional
noexcept to generic overloads.
Tested powerpc64le-linux, committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2015 bytes --]
commit 9348811e74851f9ce6594cbe1b98a855193867dc
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Nov 15 17:38:28 2017 +0000
Add noexcept to generic std::size, std::empty and std::data
* include/bits/range_access.h (size, empty, data): Add conditional
noexcept to generic overloads.
diff --git a/libstdc++-v3/include/bits/range_access.h b/libstdc++-v3/include/bits/range_access.h
index 3987c2addf1..2a037ad8082 100644
--- a/libstdc++-v3/include/bits/range_access.h
+++ b/libstdc++-v3/include/bits/range_access.h
@@ -230,7 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif // C++14
-#if __cplusplus > 201402L
+#if __cplusplus >= 201703L
#define __cpp_lib_nonmember_container_access 201411
/**
@@ -239,7 +239,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template <typename _Container>
constexpr auto
- size(const _Container& __cont) -> decltype(__cont.size())
+ size(const _Container& __cont) noexcept(noexcept(__cont.size()))
+ -> decltype(__cont.size())
{ return __cont.size(); }
/**
@@ -257,7 +258,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template <typename _Container>
constexpr auto
- empty(const _Container& __cont) -> decltype(__cont.empty())
+ empty(const _Container& __cont) noexcept(noexcept(__cont.empty()))
+ -> decltype(__cont.empty())
{ return __cont.empty(); }
/**
@@ -284,7 +286,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template <typename _Container>
constexpr auto
- data(_Container& __cont) -> decltype(__cont.data())
+ data(_Container& __cont) noexcept(noexcept(__cont.data()))
+ -> decltype(__cont.data())
{ return __cont.data(); }
/**
@@ -293,7 +296,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template <typename _Container>
constexpr auto
- data(const _Container& __cont) -> decltype(__cont.data())
+ data(const _Container& __cont) noexcept(noexcept(__cont.data()))
+ -> decltype(__cont.data())
{ return __cont.data(); }
/**
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-11-15 17:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-15 18:16 [PATCH] Add noexcept to generic std::size, std::empty and std::data Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).