STL и функция remove_if
29.09.2010, 00:09. Показов 2697. Ответов 1
C++ | 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
26
27
28
29
30
31
32
33
34
35
36
37
38
| #include "stdafx.h"
#include <iostream>
#include <list>
#include <algorithm>
#include <iterator>
.....
struct computer1
{
int comp_number;
int comp_mark;
};
struct connection1
{
int side1;
int side2;
int conn_mark;
};
bool cond_comp(list<computer1>::iterator x)
{
return (x->comp_mark==1);
}
bool cond_conn(list<connection1>::iterator y)
{
return (y->conn_mark==1);
}
void delete1()
{
list<computer1>::iterator x;
x=remove_if(computers.begin(), computers.end(), cond_comp);
computers.erase(x, computers.end());
list<connection1>::iterator y;
y=remove_if(connections.begin(), connections.end(), cond_conn);
connections.erase(y, connections.end());
} |
|
при компиляции указывает на ошибки в библиотеках. текст
c:\program files\microsoft visual studio 9.0\vc\include\algorithm(87) : error C2664: 'bool (std::list<_Ty>::_Iterator<_Secure_validation>)' : cannot convert parameter 1 from 'computer1' to 'std::list<_Ty>::_Iterator<_Secure_validation>'
1> with
1> [
1> _Ty=computer1,
1> _Secure_validation=true
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1> c:\program files\microsoft visual studio 9.0\vc\include\algorithm(96) : see reference to function template instantiation '_InIt std::_Find_if<std::list<_Ty>::_Iterator<_Secure_validation>,bool(__cdecl *)(std::list<_Ty>::_Iterator<true>)>(_InIt,_InIt,_Pr)' being compiled
1> with
1> [
1> _InIt=std::list<computer1>::_Iterator<false>,
1> _Ty=computer1,
1> _Secure_validation=false,
1> _Pr=bool (__cdecl *)(std::list<computer1>::_Iterator<true>)
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\algorithm(1305) : see reference to function template instantiation '_InIt std::find_if<_FwdIt,bool(__cdecl *)(std::list<_Ty>::_Iterator<_Secure_validation>)>(_InIt,_InIt,_Pr)' being compiled
1> with
1> [
1> _InIt=std::list<computer1>::_Iterator<true>,
1> _FwdIt=std::list<computer1>::_Iterator<true>,
1> _Ty=computer1,
1> _Secure_validation=true,
1> _Pr=bool (__cdecl *)(std::list<computer1>::_Iterator<true>)
1> ]
1> c:\users\дмитрий\desktop\с\stl_computer_net\stl_computer_net\stl_computer_net.cp p(105) : see reference to function template instantiation '_FwdIt std::remove_if<std::list<_Ty>::_Iterator<_Secure_validation>,bool(__cdecl *)(std::list<_Ty>::_Iterator<_Secure_validation>)>(_FwdIt,_FwdIt,_Pr)' being compiled
1> with
1> [
1> _FwdIt=std::list<computer1>::_Iterator<true>,
1> _Ty=computer1,
1> _Secure_validation=true,
1> _Pr=bool (__cdecl *)(std::list<computer1>::_Iterator<true>)
1> ]
1>c:\program files\microsoft visual studio 9.0\vc\include\algorithm(1241) : error C2664: 'bool (std::list<_Ty>::_Iterator<_Secure_validation>)' : cannot convert parameter 1 from 'computer1' to 'std::list<_Ty>::_Iterator<_Secure_validation>'
1> with
1> [
1> _Ty=computer1,
1> _Secure_validation=true
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1> c:\program files\microsoft visual studio 9.0\vc\include\algorithm(4951) : see reference to function template instantiation '_OutIt std::_Remove_copy_if<std::list<_Ty>::_Iterator<_Secure_validation>,_OutIt,bool(_ _cdecl *)(std::list<_Ty>::_Iterator<true>)>(_InIt,_InIt,_OutIt,_Pr,std::_Range_checked_ iterator_tag)' being compiled
1> with
1> [
1> _OutIt=std::list<computer1>::_Iterator<true>,
1> _Ty=computer1,
1> _Secure_validation=false,
1> _InIt=std::list<computer1>::_Iterator<false>,
1> _Pr=bool (__cdecl *)(std::list<computer1>::_Iterator<true>)
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\algorithm(1311) : see reference to function template instantiation '_OutIt stdext::unchecked_remove_copy_if<std::list<_Ty>::_Iterator<_Secure_validation>,_ FwdIt,bool(__cdecl *)(std::list<_Ty>::_Iterator<_Secure_validation>)>(_InIt,_InIt,_OutIt,_Pr)' being compiled
1> with
1> [
1> _OutIt=std::list<computer1>::_Iterator<true>,
1> _Ty=computer1,
1> _Secure_validation=true,
1> _FwdIt=std::list<computer1>::_Iterator<true>,
1> _InIt=std::list<computer1>::_Iterator<true>,
1> _Pr=bool (__cdecl *)(std::list<computer1>::_Iterator<true>)
1> ]
1>c:\program files\microsoft visual studio 9.0\vc\include\algorithm(87) : error C2664: 'bool (std::list<_Ty>::_Iterator<_Secure_validation>)' : cannot convert parameter 1 from 'connection1' to 'std::list<_Ty>::_Iterator<_Secure_validation>'
1> with
1> [
1> _Ty=connection1,
1> _Secure_validation=true
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1> c:\program files\microsoft visual studio 9.0\vc\include\algorithm(96) : see reference to function template instantiation '_InIt std::_Find_if<std::list<_Ty>::_Iterator<_Secure_validation>,bool(__cdecl *)(std::list<_Ty>::_Iterator<true>)>(_InIt,_InIt,_Pr)' being compiled
1> with
1> [
1> _InIt=std::list<connection1>::_Iterator<false>,
1> _Ty=connection1,
1> _Secure_validation=false,
1> _Pr=bool (__cdecl *)(std::list<connection1>::_Iterator<true>)
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\algorithm(1305) : see reference to function template instantiation '_InIt std::find_if<_FwdIt,bool(__cdecl *)(std::list<_Ty>::_Iterator<_Secure_validation>)>(_InIt,_InIt,_Pr)' being compiled
1> with
1> [
1> _InIt=std::list<connection1>::_Iterator<true>,
1> _FwdIt=std::list<connection1>::_Iterator<true>,
1> _Ty=connection1,
1> _Secure_validation=true,
1> _Pr=bool (__cdecl *)(std::list<connection1>::_Iterator<true>)
1> ]
1> c:\users\дмитрий\desktop\с\stl_computer_net\stl_computer_net\stl_computer_net.cp p(109) : see reference to function template instantiation '_FwdIt std::remove_if<std::list<_Ty>::_Iterator<_Secure_validation>,bool(__cdecl *)(std::list<_Ty>::_Iterator<_Secure_validation>)>(_FwdIt,_FwdIt,_Pr)' being compiled
1> with
1> [
1> _FwdIt=std::list<connection1>::_Iterator<true>,
1> _Ty=connection1,
1> _Secure_validation=true,
1> _Pr=bool (__cdecl *)(std::list<connection1>::_Iterator<true>)
1> ]
1>c:\program files\microsoft visual studio 9.0\vc\include\algorithm(1241) : error C2664: 'bool (std::list<_Ty>::_Iterator<_Secure_validation>)' : cannot convert parameter 1 from 'connection1' to 'std::list<_Ty>::_Iterator<_Secure_validation>'
1> with
1> [
1> _Ty=connection1,
1> _Secure_validation=true
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1> c:\program files\microsoft visual studio 9.0\vc\include\algorithm(4951) : see reference to function template instantiation '_OutIt std::_Remove_copy_if<std::list<_Ty>::_Iterator<_Secure_validation>,_OutIt,bool(_ _cdecl *)(std::list<_Ty>::_Iterator<true>)>(_InIt,_InIt,_OutIt,_Pr,std::_Range_checked_ iterator_tag)' being compiled
1> with
1> [
1> _OutIt=std::list<connection1>::_Iterator<true>,
1> _Ty=connection1,
1> _Secure_validation=false,
1> _InIt=std::list<connection1>::_Iterator<false>,
1> _Pr=bool (__cdecl *)(std::list<connection1>::_Iterator<true>)
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\algorithm(1311) : see reference to function template instantiation '_OutIt stdext::unchecked_remove_copy_if<std::list<_Ty>::_Iterator<_Secure_validation>,_ FwdIt,bool(__cdecl *)(std::list<_Ty>::_Iterator<_Secure_validation>)>(_InIt,_InIt,_OutIt,_Pr)' being compiled
1> with
1> [
1> _OutIt=std::list<connection1>::_Iterator<true>,
1> _Ty=connection1,
1> _Secure_validation=true,
1> _FwdIt=std::list<connection1>::_Iterator<true>,
1> _InIt=std::list<connection1>::_Iterator<true>,
1> _Pr=bool (__cdecl *)(std::list<connection1>::_Iterator<true>)
1> ]
0
|