check if a string is a palindrome

#include <iostream>
#include <string>
#include <algorithm>

bool isPalindrome(const std::string &str) {
    std::string temp = str;
    std::transform(temp.begin(), temp.end(), temp.begin(), ::tolower);
    temp.erase(std::remove_if(temp.begin(), temp.end(), ::isspace), temp.end());

    std::string reversed = temp;
    std::reverse(reversed.begin(), reversed.end());

    return temp == reversed;
}

int main() {
    std::string input;
    std::cout << "Enter a string: ";
    std::getline(std::cin, input);

    if (isPalindrome(input)) {
        std::cout << "The string is a palindrome." << std::endl;
    } else {
        std::cout << "The string is not a palindrome." << std::endl;
    }

    return 0;
}