473,378 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

C2784 triggered by STL::Set insert() and find()

Hello,

I've got this nice inner class that I'm holds a set of "FrontPoint"
objects as shown below. Unfortunately, the find and insert methods
trigger massive C2784 errors. Would someone please point out what I'm
doing wrong?

Many thanks,

- Olumide
//////////////////////// code ////////////////////////

struct FrontPoint
{
// stuff
};

class Cell
{
public:
double xMin , xMax, yMin, yMax , zMin , zMax;
Cell *upper , *lower , *north, *south, *east , *west;
Cell::Cell(){ upper = lower = north = south = east = west = NULL; }
set<FrontPoint frontPoint;

void addFrontPoint( FrontPoint& frontPt )
{
frontPoint.insert( frontPt ); // Triggers C2784
}

void removeFrontPoint( FrontPoint& frontPt )
{
set<FrontPoint >::iterator frontPtItx =
frontPoint.find( frontPt ); // Triggers C2784
}
};
//////////////////////// error ////////////////////////

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::basic_string<_Elem,_Traits,_Alloc&,const _Elem *)' : could not
deduce template argument for 'const
std::basic_string<_Elem,_Traits,_Ax&' from 'const
MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\string(148) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(138) : while compiling class-template member function
'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &) const'
with
[
_Ty=MarchingTriangles::FrontPoint
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\set(48) : see reference to class template instantiation
'std::less<_Ty>' being compiled
with
[
_Ty=MarchingTriangles::FrontPoint
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\xtree(23) : see reference to class template instantiation
'std::_Tset_traits<_Kty,_Pr,_Alloc,_Mfl>' being compiled
with
[
_Kty=MarchingTriangles::FrontPoint,
_Pr=std::less<MarchingTriangles::FrontPoint>,
_Alloc=std::allocator<MarchingTriangles::FrontPoin t>,
_Mfl=false
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\xtree(65) : see reference to class template instantiation
'std::_Tree_nod<_Traits>' being compiled
with
[

_Traits=std::_Tset_traits<MarchingTriangles::Front Point,std::less<MarchingTriangles::FrontPoint>,std ::allocator<MarchingTriangles::FrontPoint>,false>
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\xtree(87) : see reference to class template instantiation
'std::_Tree_ptr<_Traits>' being compiled
with
[

_Traits=std::_Tset_traits<MarchingTriangles::Front Point,std::less<MarchingTriangles::FrontPoint>,std ::allocator<MarchingTriangles::FrontPoint>,false>
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\xtree(105) : see reference to class template instantiation
'std::_Tree_val<_Traits>' being compiled
with
[

_Traits=std::_Tset_traits<MarchingTriangles::Front Point,std::less<MarchingTriangles::FrontPoint>,std ::allocator<MarchingTriangles::FrontPoint>,false>
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\set(57) : see reference to class template instantiation
'std::_Tree<_Traits>' being compiled
with
[

_Traits=std::_Tset_traits<MarchingTriangles::Front Point,std::less<MarchingTriangles::FrontPoint>,std ::allocator<MarchingTriangles::FrontPoint>,false>
]
c:\Work\Project\MuscleBuilder\MarchingTriangles.h( 72) : see
reference to class template instantiation 'std::set<_Kty>' being
compiled
with
[
_Kty=MarchingTriangles::FrontPoint
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const _Elem
*,const std::basic_string<_Elem,_Traits,_Alloc&)' : could not deduce
template argument for 'const T1 *' from 'const
MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\string(138) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::basic_string<_Elem,_Traits,_Alloc&,const
std::basic_string<_Elem,_Traits,_Alloc&)' : could not deduce
template argument for 'const std::basic_string<_Elem,_Traits,_Ax&'
from 'const MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\string(128) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::list<_Ty,_Alloc&,const std::list<_Ty,_Alloc&)' : could not
deduce template argument for 'const std::list<_Ty,_Ax&' from 'const
MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\list(991) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::_Tree<_Traits&,const std::_Tree<_Traits&)' : could not deduce
template argument for 'const std::_Tree<_Traits&' from 'const
MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\xtree(1170) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::vector<_Ty,_Alloc&,const std::vector<_Ty,_Alloc&)' : could
not deduce template argument for 'const std::vector<_Ty,_Ax&' from
'const MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\vector(915) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::reverse_iterator<_RanIt&,const std::reverse_iterator<_RanIt>
&)' : could not deduce template argument for 'const
std::reverse_iterator<_RanIt&' from 'const
MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\xutility(655) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::pair<_Ty1,_Ty2&,const std::pair<_Ty1,_Ty2&)' : could not
deduce template argument for 'const std::pair<_Ty1,_Ty2&' from
'const MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\utility(73) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2676: binary '<' : 'const
MarchingTriangles::FrontPoint' does not define this operator or a
conversion to a type acceptable to the predefined operator
MarchingTriangles.cpp
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::basic_string<_Elem,_Traits,_Alloc&,const _Elem *)' : could not
deduce template argument for 'const
std::basic_string<_Elem,_Traits,_Ax&' from 'const
MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\string(148) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(138) : while compiling class-template member function
'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &) const'
with
[
_Ty=MarchingTriangles::FrontPoint
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\set(48) : see reference to class template instantiation
'std::less<_Ty>' being compiled
with
[
_Ty=MarchingTriangles::FrontPoint
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\xtree(23) : see reference to class template instantiation
'std::_Tset_traits<_Kty,_Pr,_Alloc,_Mfl>' being compiled
with
[
_Kty=MarchingTriangles::FrontPoint,
_Pr=std::less<MarchingTriangles::FrontPoint>,
_Alloc=std::allocator<MarchingTriangles::FrontPoin t>,
_Mfl=false
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\xtree(65) : see reference to class template instantiation
'std::_Tree_nod<_Traits>' being compiled
with
[

_Traits=std::_Tset_traits<MarchingTriangles::Front Point,std::less<MarchingTriangles::FrontPoint>,std ::allocator<MarchingTriangles::FrontPoint>,false>
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\xtree(87) : see reference to class template instantiation
'std::_Tree_ptr<_Traits>' being compiled
with
[

_Traits=std::_Tset_traits<MarchingTriangles::Front Point,std::less<MarchingTriangles::FrontPoint>,std ::allocator<MarchingTriangles::FrontPoint>,false>
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\xtree(105) : see reference to class template instantiation
'std::_Tree_val<_Traits>' being compiled
with
[

_Traits=std::_Tset_traits<MarchingTriangles::Front Point,std::less<MarchingTriangles::FrontPoint>,std ::allocator<MarchingTriangles::FrontPoint>,false>
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\set(57) : see reference to class template instantiation
'std::_Tree<_Traits>' being compiled
with
[

_Traits=std::_Tset_traits<MarchingTriangles::Front Point,std::less<MarchingTriangles::FrontPoint>,std ::allocator<MarchingTriangles::FrontPoint>,false>
]
c:\Work\Project\MuscleBuilder\MarchingTriangles.h( 72) : see
reference to class template instantiation 'std::set<_Kty>' being
compiled
with
[
_Kty=MarchingTriangles::FrontPoint
]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const _Elem
*,const std::basic_string<_Elem,_Traits,_Alloc&)' : could not deduce
template argument for 'const T1 *' from 'const
MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\string(138) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::basic_string<_Elem,_Traits,_Alloc&,const
std::basic_string<_Elem,_Traits,_Alloc&)' : could not deduce
template argument for 'const std::basic_string<_Elem,_Traits,_Ax&'
from 'const MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\string(128) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::vector<_Ty,_Alloc&,const std::vector<_Ty,_Alloc&)' : could
not deduce template argument for 'const std::vector<_Ty,_Ax&' from
'const MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\vector(915) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::list<_Ty,_Alloc&,const std::list<_Ty,_Alloc&)' : could not
deduce template argument for 'const std::list<_Ty,_Ax&' from 'const
MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\list(991) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::_Tree<_Traits&,const std::_Tree<_Traits&)' : could not deduce
template argument for 'const std::_Tree<_Traits&' from 'const
MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\xtree(1170) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::reverse_iterator<_RanIt&,const std::reverse_iterator<_RanIt>
&)' : could not deduce template argument for 'const
std::reverse_iterator<_RanIt&' from 'const
MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\xutility(655) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::pair<_Ty1,_Ty2&,const std::pair<_Ty1,_Ty2&)' : could not
deduce template argument for 'const std::pair<_Ty1,_Ty2&' from
'const MarchingTriangles::FrontPoint'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\utility(73) : see declaration of 'std::operator`<''
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2676: binary '<' : 'const
MarchingTriangles::FrontPoint' does not define this operator or a
conversion to a type acceptable to the predefined operator

Oct 13 '08 #1
2 3853
Olumide wrote:
Hello,

I've got this nice inner class that I'm holds a set of "FrontPoint"
objects as shown below. Unfortunately, the find and insert methods
trigger massive C2784 errors. Would someone please point out what I'm
doing wrong?
Among other things, you're not posting a minimal compilable example
which exhibits the behavior in question -- see FAQ 5.8 --
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8
>
//////////////////////// code ////////////////////////

struct FrontPoint
{
// stuff
};

class Cell
{
public:
double xMin , xMax, yMin, yMax , zMin , zMax;
Cell *upper , *lower , *north, *south, *east , *west;
Cell::Cell(){ upper = lower = north = south = east = west = NULL; }
set<FrontPoint frontPoint;

void addFrontPoint( FrontPoint& frontPt )
{
frontPoint.insert( frontPt ); // Triggers C2784
}

void removeFrontPoint( FrontPoint& frontPt )
{
set<FrontPoint >::iterator frontPtItx =
frontPoint.find( frontPt ); // Triggers C2784
}
};
//////////////////////// error ////////////////////////

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
\functional(139) : error C2784: 'bool std::operator <(const
std::basic_string<_Elem,_Traits,_Alloc&,const _Elem *)' : could not
deduce template argument for 'const
std::basic_string<_Elem,_Traits,_Ax&' from 'const
MarchingTriangles::FrontPoint'
OK, Where and what is MarchingTriangles?
[remainder redacted]
Oct 13 '08 #2
I've got this nice inner class that ... holds a set of "FrontPoint"
objects as shown below. Unfortunately, the find and insert methods
trigger massive C2784 errors. Would someone please point out what I'm
doing wrong?

