Support string+ary and ary.to<T>()
This commit is contained in:
parent
7e88e9ee8e
commit
9ad3cc317c
1 changed files with 13 additions and 1 deletions
|
@ -45,9 +45,13 @@ namespace dhandy {
|
|||
constexpr const T* data() const { return m_data.data() + m_curr + 1; }
|
||||
constexpr iterator begin() { return m_data.begin() + m_curr + 1; }
|
||||
constexpr iterator end() { return m_data.end(); }
|
||||
constexpr const T& back() const { return *(m_data.data() + S - 1); }
|
||||
|
||||
template <typename V>
|
||||
constexpr V to() const { return V(data(), size() - (not empty() and not back() ? 1 : 0)); }
|
||||
|
||||
#if !defined(INT_CONV_WITHOUT_HELPERS)
|
||||
constexpr std::string_view to_string_view() const { return std::string_view(data(), size() - 1); }
|
||||
constexpr std::string_view to_string_view() const { return to<std::string_view>(); }
|
||||
bool operator== (const std::string_view& other) const { return to_string_view() == other; }
|
||||
bool operator!= (const std::string_view& other) const { return not operator==(other); }
|
||||
bool operator== (const std::string& other) const { return to_string_view() == other; }
|
||||
|
@ -63,10 +67,18 @@ namespace dhandy {
|
|||
|
||||
#if !defined(INT_CONV_WITHOUT_HELPERS)
|
||||
template <typename T, std::size_t S>
|
||||
inline
|
||||
std::basic_ostream<T>& operator<< (std::basic_ostream<T>& stream, const ReversedSizedArray<T, S>& arr) {
|
||||
stream << arr.to_string_view();
|
||||
return stream;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t S>
|
||||
inline
|
||||
std::basic_string<T> operator+ (std::basic_string<T>&& a, const ReversedSizedArray<T, S>& b) {
|
||||
a.insert(a.end(), b.begin(), b.end());
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
} //namespace dhandy
|
||||
|
||||
|
|
Loading…
Reference in a new issue