c++ - What is this template syntax and unsigned type? -


i'm new c++ , have difficulty understanding code:

template <typename t = unsigned> 
  1. what t = unsigned means?
  2. does compiler enforce unsigned on given type?

that's default template parameter; similar default function parameter. if don't put in argument, default unsigned [int]. imagine this:

template <typename t = unsigned> struct foo {     t one;     t two; }; 

if declare example foo<char>, resulting structure have 2 char members. default parameter lets me declare foo<>, , that structure have 2 unsigned int members, because unsigned int default.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -