|
constexpr | string_impl () noexcept |
| Default constructor. Initializes an empty string.
|
template<std::size_t N> |
constexpr | string_impl (const char(&str)[N]) noexcept |
| Constructs from a string literal.
|
constexpr | string_impl (const std::size_t &n, char c) noexcept |
| Fills the buffer with a repeated character.
|
constexpr | string_impl (std::string_view sv) noexcept |
| Constructs from a std::string_view. Copies up to BufferCapacity characters.
|
template<typename _Iter> |
constexpr | string_impl (_Iter start, _Iter end) noexcept |
| Constructs from an iterator range. Copies until 'end' or until BufferCapacity is reached.
|
constexpr | string_impl (const string_impl &) noexcept=default |
constexpr | string_impl (string_impl &&) noexcept=default |
constexpr string_impl & | operator= (const string_impl &) noexcept=default |
constexpr string_impl & | operator= (string_impl &&) noexcept=default |
constexpr auto | size () const noexcept -> size_type |
constexpr auto | capacity () const noexcept -> size_type |
constexpr auto | empty () const noexcept -> bool |
constexpr auto | data () noexcept -> pointer |
constexpr auto | data () const noexcept -> const_pointer |
constexpr auto | c_str () const noexcept -> const_pointer |
constexpr auto | view () const noexcept -> view_type |
auto | str () const -> std::string |
constexpr auto | operator[] (size_type i) noexcept -> reference |
| Accesses a character by index (mutable).
|
constexpr auto | operator[] (size_type i) const noexcept -> const_reference |
| Accesses a character by index (const).
|
constexpr auto | begin () noexcept -> iterator |
constexpr auto | begin () const noexcept -> const_iterator |
constexpr auto | cbegin () const noexcept -> const_iterator |
constexpr auto | end () noexcept -> iterator |
constexpr auto | end () const noexcept -> const_iterator |
constexpr auto | cend () const noexcept -> const_iterator |
constexpr auto | rbegin () noexcept -> reverse_iterator |
constexpr auto | rbegin () const noexcept -> const_reverse_iterator |
constexpr auto | crbegin () const noexcept -> const_reverse_iterator |
constexpr auto | rend () noexcept -> reverse_iterator |
constexpr auto | rend () const noexcept -> const_reverse_iterator |
constexpr auto | crend () const noexcept -> const_reverse_iterator |
template<std::size_t N> |
constexpr auto | set (char c) const noexcept |
| Replaces a character at compile time.
|
template<std::size_t N> |
constexpr auto | append (const char(&str)[N]) const noexcept |
| Appends a C-style string literal.
|
template<std::size_t TargetSize = DynamicExpandCapacity, std::size_t N, std::size_t ExpandCapacity> |
constexpr auto | append (const string_impl< N, ExpandCapacity > &other) const noexcept |
| Appends another hybrid string.
|
template<std::size_t TargetSize = DynamicExpandCapacity> |
constexpr auto | append (std::string_view sv) const noexcept |
| Appends a std::string_view.
|
template<std::size_t N = 1> |
constexpr auto | append (char c) const noexcept |
| Appends one or more repeated characters.
|
constexpr auto | push_back (char c) const noexcept |
| Appends a single character.
|
template<std::size_t N> |
constexpr auto | resize (char c=' ') const noexcept |
| Resizes the string to a new compile-time capacity.
|
template<std::size_t N> |
constexpr auto | reserve () const noexcept |
| Ensures compile-time capacity is at least N. If current capacity is smaller, a new string_impl is created.
|
template<std::size_t BufferCapacity = 0, std::size_t DynamicExpandCapacity = HYBSTR_DYNAMIC_EXPAND_CAPACITY>
class hybstr::string_impl< BufferCapacity, DynamicExpandCapacity >
Fixed-capacity string that will expand on demand.
- Template Parameters
-
BufferCapacity | Number of characters stored in the compile-time buffer (excluding the null terminator). |
DynamicExpandCapacity | Size of the dynamic buffer allocated for runtime operations. |
Combines a compile-time buffer for constexpr evaluation with a dynamic buffer for runtime use. 'BufferCapacity' defines how many characters are stored in the fixed buffer, and 'DynamicExpandCapacity' specifies the size of the dynamic region used when handling inputs such as 'std::string_view' or iterator ranges whose lengths cannot be determined at compile time. The dynamic buffer size can also be customized through template arguments.
This class is not intended to be used directly. Prefer using the factory functions:
constexpr std::string_view sv = "abc";
std::string
str =
"Hello world";
auto str() const -> std::string
Definition hybstr.hpp:273
constexpr auto string()
Creates an empty hybrid string.
Definition hybstr.hpp:945
Example:
constexpr auto s1 = std::string_view("Greetings");
std::string s4;
std::cin >> s4;
assert(s5.view() == std::string(s1.begin(), s1.end()) + ", " + s4);