mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Mark literal string creation as constexpr
* The compiler doesn't seem to do much with this in debug, but it might help in release.
This commit is contained in:
@@ -42,12 +42,12 @@ class rdcliteral
|
||||
size_t len;
|
||||
|
||||
// make the literal operator a friend so it can construct fixed strings. No-one else can.
|
||||
friend rdcliteral operator"" _lit(const char *str, size_t len);
|
||||
friend constexpr rdcliteral operator"" _lit(const char *str, size_t len);
|
||||
|
||||
// similarly friend inflexible strings to allow them to decompose to a literal
|
||||
friend class rdcinflexiblestr;
|
||||
|
||||
rdcliteral(const char *s, size_t l) : str(s), len(l) {}
|
||||
constexpr rdcliteral(const char *s, size_t l) : str(s), len(l) {}
|
||||
rdcliteral() = delete;
|
||||
|
||||
public:
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
const char *end() const { return str + len; }
|
||||
};
|
||||
|
||||
inline rdcliteral operator"" _lit(const char *str, size_t len)
|
||||
inline constexpr rdcliteral operator"" _lit(const char *str, size_t len)
|
||||
{
|
||||
return rdcliteral(str, len);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ rdcstr ToStr(const T &el)
|
||||
#define BEGIN_ENUM_STRINGISE(type) \
|
||||
using enumType = type; \
|
||||
static const char unknown_prefix[] = #type "("; \
|
||||
static rdcliteral empty_ret = STRING_LITERAL(#type "(0)"); \
|
||||
constexpr rdcliteral empty_ret = STRING_LITERAL(#type "(0)"); \
|
||||
static_assert(std::is_same<const type &, decltype(el)>::value, \
|
||||
"Type in macro doesn't match el"); \
|
||||
(void)(enumType) el; \
|
||||
@@ -85,7 +85,7 @@ rdcstr ToStr(const T &el)
|
||||
#define BEGIN_BITFIELD_STRINGISE(type) \
|
||||
using enumType = type; \
|
||||
static const char unknown_prefix[] = " | " #type "("; \
|
||||
static rdcliteral empty_ret = STRING_LITERAL(#type "(0)"); \
|
||||
constexpr rdcliteral empty_ret = STRING_LITERAL(#type "(0)"); \
|
||||
static_assert(std::is_same<const type &, decltype(el)>::value, \
|
||||
"Type in macro doesn't match el"); \
|
||||
uint64_t local = (uint64_t)el; \
|
||||
|
||||
Reference in New Issue
Block a user