is_palindrome:(str:std::string_view)->bool=={returnstd::equal(str.cbegin(),str.cbegin()+str.size()/2,str.crbegin());}test:(str:std::string_view)={text:std::string;ifis_palindrome(str){text="is";}else{text="is not";}std::cout<<std::quoted(str)<<std::format(" {} a palindrome",text)<<"\n";}main:()={test("radar");test("hello");static_assert(is_palindrome("civic"));}
Output
"radar" is a palindrome
"hello" is not a palindrome