@@ -1,3 +1,8 @@
+2017-08-18 Benjamin Buch <benni.buch@gmail.com>
+
+ * include/std/string_view: Added constexpr as required by the C++17.
+ * include/bits/string_view.tcc: Likewise.
+
2017-08-11 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/81808
@@ -2783,7 +2788,7 @@
2017-01-01 Jakub Jelinek <jakub@redhat.com>
Update copyright years.
-
+
Copyright (C) 2017 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
@@ -45,7 +45,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits>
- 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
{
@@ -66,7 +66,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- 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
{
@@ -82,7 +82,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- 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
{
@@ -102,7 +102,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- 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
{
@@ -119,7 +119,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- 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
{
@@ -135,7 +135,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- 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
{
@@ -156,7 +156,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- 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
{
@@ -168,7 +168,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- 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
{
@@ -179,7 +179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- 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
{
@@ -200,7 +200,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- 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
{
@@ -106,7 +106,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_str{__str}
{ }
- basic_string_view&
+ constexpr basic_string_view&
operator=(const basic_string_view&) noexcept = default;
// [string.view.iterators], iterators
@@ -127,19 +127,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
cend() const noexcept
{ return this->_M_str + this->_M_len; }
- const_reverse_iterator
+ constexpr const_reverse_iterator
rbegin() const noexcept
{ return const_reverse_iterator(this->end()); }
- const_reverse_iterator
+ constexpr const_reverse_iterator
rend() const noexcept
{ return const_reverse_iterator(this->begin()); }
- const_reverse_iterator
+ constexpr const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(this->end()); }
- const_reverse_iterator
+ constexpr const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(this->begin()); }
@@ -208,7 +208,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// [string.view.modifiers], modifiers:
- void
+ constexpr void
remove_prefix(size_type __n)
{
__glibcxx_assert(this->_M_len >= __n);
@@ -216,11 +216,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
this->_M_len -= __n;
}
- void
+ constexpr void
remove_suffix(size_type __n)
{ this->_M_len -= __n; }
- void
+ constexpr void
swap(basic_string_view& __sv) noexcept
{
std::swap(this->_M_len, __sv._M_len);
@@ -261,7 +261,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__pos, this->size()), basic_string_view{});
}
- int
+ constexpr int
compare(basic_string_view __str) const noexcept
{
int __ret = traits_type::compare(this->_M_str, __str._M_str,
@@ -271,24 +271,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __ret;
}
- int
+ constexpr int
compare(size_type __pos1, size_type __n1, basic_string_view __str) const
{ return this->substr(__pos1, __n1).compare(__str); }
- int
+ constexpr int
compare(size_type __pos1, size_type __n1,
basic_string_view __str, size_type __pos2, size_type __n2) const
{ return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2)); }
- int
+ constexpr int
compare(const _CharT* __str) const noexcept
{ return this->compare(basic_string_view{__str}); }
- int
+ constexpr int
compare(size_type __pos1, size_type __n1, const _CharT* __str) const
{ return this->substr(__pos1, __n1).compare(basic_string_view{__str}); }
- int
+ constexpr int
compare(size_type __pos1, size_type __n1,
const _CharT* __str, size_type __n2) const
{
@@ -296,97 +296,97 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
.compare(basic_string_view(__str, __n2));
}
- size_type
+ constexpr size_type
find(basic_string_view __str, size_type __pos = 0) const noexcept
{ return this->find(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find(_CharT __c, size_type __pos=0) const noexcept;
- size_type
+ constexpr size_type
find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
- size_type
+ constexpr size_type
find(const _CharT* __str, size_type __pos=0) const noexcept
{ return this->find(__str, __pos, traits_type::length(__str)); }
- size_type
+ constexpr size_type
rfind(basic_string_view __str, size_type __pos = npos) const noexcept
{ return this->rfind(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
rfind(_CharT __c, size_type __pos = npos) const noexcept;
- size_type
+ constexpr size_type
rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
- size_type
+ constexpr size_type
rfind(const _CharT* __str, size_type __pos = npos) const noexcept
{ return this->rfind(__str, __pos, traits_type::length(__str)); }
- size_type
+ constexpr size_type
find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept
{ return this->find_first_of(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find_first_of(_CharT __c, size_type __pos = 0) const noexcept
{ return this->find(__c, __pos); }
- size_type
+ constexpr size_type
find_first_of(const _CharT* __str, size_type __pos, size_type __n) const;
- size_type
+ constexpr size_type
find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept
{ return this->find_first_of(__str, __pos, traits_type::length(__str)); }
- size_type
+ constexpr size_type
find_last_of(basic_string_view __str,
size_type __pos = npos) const noexcept
{ return this->find_last_of(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find_last_of(_CharT __c, size_type __pos=npos) const noexcept
{ return this->rfind(__c, __pos); }
- size_type
+ constexpr size_type
find_last_of(const _CharT* __str, size_type __pos, size_type __n) const;
- size_type
+ constexpr size_type
find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept
{ return this->find_last_of(__str, __pos, traits_type::length(__str)); }
- size_type
+ constexpr size_type
find_first_not_of(basic_string_view __str,
size_type __pos = 0) const noexcept
{ return this->find_first_not_of(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept;
- size_type
+ constexpr size_type
find_first_not_of(const _CharT* __str,
size_type __pos, size_type __n) const;
- size_type
+ constexpr size_type
find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept
{
return this->find_first_not_of(__str, __pos,
traits_type::length(__str));
}
- size_type
+ constexpr size_type
find_last_not_of(basic_string_view __str,
size_type __pos = npos) const noexcept
{ return this->find_last_not_of(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept;
- size_type
+ constexpr size_type
find_last_not_of(const _CharT* __str,
size_type __pos, size_type __n) const;
- size_type
+ constexpr size_type
find_last_not_of(const _CharT* __str,
size_type __pos = npos) const noexcept
{
@@ -411,7 +411,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const bool __testoff = __off < this->size() - __pos;
return __testoff ? __off : this->size() - __pos;
}
-
+
private:
static constexpr int
@@ -440,109 +440,109 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator==(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator==(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator!=(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return !(__x == __y); }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator!=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return !(__x == __y); }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return !(__x == __y); }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator< (basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator< (basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator> (basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator> (basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator<=(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator<=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator>=(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) >= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator>=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) >= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) >= 0; }