Home > Back-end >  Great god please help! The format of a similar to the printf function
Great god please help! The format of a similar to the printf function

Time:02-18

Ruo chrysanthemum and double 叒 叕 to ask for help!
I want to finish such an effect:
 
# include & lt; Bits/stdc++. H>
using namespace std;

The template & lt; String mod, class... Cls>
The class Pack
{
//... The great spirit to write...
};

Pack<" CD (int) : (c), (23) ", int, char, bool> GetBit (int, char, c bool b)
{
Pack<" CD (int) : (c), (23) ", int, char, bool> Rsl_t;
Rsl_t. Setthing (" int ", I);
Rsl_t. Setthing (" c ", c);
Rsl_t. Setthing (23 "CD", b);
Return rsl_t;
}

Pack<" (int) : (c), [NOT (PPT)]; "[LEN (els)], int, char, bool, string> GetByte (int, char, c bool b, string els)
{
Pack<" (int) : (c), [NOT (PPT)]; "[LEN (els)], int, char, bool, string> Rsl_t;
//... A little...
Return rsl_t;
}

Int main ()
{
Cout & lt; Cout & lt; return 0;
}

Desired output:

2021: +, true
2022: : -, false; 9

Pack is a template class, I'm going to use it to realize a format function:
String is first pattern string, followed by the class (fill the type of thing)
Can also be changed to: "(int: its)" : this type name, this wouldn't have the back of the above class, a great god watch that good implementation,

Has two built-in function (added) :
Methods: "... [function name (fill in the item name/item types: goods name (two options, see the good implementation)]. "

In view of the bool type NOT function:
"... [NOT (bool: ygbool)]... "Or"... [NOT (ygbool)]... "

LEN for string functions:
"... [LEN (string: ygstring)]... "Or"... [LEN (ygstring)]... "

Do NOT take the LEN is long

CodePudding user response:

The constructor to use sizeof... (CLS) be able to get the actual number of type parameters, and then consider setting up a few yuan group (a tuple).

CodePudding user response:

Where is the value of this?

CodePudding user response:

Store strings can? Pointers can be I know of,
  • Related