Template integer parameter constructor
c++, templates
Solution
The constructor is taking string literal as an argument. What you see is just a syntax to declare a template for this.
With such constructor m_size can be found in O(1) opposed to O(strlen(str)) required otherwise with a non-template constructor taking `char const*` as an argument.
A thing to remember of is for each string length there will be an instance of template generated by compiler so you may end up having quite a few instantiations of this template in your library/binary/object files.
Problem
I don't understand the following constructor (part of Qt library in src\corelib\tools\qstringbuilder.h), what does it mean and how does it work? ``` class QLatin1Literal { public: int size() const { return m_size; } const char *data() const { return m_data; } template <int N> QLatin1Literal(const char (&str)[N]) : m_size(N - 1), m_data(str) {} private: const int m_size; const char * const m_data; }; ```