check if file is empty c++

ifstream file("filename.txt"); if (file.peek() == ifstream::traits_type::eof()) { // File is empty } else { // File is not empty } file.close();