Re: [PATCH] PR libstdc++/79162 ambiguity in string assignment due to string_view overload (LWG 2946)

2017-09-20 Thread Jonathan Wakely

On 20/09/17 18:59 +0100, Jonathan Wakely wrote:

On 20/09/17 17:52 +0100, Jonathan Wakely wrote:

On 20/09/17 16:36 +0100, Jonathan Wakely wrote:

On 04/09/17 16:48 +0100, Jonathan Wakely wrote:

On 30/07/17 15:01 +0200, Daniel Krügler wrote:

2017-07-28 22:40 GMT+02:00 Daniel Krügler :

2017-07-28 22:29 GMT+02:00 Daniel Krügler :

2017-07-28 22:25 GMT+02:00 Tim Song :

On Fri, Jul 28, 2017 at 4:10 PM, Daniel Krügler
 wrote:

+  // Performs an implicit conversion from _Tp to __sv_type.
+  template
+static __sv_type _S_to_string_view(const _Tp& __svt)
+{
+  return __svt;
+}


I might have gone for

+static __sv_type _S_to_string_view(__sv_type __svt) noexcept
+{
+  return __svt;
+}

With that, we can also use noexcept(_S_to_string_view(__t)) to make up
for the absence of is_nothrow_convertible (basically the same thing I
did in LWG 2993's PR).


Agreed, that makes very much sense. I will adjust the P/R, but before
I resubmit I would like to get feedback whether the other two compare
functions also should become conditionally noexcept.


Locally I have now performed the sole change of the _S_to_string_view
declaration getting rid of the template, but would also like to gather
feedback from the maintainers whether I should also change the form of
the conditional noexcept to use the expression

noexcept(_S_to_string_view(__t))

instead of the current

is_same<_Tp, __sv_type>::value

as suggested by Tim Song.

I'm asking also, because I have a paper proposing to standardize
is_nothrow_convertible submitted for the upcoming C++ mailing - This
would be one of the first applications in the library ;-)


A slightly revised patch update: It replaces the _S_to_string_view
template by a simpler _S_to_string_view function as of Tim Song's
suggestion, but still uses the simplified noexcept specification
deferring it to a future application case for is_nothrow_convertible.
Furthermore now all three compare function templates are now
(conditionally) noexcept by an (off-list) suggestion from Jonathan
Wakely.


I've committed this, after some whitespace fixes and testing.

Thanks!


This change causes two regressions in C++17 mode, see
https://gcc.gnu.org/ml/gcc-testresults/2017-09/msg01674.html

FAIL: 21_strings/basic_string/cons/char/moveable2.cc execution test
FAIL: 21_strings/basic_string/cons/wchar_t/moveable2.cc execution test

Here's a reduced version of that test, which passes in C++14 and fails
in C++17:

#include 
#include 

class tstring : public std::string
{
public:
tstring() : std::string() {}
tstring(tstring&& s) : std::string(std::move(s)) {}
};

int main()
{
tstring b;
b.push_back('1');
tstring c(std::move(b));
assert( c.size() == 1 && c[0] == '1' );
assert( b.size() == 0 );
}

The second assertion fails, because this mem-initializer:

tstring(tstring&& s) : std::string(std::move(s)) {}

now prefers to use the new constructor:

basic_string(const _Tp& __t, const _Alloc& __a = _Alloc())

because tstring is convertible to string_view.

This turns a non-allocating move into an allocating copy.


This patch fixes the failure above, I'm testing it now.

--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -115,6 +115,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
template
 using _If_sv = enable_if_t<
   __and_,
  __not_>::value,
   _Res>;




I'm committing this to fix the regression. If the final LWG 2946
resolution does something different we can change it again.

Tested powerpc64le-linux, committed to trunk.

I'll start another test run with all variations ...


That test run revealed I forgot to make the same change to the _If_sv
helper in the old std::basic_string.


commit ab3a6ce803de3d21325bb82978f1f6d61c5cb4e2
Author: Jonathan Wakely 
Date:   Wed Sep 20 22:48:04 2017 +0100

PR libstdc++/79162 Fix std::string regression due to LWG 2946 (old ABI)

PR libstdc++/79162
* include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI]
(basic_string::_If_sv): Remove from the overload set when the
argument is derived from basic_string.

diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 8a382d5640c..a4b81137571 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -3439,6 +3439,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
   template
 	using _If_sv = enable_if_t<
 	  __and_,
 		 __not_>::value,
 	  _Res>;
 


Re: [PATCH] PR libstdc++/79162 ambiguity in string assignment due to string_view overload (LWG 2946)

2017-09-20 Thread Jonathan Wakely

On 20/09/17 17:52 +0100, Jonathan Wakely wrote:

On 20/09/17 16:36 +0100, Jonathan Wakely wrote:

On 04/09/17 16:48 +0100, Jonathan Wakely wrote:

On 30/07/17 15:01 +0200, Daniel Krügler wrote:

2017-07-28 22:40 GMT+02:00 Daniel Krügler :

2017-07-28 22:29 GMT+02:00 Daniel Krügler :

2017-07-28 22:25 GMT+02:00 Tim Song :

On Fri, Jul 28, 2017 at 4:10 PM, Daniel Krügler
 wrote:

+  // Performs an implicit conversion from _Tp to __sv_type.
+  template
+static __sv_type _S_to_string_view(const _Tp& __svt)
+{
+  return __svt;
+}


I might have gone for

+static __sv_type _S_to_string_view(__sv_type __svt) noexcept
+{
+  return __svt;
+}

With that, we can also use noexcept(_S_to_string_view(__t)) to make up
for the absence of is_nothrow_convertible (basically the same thing I
did in LWG 2993's PR).


Agreed, that makes very much sense. I will adjust the P/R, but before
I resubmit I would like to get feedback whether the other two compare
functions also should become conditionally noexcept.


Locally I have now performed the sole change of the _S_to_string_view
declaration getting rid of the template, but would also like to gather
feedback from the maintainers whether I should also change the form of
the conditional noexcept to use the expression

noexcept(_S_to_string_view(__t))

instead of the current

is_same<_Tp, __sv_type>::value

as suggested by Tim Song.

I'm asking also, because I have a paper proposing to standardize
is_nothrow_convertible submitted for the upcoming C++ mailing - This
would be one of the first applications in the library ;-)


A slightly revised patch update: It replaces the _S_to_string_view
template by a simpler _S_to_string_view function as of Tim Song's
suggestion, but still uses the simplified noexcept specification
deferring it to a future application case for is_nothrow_convertible.
Furthermore now all three compare function templates are now
(conditionally) noexcept by an (off-list) suggestion from Jonathan
Wakely.


I've committed this, after some whitespace fixes and testing.

Thanks!


This change causes two regressions in C++17 mode, see
https://gcc.gnu.org/ml/gcc-testresults/2017-09/msg01674.html

FAIL: 21_strings/basic_string/cons/char/moveable2.cc execution test
FAIL: 21_strings/basic_string/cons/wchar_t/moveable2.cc execution test

Here's a reduced version of that test, which passes in C++14 and fails
in C++17:

#include 
#include 

class tstring : public std::string
{
public:
tstring() : std::string() {}
tstring(tstring&& s) : std::string(std::move(s)) {}
};

int main()
{
tstring b;
b.push_back('1');
tstring c(std::move(b));
assert( c.size() == 1 && c[0] == '1' );
assert( b.size() == 0 );
}

The second assertion fails, because this mem-initializer:

tstring(tstring&& s) : std::string(std::move(s)) {}

now prefers to use the new constructor:

basic_string(const _Tp& __t, const _Alloc& __a = _Alloc())

because tstring is convertible to string_view.

This turns a non-allocating move into an allocating copy.


This patch fixes the failure above, I'm testing it now.

--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -115,6 +115,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 template
  using _If_sv = enable_if_t<
__and_,
   __not_>::value,
_Res>;




I'm committing this to fix the regression. If the final LWG 2946
resolution does something different we can change it again.

Tested powerpc64le-linux, committed to trunk.

I'll start another test run with all variations ...


commit 45143c77f09ff9ebe27761bca81ccd4f9f928d9b
Author: Jonathan Wakely 
Date:   Wed Sep 20 17:56:53 2017 +0100

PR libstdc++/79162 Fix std::string regression due to LWG 2946

PR libstdc++/79162
* include/bits/basic_string.h (basic_string::_If_sv): Remove from the
overload set when the argument is derived from basic_string.
* testsuite/21_strings/basic_string/cons/char/moveable2_c++17.cc: New
test.
* testsuite/21_strings/basic_string/cons/wchar_t/moveable2_c++17.cc:
New test.

diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 0ef139b2c2b..8a382d5640c 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -115,6 +115,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   template
 	using _If_sv = enable_if_t<
 	  __and_,
 		 __not_>::value,
 	  _Res>;
 
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable2_c++17.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable2_c++17.cc
new file mode 

Re: [PATCH] PR libstdc++/79162 ambiguity in string assignment due to string_view overload (LWG 2946)

2017-09-20 Thread Jonathan Wakely

On 20/09/17 16:36 +0100, Jonathan Wakely wrote:

On 04/09/17 16:48 +0100, Jonathan Wakely wrote:

On 30/07/17 15:01 +0200, Daniel Krügler wrote:

2017-07-28 22:40 GMT+02:00 Daniel Krügler :

2017-07-28 22:29 GMT+02:00 Daniel Krügler :

2017-07-28 22:25 GMT+02:00 Tim Song :

On Fri, Jul 28, 2017 at 4:10 PM, Daniel Krügler
 wrote:

+  // Performs an implicit conversion from _Tp to __sv_type.
+  template
+static __sv_type _S_to_string_view(const _Tp& __svt)
+{
+  return __svt;
+}


I might have gone for

+static __sv_type _S_to_string_view(__sv_type __svt) noexcept
+{
+  return __svt;
+}

With that, we can also use noexcept(_S_to_string_view(__t)) to make up
for the absence of is_nothrow_convertible (basically the same thing I
did in LWG 2993's PR).


Agreed, that makes very much sense. I will adjust the P/R, but before
I resubmit I would like to get feedback whether the other two compare
functions also should become conditionally noexcept.


Locally I have now performed the sole change of the _S_to_string_view
declaration getting rid of the template, but would also like to gather
feedback from the maintainers whether I should also change the form of
the conditional noexcept to use the expression

noexcept(_S_to_string_view(__t))

instead of the current

is_same<_Tp, __sv_type>::value

as suggested by Tim Song.

I'm asking also, because I have a paper proposing to standardize
is_nothrow_convertible submitted for the upcoming C++ mailing - This
would be one of the first applications in the library ;-)


A slightly revised patch update: It replaces the _S_to_string_view
template by a simpler _S_to_string_view function as of Tim Song's
suggestion, but still uses the simplified noexcept specification
deferring it to a future application case for is_nothrow_convertible.
Furthermore now all three compare function templates are now
(conditionally) noexcept by an (off-list) suggestion from Jonathan
Wakely.


I've committed this, after some whitespace fixes and testing.

Thanks!


This change causes two regressions in C++17 mode, see
https://gcc.gnu.org/ml/gcc-testresults/2017-09/msg01674.html

FAIL: 21_strings/basic_string/cons/char/moveable2.cc execution test
FAIL: 21_strings/basic_string/cons/wchar_t/moveable2.cc execution test

Here's a reduced version of that test, which passes in C++14 and fails
in C++17:

#include 
#include 

class tstring : public std::string
{
public:
tstring() : std::string() {}
tstring(tstring&& s) : std::string(std::move(s)) {}
};

int main()
{
tstring b;
b.push_back('1');
tstring c(std::move(b));
assert( c.size() == 1 && c[0] == '1' );
assert( b.size() == 0 );
}

The second assertion fails, because this mem-initializer:

tstring(tstring&& s) : std::string(std::move(s)) {}

now prefers to use the new constructor:

basic_string(const _Tp& __t, const _Alloc& __a = _Alloc())

because tstring is convertible to string_view.

This turns a non-allocating move into an allocating copy.


This patch fixes the failure above, I'm testing it now.

--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -115,6 +115,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
  template
   using _If_sv = enable_if_t<
 __and_,
__not_>::value,
 _Res>;




Re: [PATCH] PR libstdc++/79162 ambiguity in string assignment due to string_view overload (LWG 2946)

2017-09-20 Thread Jonathan Wakely

On 04/09/17 16:48 +0100, Jonathan Wakely wrote:

On 30/07/17 15:01 +0200, Daniel Krügler wrote:

2017-07-28 22:40 GMT+02:00 Daniel Krügler :

2017-07-28 22:29 GMT+02:00 Daniel Krügler :