Among other things, you're not posting a minimal compilable example
which exhibits the behavior in question -- see FAQ 5.8 --http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8

...

OK, Where and what is MarchingTriangles?
[remainder redacted]
Oops ... Its the name of the parent class of 'FrontPoint' and 'Cell',
and its quite complex, but it worked perfectly, at least it did until
I added add and remove methods to the inner class 'Cell'. Anyway, I
may have solved the problem, by overloading < in the 'FrontPoint',
which I had to change from a struct to a class like so:

class FrontPoint
{
public:
// stuff

bool operator<( const FrontPoint &frontPt );
friend bool operator<(const FrontPoint& frontPt1 , const FrontPoint&
frontPt2 );
};
Interestingly, the code compiles even though, the both "operator<"
methods aren't (yet) implemented. I wonder if I can get away with not
implementing them ... I'm not trying to be cheeky. I just want to know
if the error is due to a fussy compiler that wrongly assumes these
methods will be called.

Oct 13 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Prakash Bande | last post by:
Hi, I have bool operator == (xx* obj, const string st). I have declared it as friend of class xx. I am now able to do this: xx ox; string st; if (&ox == st) { } But, when I have a vector<xx*>...
25
by: CodeCracker | last post by:
Problem details below: I have few items(simple values or objects) to be put into an array and I implement it through a set rather than just an array of items. This is because every time I get a...
8
by: vk02720 | last post by:
How does the STL "set" class ensure uniqueness ? Does the contained type need to implement a certain method or override a certain operator ( != or < ) ? TIA
12
by: CQ | last post by:
Hi there, I am having the following problem: I have the following class: class reachGraphState { protected: /* ... some stuff .... */ public:
1
by: chenboston | last post by:
I am studying STL set and write a small example to understand it. But my program output does not show that the members are sorted. Could anyone help me to see what's wrong? Thanks. // A.h...
2
by: blackswift | last post by:
hello all, i found set does not have a FindKth(), althought it is realized using a red-black tree. i have two questions: 1. is there any better SET? 2. can set be augmented?
10
by: Christian Chrismann | last post by:
Hi, I've a question on the STL find algorithm: My code: int main( void ) { vector< ClassA* myVector; ClassA *ptrElement1 = ...;
1
by: creativeinspiration | last post by:
Hey Everybody. Does anybody know which operators need to be implemented in order to make the stl set of those objects works? For example I have a class myclass, and I want to have set<myclass>...
2
by: Stefan Istrate | last post by:
How can I find the k-th position in a STL set? I want to do this in O(logN) time, where N is the dimension of the set. Thank you!
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.