Add substr() method. It looks correct to me. Fingers crossed!
This commit is contained in:
parent
f70899aed1
commit
4f54739ab6
1 changed files with 7 additions and 0 deletions
|
@ -48,6 +48,7 @@ namespace dhandy {
|
|||
constexpr string<S + S2 - 1, Ch> operator+ ( const string<S2, Ch>& parOther ) const;
|
||||
constexpr value_type operator[] ( std::size_t parIndex ) const;
|
||||
constexpr bool operator== (const string<S, Ch>& other) const;
|
||||
template <std::size_t Start, std::size_t Len=S-1> constexpr auto substr() const;
|
||||
template <std::size_t S2> constexpr bool operator== (const string<S2, Ch>&) const { return false; }
|
||||
|
||||
template <typename... Args>
|
||||
|
@ -122,6 +123,12 @@ namespace dhandy {
|
|||
constexpr bool string<S, Ch>::operator== (const string<S, Ch>& other) const {
|
||||
return implem::eq(*this, other);
|
||||
}
|
||||
|
||||
template <std::size_t S, typename Ch>
|
||||
template <std::size_t Start, std::size_t Len>
|
||||
constexpr auto string<S, Ch>::substr() const {
|
||||
return string<std::min(S - 1 - std::min(Start, S - 1), Len) + 1, Ch>(m_data + std::min(Start, S - 1)) + make_string("");
|
||||
}
|
||||
} //namespace bt
|
||||
} //namespace dhandy
|
||||
|
||||
|
|
Loading…
Reference in a new issue