2017-07-28 22:25 GMT+02:00 Tim Song :

On Fri, Jul 28, 2017 at 4:10 PM, Daniel Krügler
 wrote:

+  // Performs an implicit conversion from _Tp to __sv_type.
+  template
+static __sv_type _S_to_string_view(const _Tp& __svt)
+{
+  return __svt;
+}


I might have gone for

+static __sv_type _S_to_string_view(__sv_type __svt) noexcept
+{
+  return __svt;
+}

With that, we can also use noexcept(_S_to_string_view(__t)) to make up
for the absence of is_nothrow_convertible (basically the same thing I
did in LWG 2993's PR).


Agreed, that makes very much sense. I will adjust the P/R, but before
I resubmit I would like to get feedback whether the other two compare
functions also should become conditionally noexcept.


Locally I have now performed the sole change of the _S_to_string_view
declaration getting rid of the template, but would also like to gather
feedback from the maintainers whether I should also change the form of
the conditional noexcept to use the expression

noexcept(_S_to_string_view(__t))

instead of the current

is_same<_Tp, __sv_type>::value

as suggested by Tim Song.

I'm asking also, because I have a paper proposing to standardize
is_nothrow_convertible submitted for the upcoming C++ mailing - This
would be one of the first applications in the library ;-)


A slightly revised patch update: It replaces the _S_to_string_view
template by a simpler _S_to_string_view function as of Tim Song's
suggestion, but still uses the simplified noexcept specification
deferring it to a future application case for is_nothrow_convertible.
Furthermore now all three compare function templates are now
(conditionally) noexcept by an (off-list) suggestion from Jonathan
Wakely.


I've committed this, after some whitespace fixes and testing.

Thanks!


This change causes two regressions in C++17 mode, see
https://gcc.gnu.org/ml/gcc-testresults/2017-09/msg01674.html

FAIL: 21_strings/basic_string/cons/char/moveable2.cc execution test
FAIL: 21_strings/basic_string/cons/wchar_t/moveable2.cc execution test

Here's a reduced version of that test, which passes in C++14 and fails
in C++17:

#include 
#include 

class tstring : public std::string
{
public:
 tstring() : std::string() {}
 tstring(tstring&& s) : std::string(std::move(s)) {}
};

int main()
{
 tstring b;
 b.push_back('1');
 tstring c(std::move(b));
 assert( c.size() == 1 && c[0] == '1' );
 assert( b.size() == 0 );
}

The second assertion fails, because this mem-initializer:

 tstring(tstring&& s) : std::string(std::move(s)) {}

now prefers to use the new constructor:

 basic_string(const _Tp& __t, const _Alloc& __a = _Alloc())

because tstring is convertible to string_view.

This turns a non-allocating move into an allocating copy.




Re: [PATCH] PR libstdc++/79162 ambiguity in string assignment due to string_view overload (LWG 2946)

2017-09-11 Thread Jonathan Wakely

On 04/09/17 16:48 +0100, Jonathan Wakely wrote:

On 30/07/17 15:01 +0200, Daniel Krügler wrote:

2017-07-28 22:40 GMT+02:00 Daniel Krügler :

2017-07-28 22:29 GMT+02:00 Daniel Krügler :

2017-07-28 22:25 GMT+02:00 Tim Song :

On Fri, Jul 28, 2017 at 4:10 PM, Daniel Krügler
 wrote:

+  // Performs an implicit conversion from _Tp to __sv_type.
+  template
+static __sv_type _S_to_string_view(const _Tp& __svt)
+{
+  return __svt;
+}


I might have gone for

+static __sv_type _S_to_string_view(__sv_type __svt) noexcept
+{
+  return __svt;
+}

With that, we can also use noexcept(_S_to_string_view(__t)) to make up
for the absence of is_nothrow_convertible (basically the same thing I
did in LWG 2993's PR).


Agreed, that makes very much sense. I will adjust the P/R, but before
I resubmit I would like to get feedback whether the other two compare
functions also should become conditionally noexcept.


Locally I have now performed the sole change of the _S_to_string_view
declaration getting rid of the template, but would also like to gather
feedback from the maintainers whether I should also change the form of
the conditional noexcept to use the expression

noexcept(_S_to_string_view(__t))

instead of the current

is_same<_Tp, __sv_type>::value

as suggested by Tim Song.

I'm asking also, because I have a paper proposing to standardize
is_nothrow_convertible submitted for the upcoming C++ mailing - This
would be one of the first applications in the library ;-)


