File tree Expand file tree Collapse file tree 5 files changed +62
-1
lines changed
Expand file tree Collapse file tree 5 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -258,7 +258,8 @@ namespace hud
258258 return ptr_[i];
259259 }
260260
261- private:
261+ [[nodiscard]]
262+ constexpr bool is_valid_c private :
262263 /* *Pointer to the null-terminated C-style string. */
263264 char_type *ptr_;
264265 };
Original file line number Diff line number Diff line change 11#ifndef HD_INC_CORE_STRING_STRING_H
22#define HD_INC_CORE_STRING_STRING_H
3+ #include " ../containers/vector.h"
34
45namespace hud
56{
67 class string
78 {
9+ constexpr string () noexcept = default;
10+ constexpr string (const string &) noexcept = default;
11+ constexpr string (string &&) noexcept = default;
12+ constexpr string &operator =(const string &) noexcept = default ;
13+ constexpr string &operator =(string &&) noexcept = default ;
14+
815 private:
16+ hud::vector<char8> data_;
917 };
1018} // namespace hud
1119
Original file line number Diff line number Diff line change 1+ #ifndef HD_INC_CORE_STRING_STRING_VIEW_H
2+ #define HD_INC_CORE_STRING_STRING_VIEW_H
3+
4+ namespace hud
5+ {
6+ /* *
7+ * Valid UTF-8 string view
8+ */
9+ template <typename char_t >
10+ struct cstring_view
11+ {
12+
13+ private:
14+ /* * An UTF-8 valid string view. */
15+ char8 *ptr_;
16+ usize len;
17+ };
18+
19+ } // namespace hud
20+
21+ #endif // HD_INC_CORE_STRING_STRING_VIEW_H
Original file line number Diff line number Diff line change 1+ #include < core/string/cstring_view.h>
Original file line number Diff line number Diff line change 1+
2+ #include < core/string.h>
3+
4+ GTEST_TEST (string, default_constructor_should_allocate_no_memory)
5+ {
6+ auto test = []() -> std::tuple<bool , usize, usize> {
7+ hud::string s;
8+ return std::tuple {
9+ s.data () == nullptr ,
10+ s.count () == 0u ,
11+ s.max_count () == 0u
12+ };
13+ };
14+
15+ // Non Constant
16+ {
17+ auto result = test ();
18+ hud_assert_true (std::get<0 >(result));
19+ hud_assert_eq (std::get<1 >(result), 0u );
20+ hud_assert_eq (std::get<2 >(result), 0u );
21+ }
22+
23+ // Constant
24+ {
25+ constexpr auto result = test ();
26+ hud_assert_true (std::get<0 >(result));
27+ hud_assert_eq (std::get<1 >(result), 0u );
28+ hud_assert_eq (std::get<2 >(result), 0u );
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments