hybstr
Hybrid constexpr string library for compile-time and runtime use
Loading...
Searching...
No Matches
hybstr.hpp File Reference

Hybrid string implementation that can be used in both compile time and runtime. More...

Go to the source code of this file.

Classes

class  hybstr::string_impl< BufferCapacity, DynamicExpandCapacity >
 Fixed-capacity string that will expand on demand. More...
struct  hybstr::is_string_impl< T >
 Type trait for detecting hybstr::string_impl. More...
struct  hybstr::is_string_impl< string_impl< BufferCapacity, DynamicExpandCapacity > >

Namespaces

namespace  hybstr
 Main interface.
namespace  hybstr::literals
 Contains user defined literal operators for creating 'hybstr::string_impl' objects.

Functions

template<std::size_t DynamicExpandCapacity = HYBSTR_DYNAMIC_EXPAND_CAPACITY>
constexpr auto hybstr::string ()
 Creates an empty hybrid string.
template<std::size_t DynamicExpandCapacity = HYBSTR_DYNAMIC_EXPAND_CAPACITY, std::size_t N>
constexpr auto hybstr::string (const char(&str)[N])
 Creates a hybrid string from a string literal.
template<std::size_t ViewSize = HYBSTR_DYNAMIC_EXPAND_CAPACITY, std::size_t DynamicExpandCapacity = HYBSTR_DYNAMIC_EXPAND_CAPACITY>
constexpr auto hybstr::string (std::string_view sv) noexcept
 Creates a hybrid string from a std::string_view.
template<std::size_t RangeSize = HYBSTR_DYNAMIC_EXPAND_CAPACITY, std::size_t DynamicExpandCapacity = HYBSTR_DYNAMIC_EXPAND_CAPACITY, typename _Iter>
constexpr auto hybstr::string (_Iter start, _Iter end) noexcept
 Creates a hybrid string from an iterator range.
template<std::size_t N>
 hybstr::string_impl (const char(&)[N]) -> string_impl< N >
template<std::size_t B1, std::size_t DynamicExpandCapacity1, std::size_t B2, std::size_t DynamicExpandCapacity2>
constexpr auto hybstr::operator+ (const string_impl< B1, DynamicExpandCapacity1 > &s1, const string_impl< B2, DynamicExpandCapacity2 > &s2) noexcept
 Concatenates two hybrid strings.
template<std::size_t BufferCapacity, std::size_t DynamicExpandCapacity, std::size_t N>
constexpr auto hybstr::operator+ (const string_impl< BufferCapacity, DynamicExpandCapacity > &s, const char(&str)[N]) noexcept
 Concatenates a hybrid string with a C-style string literal.
template<std::size_t BufferCapacity, std::size_t DynamicExpandCapacity, std::size_t N>
constexpr auto hybstr::operator+ (const char(&str)[N], const string_impl< BufferCapacity, DynamicExpandCapacity > &s) noexcept
 Concatenates a C-style string literal with a hybrid string.
template<std::size_t BufferCapacity, std::size_t DynamicExpandCapacity>
constexpr auto hybstr::operator+ (const string_impl< BufferCapacity, DynamicExpandCapacity > &s, char c) noexcept
 Concatenates a hybrid string with a char.
template<std::size_t BufferCapacity, std::size_t DynamicExpandCapacity>
constexpr auto hybstr::operator+ (char c, const string_impl< BufferCapacity, DynamicExpandCapacity > &s) noexcept
 Concatenates a hybrid string with a char.
template<std::size_t BufferCapacity, std::size_t DynamicExpandCapacity>
constexpr auto hybstr::operator+ (const string_impl< BufferCapacity, DynamicExpandCapacity > &s, std::string_view sv) noexcept
 Concatenates a hybrid string with a std::string_view.
template<std::size_t BufferCapacity, std::size_t DynamicExpandCapacity>
constexpr auto hybstr::operator+ (std::string_view sv, const string_impl< BufferCapacity, DynamicExpandCapacity > &s) noexcept
 Concatenates a std::string_view with a hybrid string.
template<std::size_t B1, std::size_t D1, std::size_t B2, std::size_t D2>
constexpr bool hybstr::operator== (const string_impl< B1, D1 > &s1, const string_impl< B2, D2 > &s2) noexcept
 Equality comparison for two hybrid strings.
template<std::size_t B1, std::size_t D1, std::size_t B2, std::size_t D2>
constexpr bool hybstr::operator!= (const string_impl< B1, D1 > &s1, const string_impl< B2, D2 > &s2) noexcept
 Inequality comparison for two hybrid strings.
template<std::size_t B1, std::size_t D1, std::size_t B2, std::size_t D2>
constexpr auto hybstr::operator<=> (const string_impl< B1, D1 > &s1, const string_impl< B2, D2 > &s2) noexcept
 Lexicographical three-way comparison for hybrid strings. C++20 or above.
template<std::size_t B1, std::size_t D1, std::size_t B2, std::size_t D2>
constexpr bool hybstr::operator< (const string_impl< B1, D1 > &s1, const string_impl< B2, D2 > &s2) noexcept
 Less than comparison for two hybrid strings. C++17.
template<std::size_t B1, std::size_t D1, std::size_t B2, std::size_t D2>
constexpr bool hybstr::operator<= (const string_impl< B1, D1 > &s1, const string_impl< B2, D2 > &s2) noexcept
 Less than or equal to comparison for two hybrid strings.
template<std::size_t B1, std::size_t D1, std::size_t B2, std::size_t D2>
constexpr bool hybstr::operator> (const string_impl< B1, D1 > &s1, const string_impl< B2, D2 > &s2) noexcept
 Greater than comparison for two hybrid strings.
template<std::size_t B1, std::size_t D1, std::size_t B2, std::size_t D2>
constexpr bool hybstr::operator>= (const string_impl< B1, D1 > &s1, const string_impl< B2, D2 > &s2) noexcept
 Greater than or equal to comparison for two hybrid strings.
template<auto str>
consteval auto hybstr::fit_string () noexcept
 Adjusts the compile-time buffer size to exactly fit the string content. C++20 or above.
template<hybstr::string_impl str>
consteval auto hybstr::literals::operator""_hyb () noexcept
 User-defined literal for creating a 'hybstr::string_impl'. C++20 or above.
consteval auto hybstr::literals::operator""_hyb (const char *str, std::size_t len) noexcept
 User-defined literal for creating a 'hybstr::string_impl'. C++17.

Variables

template<typename T>
constexpr bool hybstr::is_string_impl_v = is_string_impl<T>::value
 Shorthand boolean variable for is_string_impl.

Detailed Description

Hybrid string implementation that can be used in both compile time and runtime.

This header defines a hybrid constexpr string type that supports operations in both compile-time and runtime environments. It is primarily designed for constexpr metaprogramming and string literal manipulation, so runtime functionality will be limited.

Note
Requires C++17 or later - C++20 is recommended, with C++17 is supported with limited constexpr metaprogramming
Author
404hasfound (GitHub: 4o4hasfound)
Date
2025-10-05
Version
1.0 @cpp C++20+