On 11/09/17 22:48 +0100, Jonathan Wakely wrote:
This adds 'constexpr' everywhere it's missing from
std::basic_string_view.
And this does it for std::experimental::basic_string_view, fixing the
bug as reported.
Tested powerpc64le-linux, committed to trunk.
commit d1cb3e5ac0bf7b07a06d4b8bbdd4f6752be112ae
Author: Jonathan Wakely
Date: Tue Sep 12 10:44:38 2017 +0100
PR libstdc++/70483 make std::experimental::string_view fully constexpr
PR libstdc++/70483
* include/experimental/bits/string_view.tcc (basic_string_view::find)
(basic_string_view::rfind, basic_string_view::find_first_of)
(basic_string_view::find_last_of, basic_string_view::find_first_not_of)
(basic_string_view::find_last_not_of): Add constexpr specifier.
* include/experimental/string_view (basic_string_view::remove_prefix)
(basic_string_view::remove_suffix, basic_string_view::swap)
(basic_string_view::compare, basic_string_view::find)
(basic_string_view::rfind, basic_string_view::find_first_of)
(basic_string_view::find_last_of, basic_string_view::find_first_not_of)
(basic_string_view::find_last_not_of, operator==, operator!=)
(operator<, operator>, operator<=, operator>=): Likewise.
* testsuite/experimental/string_view/operations/compare/char/70483.cc:
New.
diff --git a/libstdc++-v3/include/experimental/bits/string_view.tcc b/libstdc++-v3/include/experimental/bits/string_view.tcc
index e66932d1ac0..450a43c7876 100644
--- a/libstdc++-v3/include/experimental/bits/string_view.tcc
+++ b/libstdc++-v3/include/experimental/bits/string_view.tcc
@@ -49,7 +49,7 @@ namespace experimental
inline namespace fundamentals_v1
{
template
-typename basic_string_view<_CharT, _Traits>::size_type
+constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find(const _CharT* __str, size_type __pos, size_type __n) const noexcept
{
@@ -70,7 +70,7 @@ inline namespace fundamentals_v1
}
template
-typename basic_string_view<_CharT, _Traits>::size_type
+constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find(_CharT __c, size_type __pos) const noexcept
{
@@ -86,7 +86,7 @@ inline namespace fundamentals_v1
}
template
-typename basic_string_view<_CharT, _Traits>::size_type
+constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept
{
@@ -106,7 +106,7 @@ inline namespace fundamentals_v1
}
template
-typename basic_string_view<_CharT, _Traits>::size_type
+constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
rfind(_CharT __c, size_type __pos) const noexcept
{
@@ -123,7 +123,7 @@ inline namespace fundamentals_v1
}
template
-typename basic_string_view<_CharT, _Traits>::size_type
+constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_first_of(const _CharT* __str, size_type __pos, size_type __n) const
{
@@ -139,7 +139,7 @@ inline namespace fundamentals_v1
}
template
-typename basic_string_view<_CharT, _Traits>::size_type
+constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_last_of(const _CharT* __str, size_type __pos, size_type __n) const
{
@@ -160,7 +160,7 @@ inline namespace fundamentals_v1
}
template
-typename basic_string_view<_CharT, _Traits>::size_type
+constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_first_not_of(const _CharT* __str, size_type __pos, size_type __n) const
{
@@ -172,7 +172,7 @@ inline namespace fundamentals_v1
}
template
-typename basic_string_view<_CharT, _Traits>::size_type
+constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_first_not_of(_CharT __c, size_type __pos) const noexcept
{
@@ -183,7 +183,7 @@ inline namespace fundamentals_v1
}
template
-typename basic_string_view<_CharT, _Traits>::size_type
+constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_last_not_of(const _CharT* __str, size_type __pos, size_type __n) const
{
@@ -204,7 +204,7 @@ inline namespace fundamentals_v1
}
template
-typename basic_string_view<_CharT, _Traits>::size_type
+constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_last_not_of(_CharT __c, size_type __pos) const noexcept
{
diff