16template <
size_t capacity>
18 std::array<std::string::value_type, capacity> data_{};
30 StaticString(std::string
const&
string) : size_(std::min(string.size(), capacity)) {
31 assert(
string.size() <= capacity &&
32 "rsl::StaticString::StaticString: Input exceeds capacity");
33 std::copy(
string.cbegin(),
string.cbegin() + std::string::difference_type(size_),
39 [[nodiscard]]
auto begin()
const {
return data_.cbegin(); }
44 [[nodiscard]]
auto end()
const {
return data_.cbegin() + size_; }
49 operator std::string_view()
const {
return std::string_view(data_.data(), size_); }
55template <
size_t capacity>
57 return std::string(static_string);
Fixed capacity string with an implicit conversion to std::string_view. Capacity is specified as a tem...
Definition static_string.hpp:17
auto end() const
Get a const end iterator.
Definition static_string.hpp:44
StaticString()=default
Construct an empty string.
auto begin() const
Get a const begin iterator.
Definition static_string.hpp:39
StaticString(std::string const &string)
Construct from a std::string.
Definition static_string.hpp:30
auto to_string(StaticString< capacity > const &static_string)
Explicit conversion to std::string.
Definition static_string.hpp:56