G
Giulio Veronesi
Hi,
Let us consider the following code fragment:
struct TAnnotation {
int x, y;
};
struct TAnnotationLT
{
bool operator()(const TAnnotation& a1, const TAnnotation& a2) const {
return ( (a1.x < a2.x) ||
( (a1.x == a2.x) && (a2.y < a2.y) ) );
}
};
typedef set<TAnnotation, TAnnotationLT> TAnnotationsSet;
TAnnotationsSet s1, s2, s3;
I would like to put in s3 the intersection between the sets s1 and s3.
If I do:
set_intersection(as1.begin(), as1.end(), as2.begin(), as2.end(),
std::inserter(as3, as3.begin()));
I get the following compilation error:
/usr/include/c++/3.4.3/bits/stl_algo.h: In function `_OutputIterator
std::set_intersection(_InputIterator1, _InputIterator1,
_InputIterator2, _InputIterator2, _OutputIterator) [with
_InputIterator1 = std::_Rb_tree_const_iterator<TAnnotation>,
_InputIterator2 = std::_Rb_tree_const_iterator<TAnnotation>,
_OutputIterator = std::insert_iterator<TAnnotationsSet>]':
prova2.cpp:63: instantiated from here
/usr/include/c++/3.4.3/bits/stl_algo.h:4210: error: no match for
'operator<' in
'(&__first1)->std::_Rb_tree_const_iterator<_Tp>:perator* [with _Tp =
TAnnotation]() <
(&__first2)->std::_Rb_tree_const_iterator<_Tp>:perator* [with _Tp =
TAnnotation]()'
prova2.cpp:63: instantiated from here
/usr/include/c++/3.4.3/bits/stl_algo.h:4212: error: no match for
'operator<' in
'(&__first2)->std::_Rb_tree_const_iterator<_Tp>:perator* [with _Tp =
TAnnotation]() <
(&__first1)->std::_Rb_tree_const_iterator<_Tp>:perator* [with _Tp =
TAnnotation]()'
Please, could you help me to resolve the problem?
Thanks in advance,
Giulio
Let us consider the following code fragment:
struct TAnnotation {
int x, y;
};
struct TAnnotationLT
{
bool operator()(const TAnnotation& a1, const TAnnotation& a2) const {
return ( (a1.x < a2.x) ||
( (a1.x == a2.x) && (a2.y < a2.y) ) );
}
};
typedef set<TAnnotation, TAnnotationLT> TAnnotationsSet;
TAnnotationsSet s1, s2, s3;
I would like to put in s3 the intersection between the sets s1 and s3.
If I do:
set_intersection(as1.begin(), as1.end(), as2.begin(), as2.end(),
std::inserter(as3, as3.begin()));
I get the following compilation error:
/usr/include/c++/3.4.3/bits/stl_algo.h: In function `_OutputIterator
std::set_intersection(_InputIterator1, _InputIterator1,
_InputIterator2, _InputIterator2, _OutputIterator) [with
_InputIterator1 = std::_Rb_tree_const_iterator<TAnnotation>,
_InputIterator2 = std::_Rb_tree_const_iterator<TAnnotation>,
_OutputIterator = std::insert_iterator<TAnnotationsSet>]':
prova2.cpp:63: instantiated from here
/usr/include/c++/3.4.3/bits/stl_algo.h:4210: error: no match for
'operator<' in
'(&__first1)->std::_Rb_tree_const_iterator<_Tp>:perator* [with _Tp =
TAnnotation]() <
(&__first2)->std::_Rb_tree_const_iterator<_Tp>:perator* [with _Tp =
TAnnotation]()'
prova2.cpp:63: instantiated from here
/usr/include/c++/3.4.3/bits/stl_algo.h:4212: error: no match for
'operator<' in
'(&__first2)->std::_Rb_tree_const_iterator<_Tp>:perator* [with _Tp =
TAnnotation]() <
(&__first1)->std::_Rb_tree_const_iterator<_Tp>:perator* [with _Tp =
TAnnotation]()'
Please, could you help me to resolve the problem?
Thanks in advance,
Giulio