Skip to content

Commit

Permalink
Fix C++14 constexpr use.
Browse files Browse the repository at this point in the history
  • Loading branch information
grafikrobot committed Aug 5, 2023
1 parent c25aadd commit ff624ab
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/engine/strview.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ template<> struct sv_to_uchar<char>
# pragma GCC diagnostic ignored "-Wtype-limits"
#endif

template<class Ch> constexpr std::size_t find_first_of( Ch const* p_, std::size_t n_, Ch const* s, std::size_t pos, std::size_t n ) noexcept
template<class Ch> std::size_t find_first_of( Ch const* p_, std::size_t n_, Ch const* s, std::size_t pos, std::size_t n ) noexcept
{
typedef typename sv_to_uchar<Ch>::type UCh;

Expand Down Expand Up @@ -104,7 +104,7 @@ template<class Ch> constexpr std::size_t find_first_of( Ch const* p_, std::size_
return static_cast<std::size_t>( -1 );
}

template<class Ch> constexpr std::size_t find_last_of( Ch const* p_, Ch const* s, std::size_t pos, std::size_t n ) noexcept
template<class Ch> std::size_t find_last_of( Ch const* p_, Ch const* s, std::size_t pos, std::size_t n ) noexcept
{
typedef typename sv_to_uchar<Ch>::type UCh;

Expand Down Expand Up @@ -174,7 +174,7 @@ template<class Ch> constexpr std::size_t find_last_of( Ch const* p_, Ch const* s
return npos;
}

template<class Ch> constexpr std::size_t find_first_not_of( Ch const* p_, std::size_t n_, Ch const* s, std::size_t pos, std::size_t n ) noexcept
template<class Ch> std::size_t find_first_not_of( Ch const* p_, std::size_t n_, Ch const* s, std::size_t pos, std::size_t n ) noexcept
{
typedef typename sv_to_uchar<Ch>::type UCh;

Expand Down Expand Up @@ -237,7 +237,7 @@ template<class Ch> constexpr std::size_t find_first_not_of( Ch const* p_, std::s
return static_cast<std::size_t>( -1 );
}

template<class Ch> constexpr std::size_t find_last_not_of( Ch const* p_, Ch const* s, std::size_t pos, std::size_t n ) noexcept
template<class Ch> std::size_t find_last_not_of( Ch const* p_, Ch const* s, std::size_t pos, std::size_t n ) noexcept
{
typedef typename sv_to_uchar<Ch>::type UCh;

Expand Down Expand Up @@ -451,13 +451,13 @@ template<class Ch> class basic_string_view

// element access

constexpr const_reference operator[]( size_type pos ) const noexcept
const_reference operator[]( size_type pos ) const noexcept
{
assert( pos < size() );
return p_[ pos ];
}

constexpr const_reference at( size_type pos ) const
const_reference at( size_type pos ) const
{
if( pos >= size() )
{
Expand All @@ -467,13 +467,13 @@ template<class Ch> class basic_string_view
return p_[ pos ];
}

constexpr const_reference front() const noexcept
const_reference front() const noexcept
{
assert( !empty() );
return p_[ 0 ];
}

constexpr const_reference back() const noexcept
const_reference back() const noexcept
{
assert( !empty() );
return p_[ n_ - 1 ];
Expand All @@ -486,30 +486,30 @@ template<class Ch> class basic_string_view

// modifiers

constexpr void remove_prefix( size_type n ) noexcept
void remove_prefix( size_type n ) noexcept
{
assert( n <= size() );

p_ += n;
n_ -= n;
}

constexpr void remove_suffix( size_type n ) noexcept
void remove_suffix( size_type n ) noexcept
{
assert( n <= size() );

n_ -= n;
}

constexpr void swap( basic_string_view& s ) noexcept
void swap( basic_string_view& s ) noexcept
{
std::swap( p_, s.p_ );
std::swap( n_, s.n_ );
}

// string operations

constexpr size_type copy( Ch* s, size_type n, size_type pos = 0 ) const
size_type copy( Ch* s, size_type n, size_type pos = 0 ) const
{
if( pos > size() )
{
Expand All @@ -523,7 +523,7 @@ template<class Ch> class basic_string_view
return rlen;
}

constexpr basic_string_view substr( size_type pos = 0, size_type n = npos ) const
basic_string_view substr( size_type pos = 0, size_type n = npos ) const
{
if( pos > size() )
{
Expand All @@ -537,7 +537,7 @@ template<class Ch> class basic_string_view

// compare

constexpr int compare( basic_string_view str ) const noexcept
int compare( basic_string_view str ) const noexcept
{
std::size_t rlen = (std::min)( size(), str.size() );

Expand Down Expand Up @@ -616,7 +616,7 @@ template<class Ch> class basic_string_view
return find( str.data(), pos, str.size() );
}

constexpr size_type find( Ch c, size_type pos = 0 ) const noexcept
size_type find( Ch c, size_type pos = 0 ) const noexcept
{
if( pos >= size() ) return npos;

Expand All @@ -625,7 +625,7 @@ template<class Ch> class basic_string_view
return r? r - data(): npos;
}

constexpr size_type find( Ch const* s, size_type pos, size_type n ) const noexcept
size_type find( Ch const* s, size_type pos, size_type n ) const noexcept
{
if( n == 1 ) return find( s[0], pos );

Expand Down Expand Up @@ -661,7 +661,7 @@ template<class Ch> class basic_string_view
return rfind( str.data(), pos, str.size() );
}

constexpr size_type rfind( Ch c, size_type pos = npos ) const noexcept
size_type rfind( Ch c, size_type pos = npos ) const noexcept
{
size_type n = size();

Expand All @@ -685,7 +685,7 @@ template<class Ch> class basic_string_view
return npos;
}

constexpr size_type rfind( Ch const* s, size_type pos, size_type n ) const noexcept
size_type rfind( Ch const* s, size_type pos, size_type n ) const noexcept
{
if( n > size() ) return npos;

Expand Down Expand Up @@ -727,7 +727,7 @@ template<class Ch> class basic_string_view
return find( c, pos );
}

constexpr size_type find_first_of( Ch const* s, size_type pos, size_type n ) const noexcept
size_type find_first_of( Ch const* s, size_type pos, size_type n ) const noexcept
{
if( n == 0 || pos >= size() ) return npos;
if( n == 1 ) return find( s[0], pos );
Expand All @@ -752,7 +752,7 @@ template<class Ch> class basic_string_view
return rfind( c, pos );
}

constexpr size_type find_last_of( Ch const* s, size_type pos, size_type n ) const noexcept
size_type find_last_of( Ch const* s, size_type pos, size_type n ) const noexcept
{
if( n == 1 )
{
Expand Down Expand Up @@ -786,7 +786,7 @@ template<class Ch> class basic_string_view
return find_first_not_of( str.data(), pos, str.size() );
}

constexpr size_type find_first_not_of( Ch c, size_type pos = 0 ) const noexcept
size_type find_first_not_of( Ch c, size_type pos = 0 ) const noexcept
{
for( std::size_t i = pos; i < n_; ++i )
{
Expand All @@ -796,7 +796,7 @@ template<class Ch> class basic_string_view
return npos;
}

constexpr size_type find_first_not_of( Ch const* s, size_type pos, size_type n ) const noexcept
size_type find_first_not_of( Ch const* s, size_type pos, size_type n ) const noexcept
{
if( pos >= size() ) return npos;
if( n == 1 ) return find_first_not_of( s[0], pos );
Expand All @@ -816,7 +816,7 @@ template<class Ch> class basic_string_view
return find_last_not_of( str.data(), pos, str.size() );
}

constexpr size_type find_last_not_of( Ch c, size_type pos = npos ) const noexcept
size_type find_last_not_of( Ch c, size_type pos = npos ) const noexcept
{
size_type m = size();

Expand All @@ -840,7 +840,7 @@ template<class Ch> class basic_string_view
return npos;
}

constexpr size_type find_last_not_of( Ch const* s, size_type pos, size_type n ) const noexcept
size_type find_last_not_of( Ch const* s, size_type pos, size_type n ) const noexcept
{
if( n == 1 )
{
Expand Down Expand Up @@ -874,7 +874,7 @@ template<class Ch> class basic_string_view
return find( sv ) != npos;
}

constexpr bool contains( Ch c ) const noexcept
bool contains( Ch c ) const noexcept
{
Ch const* p = data();
size_type n = size();
Expand Down

0 comments on commit ff624ab

Please sign in to comment.