# Comile Error: C2784

This topic is 4877 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've hit the end of my rope with this error. Its caused (somehow) by my overloaded = operator. It reports the error in xutility and the nature of the error suggests its something to do with the fact im using vectors as a previous bug-fix reports this error is quite common when dealing with them (Source MSDN). However, the bug-fix was sorted in VC++ 97 and I am using VC++ Version 6, an even later version. Here's the code for my overloaded operator. Hopefully an eagle-eyed coder can spot something which I have overlooked.
// The offending operator

LINE LINE::operator=(const LINE LineB)
{
this->text = LineB.text;
return (*this);
}

// The following variable is a member of another class.

vector <LINE> LineSetA;


##### Share on other sites
It would be a lot easier to figure out what is causing your error if you said what "the error" is.

I doubt this is the answer, but the parameter to the function needs to be "const LINE & LineB". Check the parameter to your copy constructor for the same problem.

Also, in order to handle the statement "x = x;", operator=() usually has something like this: "if ( this != &LineB ) ...".

##### Share on other sites
Error C2784 is:

error C2784: '(template instantiation) : could not deduce template argument for (a template) from (a class)'
.

Don't know what to fill in though.

##### Share on other sites
Thanks John, overlooked that mistake. Still getting the template problems though. If I take out the overloaded operator, everything compiles as it should. But I need that operator for some of the functions I've yet to include.

##### Share on other sites
Hi,

How's LINE defined, because it looks an awful lot like a macro of some kind, but that could be your naming convention too. [wink]

Is class/struct LINE templated and if so: how?

cu,
CipherCraft

##### Share on other sites
Can we see the declaration of your LINE class/struct, and also the full error message, and the line of code that the error occurs on?

##### Share on other sites
class LINE{	private:     	std::string parseit(  char c ); 	public:            	std::string text;	//constructor / destructor       	LINE();	~LINE();	void init(LINE line);	int size();	std::string fromstring( char c );	LINE operator=(const LINE &LineB);};// Error supplied/*C:\Program Files\Programming\DevStudio\VC\INCLUDE\xutility(45) : error C2784:'bool __cdecl std::operator <(const class std::basic_string<template-parameter-1',template-parameter-2',template-parameter-3'> &,const template-parameter-1 *)' : could not deduce template argumentfor 'const class std::basic_string<template-parameter-1',template-parameter-2',template-parameter-3'> &'from 'const class LINE'*/
Actually, thats one of 24 errors, each one detailing pretty much the same error, but given for a different template.

##### Share on other sites
Translation of that error: "Something to do with operator < (probably to do with sorting) is expecting a std::string, but it's getting a LINE instead."

Try making a copy constructor. The STL might be complaining because you don't have one, but you do have an operator=()
Something like:
LINE::LINE(const LINE& rhs) : text(rhs.text){}

##### Share on other sites
Yes, it is indeed something to do with the < operator. It always occurs where the comparison (*_F1 < *_F2) is made in xutility. I can only assume that F1 and F2 are pointers due to my lack of knowledge on the file. If so, then surely this would not prove to be a problem for the compiler?

##### Share on other sites
I'm confused. I don't get any compile errors no matter which compiler I use (I tried VC++ 6.00.8168, Borland C++ 5.5.1, Mingw GCC 3.2.3, Visual C++ .NET 2003).

Quote:
 I can only assume that F1 and F2 are pointers due to my lack of knowledge on the file. If so, then surely this would not prove to be a problem for the compiler?

Not always. _F1 and _F2 ([wow], that code is ugly [grin]) are input iterators (pointers, usually, but not always). The error is in the function lexicographical_compare. As far as I can see this is called from std::vector<_Ty, _A>::_Lt which is called when a vector is compared with another vector of the same type.

Try defining comparison operators for your class. (Although this shouldn't be necessary).

1. 1
Rutin
24
2. 2
3. 3
JoeJ
18
4. 4
5. 5

• 38
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631706
• Total Posts
3001835
×