Skip to content

Commit 6819b55

Browse files
committed
Make ComaptStringArray with more function
1 parent 2df4a88 commit 6819b55

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

common/conststr.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,13 @@ struct EnumStr : public Split {
304304
template <typename Accum, typename Whole>
305305
struct CompactStringArray {
306306
constexpr static decltype(auto) whole() { return Whole(); }
307+
constexpr static size_t size() { return Accum::size(); }
307308

308309
constexpr static std::string_view at(size_t i) {
310+
if (i < 0 || i >= size()) return {};
311+
return CompactStringArray<Accum, Whole>()[i];
312+
}
313+
constexpr std::string_view operator[](size_t i) {
309314
return {&Whole::chars[Accum::arr[i] + i],
310315
(size_t)Accum::arr[i + 1] - (size_t)Accum::arr[i]};
311316
}

0 commit comments

Comments
 (0)