string_holder class
#include <gtopt/as_label.hpp>
String holder that avoids heap allocation for integral and string_view arguments. Integer values are formatted into a small stack buffer. Only the std::format fallback path allocates on the heap.
Uses a tag to track which storage is active, computing the view on demand in view(). This avoids self-referential pointers that would break on move/copy.
Constructors, destructors, conversion operators
- string_holder(char c) explicit constexpr noexcept
- string_holder(const std::string& s) explicit constexpr noexcept
-
template<typename T>string_holder(const T& value) explicit
-
template<typename T>string_holder(const T& value) explicit noexcept
- string_holder(std::string&& s) explicit noexcept
-
template<typename T>string_holder(T&& range) explicit
-
template<string_like T>string_holder(T&& value) explicit constexpr noexcept
-
template<typename T>string_holder(T value) explicit noexcept
Public functions
- auto view() const -> std::string_view noexcept