I want to implement my own string-literal class Literal
and operator:
constexpr Literal operator""_s(const char* str, size_t size);
class Literal {
friend constexpr Literal operator"" _s(const char*, size_t);
constexpr Literal(const char* str, size_t size);
const char* str = nullptr;
const size_t size = 0u;
};
Then I want to place an empty literal inside my class:
class Literal {
…
static constexpr const Literal empty = ""_s;
…
};
As expected compiler refuses such construction because class is incomplete at this point. Also I suggest that it's technically should be possible, since the compiler just needs to put somewhere the pair of char* str = nullptr
and size_t size = 0
for the empty
literal and assign it at compile-time to the static instance of my class.
Is there some "trick" to achieve the clause like: auto new_literal = Literal::empty;
?