di 0.1.0
Loading...
Searching...
No Matches
zstring.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace di::container {
6template<di::concepts::OneOf<char, unsigned char, wchar_t, char const, unsigned char const, wchar_t const, c8, c8 const,
7 c16, c16 const, c32, c32 const>
8 T>
9class ZStringImpl : public di::meta::EnableBorrowedContainer<ZStringImpl<T>> {
10private:
11 struct Iterator : di::container::IteratorExtension<Iterator, T*, T> {
12 private:
14
15 public:
16 Iterator() = default;
17
18 constexpr explicit Iterator(T* base) : Base(base) {}
19
20 constexpr auto operator*() const -> T& { return *this->base(); }
21
22 private:
23 constexpr friend auto operator==(Iterator const& a, di::DefaultSentinel) -> bool { return *a == 0; }
24 };
25
26public:
27 constexpr explicit ZStringImpl(T* data) : m_data(data) {}
28 constexpr explicit ZStringImpl(Iterator data) : m_data(&*data) {}
29
30 constexpr auto data() const -> T* { return m_data; }
31
32 constexpr auto begin() const -> Iterator { return Iterator(m_data); }
33 constexpr auto end() const { return di::default_sentinel; }
34
35private:
36 T* m_data { nullptr };
37};
38
51}
52
53namespace di {
66}
Definition iterator_extension.h:19
constexpr auto base() const &-> Iter const &
Definition iterator_extension.h:30
Definition zstring.h:9
constexpr ZStringImpl(Iterator data)
Definition zstring.h:28
constexpr ZStringImpl(T *data)
Definition zstring.h:27
constexpr auto begin() const -> Iterator
Definition zstring.h:32
constexpr auto end() const
Definition zstring.h:33
constexpr auto data() const -> T *
Definition zstring.h:30
Definition enable_borrowed_container.h:7
Definition sequence.h:12
ZStringImpl< c32 > ZC32String
Definition zstring.h:50
ZStringImpl< char > ZString
Definition zstring.h:42
ZStringImpl< c8 const > ZC8CString
Definition zstring.h:45
ZStringImpl< unsigned char const > ZCUString
Definition zstring.h:40
ZStringImpl< unsigned char > ZUString
Definition zstring.h:43
constexpr auto operator==(MoveIterator< Iter > const &a, MoveIterator< U > const &b) -> bool
Definition move_iterator.h:85
ZStringImpl< char const > ZCString
Definition zstring.h:39
ZStringImpl< c16 const > ZC16CString
Definition zstring.h:47
ZStringImpl< c16 > ZC16String
Definition zstring.h:48
ZStringImpl< wchar_t > ZWString
Definition zstring.h:44
ZStringImpl< c8 > ZC8String
Definition zstring.h:46
ZStringImpl< c32 const > ZC32CString
Definition zstring.h:49
ZStringImpl< wchar_t const > ZCWString
Definition zstring.h:41
char8_t c8
Definition char.h:4
char16_t c16
Definition char.h:5
char32_t c32
Definition char.h:6
Definition any_storable.h:9
constexpr auto default_sentinel
Definition default_sentinel.h:6
Definition default_sentinel.h:4