Suppose I want to perform a number of actions on the "before" string he enters Binary.
My main problem is literal string, I try to perform actions and save the resulting string and then perform other actions on the resulting string.
I've created this mini-code:
template <char one_char>
struct deal_with_one_char
{
enum { my_val = one_char ^ 0x55};
};
template <char ... Chars>
struct deal_with_milty_char
{
static const char My_string[sizeof...(Chars)+1];
};
template <char ... Chars>
char const deal_with_milty_char< Chars ...>::My_string[sizeof...(Chars)+1] = { deal_with_one_char<Chars>::my_val ...};
int main()
{
cout << deal_with_milty_char<'H', 'B', 'R'>::My_string << std::endl;
return 0;
}
And it works, of course, because it inhabits a global array while compiling and everything is good. The question is how do I bridge the existing gap and insert a regular string and convert it into a series of characters so that it can use the functions.
An example illustrating what I'm trying to do:
#define CompleteStr(str) (do something to converrt str to deal_with_milty_char<'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'>::My_string)
int main()
{
cout << CompleteStr("hello world")::My_string << std::endl;
return 0;
}
Of course everything must be done during compiling.
Conceptually, I try to make the templet relate to my string as a sequence of bytes with separation rather than as one string. The problem is that it is not so clear to me how to do it ...