diff mbox

Make string_view operations involving CharT* *not* noexcept and consistent beween string_view and string_view.tcc.

Message ID 20140415190646.GT6807@redhat.com
State New
Headers show

Commit Message

Jonathan Wakely April 15, 2014, 7:06 p.m. UTC
On 29/03/14 14:54 -0400, Ed Smith-Rowland wrote:
>All,
>
>In string_view I botched the noexcept specification of operations 
>like find and friends with CharT* arguments.
>
>I'm a little surprised the inconsistency between string_view and 
>string_view.tcc didn't error.  In fact, in one repo thats a little 
>behind trunk it does.  I'll continue to look after that issue 
>separately.

I'm fixing this differently, by strengthening the exception specs as
Marc suggested. I haven't addressed Marc's other comments, but we
should do.

Tested x86_64-linux, committed to trunk.
commit 5ac00aa4544a4c10c3eeadb8ca2a3ce57d9e62ce
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Apr 15 19:45:29 2014 +0100

    	* include/experimental/string_view: Fix inconsistent exception specs.

Comments

Ed Smith-Rowland April 16, 2014, 2:57 p.m. UTC | #1
On 04/15/2014 03:06 PM, Jonathan Wakely wrote:
> On 29/03/14 14:54 -0400, Ed Smith-Rowland wrote:
>> All,
>>
>> In string_view I botched the noexcept specification of operations 
>> like find and friends with CharT* arguments.
>>
>> I'm a little surprised the inconsistency between string_view and 
>> string_view.tcc didn't error.  In fact, in one repo thats a little 
>> behind trunk it does.  I'll continue to look after that issue 
>> separately.
>
> I'm fixing this differently, by strengthening the exception specs as
> Marc suggested. I haven't addressed Marc's other comments, but we
> should do.
>
> Tested x86_64-linux, committed to trunk.
Thanks,

The latest library fundamentals paper has a lot of changes coming - a 
lot of constexpr in the find type functions.  Unfortunately, most of 
that will wave to wait until we get C++14 constexpr.

Also, if the built-in strlen is or could be made constexpr then all the 
char* ctors could be constexpr as well.
Jonathan Wakely Aug. 26, 2014, 11:25 a.m. UTC | #2
On 15/04/14 20:06 +0100, Jonathan Wakely wrote:
>On 29/03/14 14:54 -0400, Ed Smith-Rowland wrote:
>>All,
>>
>>In string_view I botched the noexcept specification of operations 
>>like find and friends with CharT* arguments.
>>
>>I'm a little surprised the inconsistency between string_view and 
>>string_view.tcc didn't error.  In fact, in one repo thats a little 
>>behind trunk it does.  I'll continue to look after that issue 
>>separately.
>
>I'm fixing this differently, by strengthening the exception specs as
>Marc suggested. I haven't addressed Marc's other comments, but we
>should do.
>
>Tested x86_64-linux, committed to trunk.

I've also committed this on the 4.9 branch, to fix PR62264

>commit 5ac00aa4544a4c10c3eeadb8ca2a3ce57d9e62ce
>Author: Jonathan Wakely <jwakely@redhat.com>
>Date:   Tue Apr 15 19:45:29 2014 +0100
>
>    	* include/experimental/string_view: Fix inconsistent exception specs.
>
>diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view
>index bebeb6b..6b6588b 100644
>--- a/libstdc++-v3/include/experimental/string_view
>+++ b/libstdc++-v3/include/experimental/string_view
>@@ -329,7 +329,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>       find(_CharT __c, size_type __pos=0) const noexcept;
>
>       size_type
>-      find(const _CharT* __str, size_type __pos, size_type __n) const;
>+      find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
>
>       size_type
>       find(const _CharT* __str, size_type __pos=0) const noexcept
>@@ -343,7 +343,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>       rfind(_CharT __c, size_type __pos = npos) const noexcept;
>
>       size_type
>-      rfind(const _CharT* __str, size_type __pos, size_type __n) const;
>+      rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
>
>       size_type
>       rfind(const _CharT* __str, size_type __pos = npos) const noexcept
>
diff mbox

Patch

diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view
index bebeb6b..6b6588b 100644
--- a/libstdc++-v3/include/experimental/string_view
+++ b/libstdc++-v3/include/experimental/string_view
@@ -329,7 +329,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       find(_CharT __c, size_type __pos=0) const noexcept;
 
       size_type
-      find(const _CharT* __str, size_type __pos, size_type __n) const;
+      find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
 
       size_type
       find(const _CharT* __str, size_type __pos=0) const noexcept
@@ -343,7 +343,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       rfind(_CharT __c, size_type __pos = npos) const noexcept;
 
       size_type
-      rfind(const _CharT* __str, size_type __pos, size_type __n) const;
+      rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
 
       size_type
       rfind(const _CharT* __str, size_type __pos = npos) const noexcept