last day (14 days later) » 

14:20
1
A: Compile time encryption for strings using user-defined literals

black Is it even possible what I'm trying to attempt? Yes, it is possible. What you can pre-compute and put directly in the source code can also be done by the compiler at compile time. However, you cannot use std::string. It's not a literal type. Something like: constexpr std::string tmp = "s...

how would you manipulate the char array in a constexpr function?
@m.s. You can copy it. Whether you want to do it is another question...
but you can't allocate memory in a constexpr function, I am really curious how that would work
@m.s. You can't allocate dynamic memory, but you can use automatic arrays.
what is an automatic array?
14:20
@m.s I meant an array with automatic storage duration. Like char s[N].
but you don't get the size of the character array as a compile time constant
@m.s What do you mean? Just template <size_t N> constexpr auto(const char (&s)[N]) , where N is the length.
what I meant is that you do not get the length of the character array as a compile time constant when implementing a user defined literal
since len is not a compile time constant, you cannot define a char s[len]
sorry I don't understand
14:26
I'll give you that I was mainly referring to constexpr functions and structs
which you generally use for meta-programming
and not specifically to operator"" you typically use for UDLs
but the question explicitly was about "user defined literals"
that's true but it doesn't change much, does it? It's still meta-programming...
I still don't see a way how you could manipulate a character array using a user defined literal
which you have to implement using operator""
therefore your "Yes, it is possible." might be be wrong
uhmm
I think I see what you mean
so you can't basically take string literals in UDLs as const char []
is that what you meant to say?
the lack of the size parameter as a constant expression
yes
exactly
14:41
couldn't you get to the point directly in the first comment :D ? I've wondered for a while why you were saying that
sorry :)
ok thanks!
I said "it is possible" because you actually can with "normal" non-type template parameters that gives you the size
I'm gonna fix and see what can be done
have a nice day

last day (14 days later) »