D
dragon9
//main.cpp
...
class IsFileAttributes{
public:
IsFileAttributes(const DWORD aim):aim_(aim){}
bool operator() (const fs:ath arg){
using namespace wukexin;
string fname=arg.native_file_string();
DWORD attrib=GetFileAttributes(fname.c_str() );
std::cout<<fname<<"\n";
//std::cout<<"file="<<attrib<<"\tfiltrate="<<aim_<<"\n";
//std::cout<<"file="<<fileAttribToStr(attrib)<<"\tfiltrate="<<fileAttribToStr(aim_)<<"\n";
std::cout.setf(ios::boolalpha);
std::cout<<static_cast<bool>(aim_ & attrib)<<"\t"<<fname<<"\n";
return ( aim_ & attrib );
}
//private:
DWORD aim_;
};
...
if(vm.count("attribute") ){
for(vector<string>::const_iterator
itr=attribs.begin();itr!=attribs.end();++itr){
attrib |= wukexin::stringToAttrib(*itr);
}
filtrate(fileList,IsFileAttributes(attrib) );
}
...
//help.h
//
template<class C, class P> void filtrate(C& c, P pred)
{
c.erase(std::remove_if(c.begin(), c.end(), std::not1(pred) ), c.end());
}
//vc 2003 error message
main.cpp
d:\backup\program\VC2003\include\functional(201) : error C2039:
¡°argument_type¡± : ²»ÊÇ¡°IsFileAttributes¡±µÄ³ÉÔ±
main.cpp(31) : ²Î¼û¡°IsFileAttributes¡±µÄÉùÃ÷
d:\backup\program\boost_1_34_1\../wukexin\help\help.h(18) : ²Î¼û¶ÔÕýÔÚ±àÒëµÄÀàÄ£°åʵÀý»¯¡°std::unary_negate<_Fn1>¡±µÄÒýÓÃ
with
[
_Fn1=IsFileAttributes
]
main.cpp(171) : ²Î¼û¶ÔÕýÔÚ±àÒëµÄº¯ÊýÄ£°åʵÀý»¯¡°void
filtrate<Container,IsFileAttributes>(C &,P)¡±µÄÒýÓÃ
with
[
C=Container,
P=IsFileAttributes
]
d:\backup\program\VC2003\include\functional(201) : error C2146: Óï·¨´íÎó :
ȱÉÙ¡°,¡±(ÔÚ±êʶ·û¡°argument_type¡±µÄÇ°Ãæ)
d:\backup\program\VC2003\include\functional(201) : error C2065:
¡°argument_type¡± : δÉùÃ÷µÄ±êʶ·û
d:\backup\program\VC2003\include\functional(201) : error C2976:
¡°std::unary_function¡± : Ä£°å²ÎÊýÌ«ÉÙ
d:\backup\program\VC2003\include\functional(20) : ²Î¼û¡°std::unary_function¡±µÄÉùÃ÷
d:\backup\program\VC2003\include\functional(209) : error C2039:
¡°argument_type¡± : ²»ÊÇ¡°IsFileAttributes¡±µÄ³ÉÔ±
main.cpp(31) : ²Î¼û¡°IsFileAttributes¡±µÄÉùÃ÷
d:\backup\program\boost_1_34_1\../wukexin\help\help.h(18) : error C2664:
¡°std::remove_if¡± : ²»Äܽ«²ÎÊý 3 ´Ó¡°std::unary_negate<_Fn1>¡±×ª»»Îª¡°std::unary_negate<_Fn1>¡±
with
[
_Fn1=IsFileAttributes
]
and
[
_Fn1=IsFileAttributes
]
ûÓпÉÓÃÓÚ class¡°std::unary_negate<_Fn1>¡±µÄ¸´Öƹ¹Ô캯Êý£¬»ò¹¹Ô캯ÊýÊÔͼִÐе½·Ç __gc ÒýÓõķǷ¨×ª»»
with
[
_Fn1=IsFileAttributes
]
...
class IsFileAttributes{
public:
IsFileAttributes(const DWORD aim):aim_(aim){}
bool operator() (const fs:ath arg){
using namespace wukexin;
string fname=arg.native_file_string();
DWORD attrib=GetFileAttributes(fname.c_str() );
std::cout<<fname<<"\n";
//std::cout<<"file="<<attrib<<"\tfiltrate="<<aim_<<"\n";
//std::cout<<"file="<<fileAttribToStr(attrib)<<"\tfiltrate="<<fileAttribToStr(aim_)<<"\n";
std::cout.setf(ios::boolalpha);
std::cout<<static_cast<bool>(aim_ & attrib)<<"\t"<<fname<<"\n";
return ( aim_ & attrib );
}
//private:
DWORD aim_;
};
...
if(vm.count("attribute") ){
DWORD attrib(0);const vector said:>();
for(vector<string>::const_iterator
itr=attribs.begin();itr!=attribs.end();++itr){
attrib |= wukexin::stringToAttrib(*itr);
}
filtrate(fileList,IsFileAttributes(attrib) );
}
...
//help.h
//
template<class C, class P> void filtrate(C& c, P pred)
{
c.erase(std::remove_if(c.begin(), c.end(), std::not1(pred) ), c.end());
}
//vc 2003 error message
main.cpp
d:\backup\program\VC2003\include\functional(201) : error C2039:
¡°argument_type¡± : ²»ÊÇ¡°IsFileAttributes¡±µÄ³ÉÔ±
main.cpp(31) : ²Î¼û¡°IsFileAttributes¡±µÄÉùÃ÷
d:\backup\program\boost_1_34_1\../wukexin\help\help.h(18) : ²Î¼û¶ÔÕýÔÚ±àÒëµÄÀàÄ£°åʵÀý»¯¡°std::unary_negate<_Fn1>¡±µÄÒýÓÃ
with
[
_Fn1=IsFileAttributes
]
main.cpp(171) : ²Î¼û¶ÔÕýÔÚ±àÒëµÄº¯ÊýÄ£°åʵÀý»¯¡°void
filtrate<Container,IsFileAttributes>(C &,P)¡±µÄÒýÓÃ
with
[
C=Container,
P=IsFileAttributes
]
d:\backup\program\VC2003\include\functional(201) : error C2146: Óï·¨´íÎó :
ȱÉÙ¡°,¡±(ÔÚ±êʶ·û¡°argument_type¡±µÄÇ°Ãæ)
d:\backup\program\VC2003\include\functional(201) : error C2065:
¡°argument_type¡± : δÉùÃ÷µÄ±êʶ·û
d:\backup\program\VC2003\include\functional(201) : error C2976:
¡°std::unary_function¡± : Ä£°å²ÎÊýÌ«ÉÙ
d:\backup\program\VC2003\include\functional(20) : ²Î¼û¡°std::unary_function¡±µÄÉùÃ÷
d:\backup\program\VC2003\include\functional(209) : error C2039:
¡°argument_type¡± : ²»ÊÇ¡°IsFileAttributes¡±µÄ³ÉÔ±
main.cpp(31) : ²Î¼û¡°IsFileAttributes¡±µÄÉùÃ÷
d:\backup\program\boost_1_34_1\../wukexin\help\help.h(18) : error C2664:
¡°std::remove_if¡± : ²»Äܽ«²ÎÊý 3 ´Ó¡°std::unary_negate<_Fn1>¡±×ª»»Îª¡°std::unary_negate<_Fn1>¡±
with
[
_Fn1=IsFileAttributes
]
and
[
_Fn1=IsFileAttributes
]
ûÓпÉÓÃÓÚ class¡°std::unary_negate<_Fn1>¡±µÄ¸´Öƹ¹Ô캯Êý£¬»ò¹¹Ô캯ÊýÊÔͼִÐе½·Ç __gc ÒýÓõķǷ¨×ª»»
with
[
_Fn1=IsFileAttributes
]