The implementation of variadic templates includes a sizeof… operator that returns the number of template arguments in the parameter pack.
template<typename... Args> class Test
{
public:
size_t GetTCount()
{
return sizeof...(Args);
}
};
// . . .
Test<int> data;
size_t args = data.GetTCount(); //1
Test<int, int, char*> data2;
args = data2.GetTCount(); //3
Test<int, float> data3;
args = data3.GetTCount(); //2
It’s really more of a count-of here but I guess they chose to reuse an existing operator that’s familiar to C++ developers.