While working on a project I came upon this code, which I’m trying to figure out:
enum Attributes { ACTIVE, COMPLETE, POSITION }
template<Attributes NN,typename TT>
TT& Set(TT&& t)
{
return typeList.get<NN>()=t; //typeList is a boost tuple
}
This is called later on with
object.Set<ACTIVE>(true);
There’s only one template parameter in there!
How is possible to specify a template with two parameters, and then call it with only one? I would think the Set method supposed to take 2 template parameters (Attributes and typename), like an std::map.
When calling a function template template parameters, which are the type of the function arguments can be automatically deduced from the type of the arguments, the function is called with:
This is the reason one can use template functions from the standardlibrary, like
std::maxorstd::copywithout explicitely mentioning the types of the arguments.