A slightly revised patch update: It replaces the _S_to_string_view
template by a simpler _S_to_string_view function as of Tim Song's
suggestion, but still uses the simplified noexcept specification
deferring it to a future application case for is_nothrow_convertible.
Furthermore now all three compare function templates are now
(conditionally) noexcept by an (off-list) suggestion from Jonathan
Wakely.


I've committed this, after some whitespace fixes and testing.

Thanks!



We also need this tweak, to account for the fact that the old
std::string has this signature:

 basic_string& replace(iterator __i1, iterator __i2,
initializer_list<_CharT> __l)


Tested powerpc64le-linux, committed to trunk.


commit c435fd7ed919ae54fc8f730844c7466822787ff8
Author: Jonathan Wakely 
Date:   Mon Sep 11 17:29:34 2017 +0100

Adjust test to pass with old std::string

* testsuite/21_strings/basic_string/lwg2946.cc: Adjust for
compatibility with old COW std::string.

diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/lwg2946.cc b/libstdc++-v3/testsuite/21_strings/basic_string/lwg2946.cc
index 74d5a5c89a7..fe1f15553fb 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/lwg2946.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/lwg2946.cc
@@ -29,7 +29,7 @@ int main()
   s.assign({"abc", 1});
   s.insert(0, {"abc", 1});
   s.replace(0, 1, {"abc", 1});
-  s.replace(s.cbegin(), s.cbegin(), {"abc", 1});
+  s.replace(s.begin(), s.begin(), {"abc", 1});
   s.find({"abc", 1});
   s.rfind({"abc", 1});
   s.find_first_of({"abc", 1});


Re: [PATCH] PR libstdc++/79162 ambiguity in string assignment due to string_view overload (LWG 2946)

2017-09-04 Thread Jonathan Wakely

On 30/07/17 15:01 +0200, Daniel Krügler wrote:

2017-07-28 22:40 GMT+02:00 Daniel Krügler :

2017-07-28 22:29 GMT+02:00 Daniel Krügler :

2017-07-28 22:25 GMT+02:00 Tim Song :

On Fri, Jul 28, 2017 at 4:10 PM, Daniel Krügler
 wrote:

+  // Performs an implicit conversion from _Tp to __sv_type.
+  template
+static __sv_type _S_to_string_view(const _Tp& __svt)
+{
+  return __svt;
+}


I might have gone for

+static __sv_type _S_to_string_view(__sv_type __svt) noexcept
+{
+  return __svt;
+}

With that, we can also use noexcept(_S_to_string_view(__t)) to make up
for the absence of is_nothrow_convertible (basically the same thing I
did in LWG 2993's PR).


Agreed, that makes very much sense. I will adjust the P/R, but before
I resubmit I would like to get feedback whether the other two compare
functions also should become conditionally noexcept.


Locally I have now performed the sole change of the _S_to_string_view
declaration getting rid of the template, but would also like to gather
feedback from the maintainers whether I should also change the form of
the conditional noexcept to use the expression

noexcept(_S_to_string_view(__t))

instead of the current

is_same<_Tp, __sv_type>::value

as suggested by Tim Song.

I'm asking also, because I have a paper proposing to standardize
is_nothrow_convertible submitted for the upcoming C++ mailing - This
would be one of the first applications in the library ;-)


A slightly revised patch update: It replaces the _S_to_string_view
template by a simpler _S_to_string_view function as of Tim Song's
suggestion, but still uses the simplified noexcept specification
deferring it to a future application case for is_nothrow_convertible.
Furthermore now all three compare function templates are now
(conditionally) noexcept by an (off-list) suggestion from Jonathan
Wakely.


I've committed this, after some whitespace fixes and testing.

Thanks!



Re: [PATCH] PR libstdc++/79162 ambiguity in string assignment due to string_view overload (LWG 2946)

2017-08-18 Thread Daniel Krügler
Hi,

This is a friendly reminder asking for a review of the suggested patch!

Thanks,

- Daniel

2017-07-30 15:01 GMT+02:00 Daniel Krügler :
> 2017-07-28 22:40 GMT+02:00 Daniel Krügler :
>> 2017-07-28 22:29 GMT+02:00 Daniel Krügler :
>>> 2017-07-28 22:25 GMT+02:00 Tim Song :
 On Fri, Jul 28, 2017 at 4:10 PM, Daniel Krügler
  wrote:
