Get number of dimensions of tensor using C++ frontend

With the python frontend tensor.size() already returns a list of sizes, but in the C++ frontend I have to specify the dimension tensor.size(dim). How do I know the number of available dimensions in the first place?

This way -> tensor.dim()