I'm new to C++ and I am have difficulty understanding this code:
template <typename T = unsigned> - What is
T = unsignedmeans? - Does the compiler enforce the
unsignedon the given type?
That's a default template parameter; it is similar to a default function parameter. If you don't put in an argument, it will default to unsigned [int]. So imagine this:
template <typename T = unsigned> struct foo { T one; T two; }; If I declare for example a foo<char>, the resulting structure will have two char members. But the default parameter lets me declare a foo<>, and that structure will have two unsigned int members, because unsigned int is the default.
The template has a default parameter for the type T, in this case unsigned int.
The unsigned is short hand for unsigned int.
For example; in client code if the template was a class template, then an object could be declared with or without explicitly adding a type to the declaration;
ABC<> abc1; // the <> is required ABC<unsigned int> abc2; // equivalent type to abc1 ABC<float> abc3;
3. List item– what? BTW,unsignedis a synonym forunsigned intin this context (and many others).