> +  // Performs an implicit conversion from _Tp to __sv_type.
> +  template
> +static __sv_type _S_to_string_view(const _Tp& __svt)
> +{
> +  return __svt;
> +}

 I might have gone for

 +static __sv_type _S_to_string_view(__sv_type __svt) noexcept
 +{
 +  return __svt;
 +}

 With that, we can also use noexcept(_S_to_string_view(__t)) to make up
 for the absence of is_nothrow_convertible (basically the same thing I
 did in LWG 2993's PR).
>>>
>>> Agreed, that makes very much sense. I will adjust the P/R, but before
>>> I resubmit I would like to get feedback whether the other two compare
>>> functions also should become conditionally noexcept.
>>
>> Locally I have now performed the sole change of the _S_to_string_view
>> declaration getting rid of the template, but would also like to gather
>> feedback from the maintainers whether I should also change the form of
>> the conditional noexcept to use the expression
>>
>> noexcept(_S_to_string_view(__t))
>>
>> instead of the current
>>
>> is_same<_Tp, __sv_type>::value
>>
>> as suggested by Tim Song.
>>
>> I'm asking also, because I have a paper proposing to standardize
>> is_nothrow_convertible submitted for the upcoming C++ mailing - This
>> would be one of the first applications in the library ;-)
>
> A slightly revised patch update: It replaces the _S_to_string_view
> template by a simpler _S_to_string_view function as of Tim Song's
> suggestion, but still uses the simplified noexcept specification
> deferring it to a future application case for is_nothrow_convertible.
> Furthermore now all three compare function templates are now
> (conditionally) noexcept by an (off-list) suggestion from Jonathan
> Wakely.
>
> Thanks,
>
> - Daniel



-- 


SavedURI :Show URLShow URLSavedURI :
SavedURI :Hide URLHide URLSavedURI :
https://mail.google.com/_/scs/mail-static/_/js/k=gmail.main.de.LEt2fN4ilLE.O/m=m_i,t,it/am=OCMOBiHj9kJxhnelj6j997_NLil29vVAOBGeBBRgJwD-m_0_8B_AD-qOEw/rt=h/d=1/rs=AItRSTODy9wv1JKZMABIG3Ak8ViC4kuOWA?random=1395770800154https://mail.google.com/_/scs/mail-static/_/js/k=gmail.main.de.LEt2fN4ilLE.O/m=m_i,t,it/am=OCMOBiHj9kJxhnelj6j997_NLil29vVAOBGeBBRgJwD-m_0_8B_AD-qOEw/rt=h/d=1/rs=AItRSTODy9wv1JKZMABIG3Ak8ViC4kuOWA?random=1395770800154



Re: [PATCH] PR libstdc++/79162 ambiguity in string assignment due to string_view overload (LWG 2946)

2017-07-30 Thread Daniel Krügler
2017-07-28 22:40 GMT+02:00 Daniel Krügler :
> 2017-07-28 22:29 GMT+02:00 Daniel Krügler :
>> 2017-07-28 22:25 GMT+02:00 Tim Song :
>>> On Fri, Jul 28, 2017 at 4:10 PM, Daniel Krügler
>>>  wrote:
 +  // Performs an implicit conversion from _Tp to __sv_type.
 +  template
 +static __sv_type _S_to_string_view(const _Tp& __svt)
 +{
 +  return __svt;
 +}
>>>
>>> I might have gone for
>>>
>>> +static __sv_type _S_to_string_view(__sv_type __svt) noexcept
>>> +{
>>> +  return __svt;
>>> +}
>>>
>>> With that, we can also use noexcept(_S_to_string_view(__t)) to make up
>>> for the absence of is_nothrow_convertible (basically the same thing I
>>> did in LWG 2993's PR).
>>
>> Agreed, that makes very much sense. I will adjust the P/R, but before
>> I resubmit I would like to get feedback whether the other two compare
>> functions also should become conditionally noexcept.
>
> Locally I have now performed the sole change of the _S_to_string_view
> declaration getting rid of the template, but would also like to gather
> feedback from the maintainers whether I should also change the form of
> the conditional noexcept to use the expression
>
> noexcept(_S_to_string_view(__t))
>
> instead of the current
>
> is_same<_Tp, __sv_type>::value
>
> as suggested by Tim Song.
>
> I'm asking also, because I have a paper proposing to standardize
> is_nothrow_convertible submitted for the upcoming C++ mailing - This
> would be one of the first applications in the library ;-)

A slightly revised patch update: It replaces the _S_to_string_view
template by a simpler _S_to_string_view function as of Tim Song's
suggestion, but still uses the simplified noexcept specification
deferring it to a future application case for is_nothrow_convertible.
Furthermore now all three compare function templates are now
(conditionally) noexcept by an (off-list) suggestion from Jonathan
Wakely.

Thanks,

- Daniel


ChangeLog_79162.patch
Description: Binary data


79162.patch
Description: Binary data


Re: [PATCH] PR libstdc++/79162 ambiguity in string assignment due to string_view overload (LWG 2946)

2017-07-28 Thread Daniel Krügler
2017-07-28 22:29 GMT+02:00 Daniel Krügler :
> 2017-07-28 22:25 GMT+02:00 Tim Song :
>> On Fri, Jul 28, 2017 at 4:10 PM, Daniel Krügler
>>  wrote:
>>> +  // Performs an implicit conversion from _Tp to __sv_type.
>>> +  template
>>> +static __sv_type _S_to_string_view(const _Tp& __svt)
>>> +{
>>> +  return __svt;
>>> +}
>>
>> I might have gone for
>>
>> +static __sv_type _S_to_string_view(__sv_type __svt) noexcept
>> +{
>> +  return __svt;
>> +}
>>
>> With that, we can also use noexcept(_S_to_string_view(__t)) to make up
>> for the absence of is_nothrow_convertible (basically the same thing I
>> did in LWG 2993's PR).
>
> Agreed, that makes very much sense. I will adjust the P/R, but before
> I resubmit I would like to get feedback whether the other two compare
> functions also should become conditionally noexcept.

Locally I have now performed the sole change of the _S_to_string_view
declaration getting rid of the template, but would also like to gather
feedback from the maintainers whether I should also change the form of
the conditional noexcept to use the expression

noexcept(_S_to_string_view(__t))

instead of the current

is_same<_Tp, __sv_type>::value

as suggested by Tim Song.

I'm asking also, because I have a paper proposing to standardize
is_nothrow_convertible submitted for the upcoming C++ mailing - This
would be one of the first applications in the library ;-)

> Thanks,
>
> - Daniel


Re: [PATCH] PR libstdc++/79162 ambiguity in string assignment due to string_view overload (LWG 2946)

2017-07-28 Thread Daniel Krügler
2017-07-28 22:25 GMT+02:00 Tim Song :
> On Fri, Jul 28, 2017 at 4:10 PM, Daniel Krügler
>  wrote:
>> +  // Performs an implicit conversion from _Tp to __sv_type.
>> +  template
>> +static __sv_type _S_to_string_view(const _Tp& __svt)
>> +{
>> +  return __svt;
>> +}
>
> I might have gone for
>
> +static __sv_type _S_to_string_view(__sv_type __svt) noexcept
> +{
> +  return __svt;
> +}
>
> With that, we can also use noexcept(_S_to_string_view(__t)) to make up
> for the absence of is_nothrow_convertible (basically the same thing I
> did in LWG 2993's PR).

Agreed, that makes very much sense. I will adjust the P/R, but before
I resubmit I would like to get feedback whether the other two compare
functions also should become conditionally noexcept.

Thanks,

- Daniel


Re: [PATCH] PR libstdc++/79162 ambiguity in string assignment due to string_view overload (LWG 2946)

2017-07-28 Thread Tim Song
On Fri, Jul 28, 2017 at 4:10 PM, Daniel Krügler
 wrote:
> +  // Performs an implicit conversion from _Tp to __sv_type.
> +  template
> +static __sv_type _S_to_string_view(const _Tp& __svt)
> +{
> +  return __svt;
> +}

I might have gone for

+static __sv_type _S_to_string_view(__sv_type __svt) noexcept
+{
+  return __svt;
+}

With that, we can also use noexcept(_S_to_string_view(__t)) to make up
for the absence of is_nothrow_convertible (basically the same thing I
did in LWG 2993's PR).

Tim