Weird compiler errors

I really don't have a clue what's going on...

error C2666: 'operator <<' : 19 overloads have similar conversions
while trying to match the argument list '(std::stringstream, uint32)'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
			std::stringstream s;

			switch(m_data.front()->m_type) {
				case TYPE_INT:		
					{
						int32* i = (int32*)m_data.front()->m_data;
						int32 temp = *i;
						s << temp; //error here
					} break;
				case TYPE_UINT:		
					{
						uint32* i = (uint32*)m_data.front()->m_data;
						uint32 temp = *i;
						s << temp;  //here
					};break;
				case TYPE_CHAR:		
					{
						char* c = (char*)m_data.front()->m_data;
						char temp = *c;
						s << temp;  //and here 
					} break; 
				default: break;
			}


More details:
m_data is a list of Data*(which is a helper class that holds a void* called m_data)

More code here:
http://pastebin.com/9HuiRyE6 //Value.h
http://pastebin.com/w4rLYHJH //Value.cpp
afaik int32 is a non-standard type, so operator<<(std::stringstream, int32) isn't defined.
sorry.. forgot to mention... int32 is a typedef for int. uint32 is a typedef for unsigned
sorry to bump.. but I really need help. I have no ideea what's wrong :|
I have no idea...try just creating the stringstream and putting something (anything) into it and see if it gives the same error.

Maybe check all your includes are set up correctly?
I don't know what is wrong just looking at it. I can't seem to reproduce your error, either. I would try copying bits of the code into a separate test program to get the smallest amount that can reproduce the error.
Apparently it's because of two overloaded operators <<
1
2
3
	std::ostream& operator<<( std::ostream& os, const Rect& rect);
	std::stringstream& operator << (std::stringstream& ss, const Rect& rect);

Without them.. it works. But I need/want them. Any way to fix it ?
They're are declared on an .h file, and defined in a .cpp file.
Last edited on
Do me a favour - post the defines.h file.
In your defines.cpp file, you have this line:
#include "../include/gui/Defines.hpp"

what is this defines.hpp file??
That was the Defines.hpp, the Defines.h(I forgot it's .hpp so I wrote .h) post from pastebin..

Also.. I removed the const from const Rect&, and now it compiles. But I kinda wanna know.. why didn't it compile with const on?
ha, so that is why it was working for me, you posted it without the const and it was working - now
that I have put them in it creates the problem you mentioned with the overloads.

the problem seems to be tied in with this particular function
std::stringstream& operator << (std::stringstream& ss, const gui::Rect& rect);
It (MSVC) just does not like this stringstream << operator overload with const.

I can't quite figure out why (yet)
Topic archived. No new replies allowed.