inserting string into a deque

hello! i'm trying to check if a string is a palindrone. what i'm trying to do is put s into a and check the front and the back of the deque to see if it's a palindrone but it doesn't like my insert??

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <cstdlib>
#include <cctype>
#include <string>
#include <deque>
using namespace std;
bool isPalindrome(string s)
{
	deque<string> a;
	string::iterator itr;
	transform(s.begin(),s.end(),s.begin(),static_cast<int (*)(int)>(toupper));
	for(int i = 0; i < sizeof(s);++i)
	{
		a.insert(i,s.begin(),s.end());//here is the root of me problems
	}
	for(int i = 0; i < sizeof(s);++i)
	{
		if(a.front() != a.back())
			return false;
		a.pop_front();
		a.pop_back();
	}
	return true;
}

any ideas?
The value_type of deque is string. On line 14 you provide iterators of type char. string cannot be constructed with a char only. So why not change line 9 to deque<char> a?

Do you know the function reverse:
http://www.cplusplus.com/reference/algorithm/reverse/?kw=reverse
Topic archived. No new replies allowed.