#include <list>
#include <algorithm>
#include <iostream>

int main()
{
    // Fill a doubly-linked list with characters.
    std::string str = "racecar";
    std::list<char> l;
    for (char c : str)
        l.emplace_back(c);

    // Find the center of the list.
    auto it = l.begin();
    std::advance(it, l.size() / 2);

    // Compare the first half of the list to the second half.
    if (std::equal(l.begin(), it, l.rbegin()))
        std::cout << str.c_str() << " is a palindrome." << std::endl;
    else
        std::cout << str.c_str() << " is not a palindrome." << std::endl;

    return 0;
}
