What's the equivalent way for C++ to change dtype in place?

This is the python code:

  x = torch.ones([4], dtype=torch.float64)
  y = x.view(torch.int64)

However, in C++, it doesn’t work:

  x = torch::ones({4}, ...)
  y = x.view(torch::kInt64); // Failed

Which function should I use to do the python-equivalent thing in C++?