vendredi 24 juillet 2020

String class constructor accepting list of const char*

In my String class i want to make a ctor which accept variable length of arguments (const char*) like parameter pack with variadic template.

Something like following

class String() 
{
public: 
    
    String(const char*... xList)
    {
         // Internally appending all const char* present in xList and 
         // populating String class char buffer
    } 

};

Any idea how to achieve this? I was under impression that following thing should work... but it is not.

template <const char* ... Args>
String(Args... xList)
{
    
} 

There may be a way by using "va_arg" but i am not interested in that.

Aucun commentaire:

Enregistrer un commentaire