4#ifndef FTXUI_UTIL_REF_HPP
5#define FTXUI_UTIL_REF_HPP
32 std::variant<T, const T*> variant_ = T{};
34 const T* Address()
const {
35 return std::holds_alternative<T>(variant_) ? &std::get<T>(variant_)
36 : std::get<const T*>(variant_);
47 Ref(T t) : variant_(std::move(t)) {}
48 Ref(T* t) : variant_(t) {}
62 std::variant<T, T*> variant_ = T{};
64 const T* Address()
const {
65 return std::holds_alternative<T>(variant_) ? &std::get<T>(variant_)
66 : std::get<T*>(variant_);
69 return std::holds_alternative<T>(variant_) ? &std::get<T>(variant_)
70 : std::get<T*>(variant_);
111 return ref_wide_->size();
127 const std::vector<std::string>* ref_ =
nullptr;
128 const std::vector<std::wstring>* ref_wide_ =
nullptr;
An adapter. Own or reference an immutable object.
ConstRef(const ConstRef< T > &)=default
const T & operator*() const
ConstRef(ConstRef< T > &&)=default
ConstRef< T > & operator=(const ConstRef< T > &)=default
const T * operator->() const
const T & operator()() const
An adapter. Reference a list of strings.
ConstStringListRef()=default
ConstStringListRef(const std::vector< std::wstring > *ref)
ConstStringListRef(const std::vector< std::string > *ref)
ConstStringListRef & operator=(const ConstStringListRef &other)=default
ConstStringListRef(const ConstStringListRef &other)=default
std::string operator[](size_t i) const
An adapter. Own or reference a constant string. For convenience, this class convert multiple immutabl...
ConstStringRef(const char *ref)
ConstStringRef(const std::wstring ref)
ConstStringRef(const std::wstring *ref)
ConstStringRef(const wchar_t *ref)
An adapter. Own or reference an mutable object.
Ref< T > & operator=(const Ref< T > &)=default
const T & operator*() const
const T * operator->() const
Ref(const Ref< T > &)=default
const T & operator()() const
An adapter. Own or reference a constant string. For convenience, this class convert multiple mutable ...
StringRef(const char *ref)
StringRef(const wchar_t *ref)
std::string to_string(const std::wstring &s)
Convert a UTF8 std::string into a std::wstring.