Update C++ version of wapp_str8_node_from_str8
This commit is contained in:
@@ -119,12 +119,25 @@ Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8R
|
||||
/**
|
||||
* Str8 list utilities
|
||||
*/
|
||||
u64 wapp_str8_list_total_size(const Str8List *list);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
template <typename T>
|
||||
constexpr bool is_lvalue(T&&) {
|
||||
return std::is_lvalue_reference<T>{};
|
||||
}
|
||||
|
||||
#define wapp_str8_node_from_cstr(STRING) wapp_dbl_list_node(Str8, Str8Node, [&]() { \
|
||||
wapp_persist Str8 str = wapp_str8_lit(STRING); \
|
||||
return &str; \
|
||||
}())
|
||||
#define wapp_str8_node_from_str8(STRING) wapp_dbl_list_node(Str8, Str8Node, [&]() { \
|
||||
if (is_lvalue(STRING)) { return &STRING; } \
|
||||
\
|
||||
wapp_persist Str8 str = STRING; \
|
||||
return &str; \
|
||||
}())
|
||||
@@ -132,10 +145,5 @@ Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8R
|
||||
#define wapp_str8_node_from_cstr(STRING) wapp_dbl_list_node(Str8, Str8Node, &wapp_str8_lit(STRING))
|
||||
#define wapp_str8_node_from_str8(STRING) wapp_dbl_list_node(Str8, Str8Node, &(STRING))
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
u64 wapp_str8_list_total_size(const Str8List *list);
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
#endif // !STR8_H
|
||||
|
||||
Reference in New Issue
Block a user