sososososos, about bin1st, why error?

ttzzgg_80713 2003-05-09 03:05:09
namespace tzg {
template<typename T>
struct CheckVal : public binary_function<vector<T> ,//vtVal,
PMEMORYVALUE ,// pMem
bool>
{
HANDLE hdl;

CheckVal(HANDLE hdl_)
{
hdl = hdl_;
}//

void setHandle(HANDLE hdl_)
{
hdl = hdl_;
}

bool operator() (vector<T> & vtVal,
PMEMORYVALUE pMem)
{
T *pVal = NULL;
long i = 0;
bool bRet = false;

pVal = new T[vtVal.size() + 1];

if (TRUE == Read_Mem_In_Proc(hdl, pMem->pAddr, pVal, vtVal.size(), NULL))
{
for (i = 0; i < vtVal.size(); ++i)
{
if (vtVal[i] != pVal[i])
{
break;
} //for

if (i == vtVal.size() - 1)
{
bRet = true;
} //if
} //for
} //if

delete []pVal;
return bRet;
}
};
};


template<typename T>
struct ScanImp {
HANDLE hdl;

void setHandle(HANDLE hdl_)
{
hdl = hdl_;
}

static void SetVal(string val, vector<T> &vt)
{
tzg::SetVal(val, vt);
}

static long ScanMemImpl(vector<T> &vtVal, PVOID pAddr, PBYTE pBuf, LONG lSize, vtMemVal &vtVals, hashMemVal &hashVals)
{
return tzg::ScanMemImpl(vtVal, pAddr, pBuf, lSize, vtVals, hashVals);
}

static long ScanAgain(vector<T> &vtVal, HANDLE hdl, vtMemVal &mem_val)
{
tzg::CheckVal<T> v(hdl);

remove_if(mem_val.begin(), mem_val.end(),
not1(bind1st(v, vtVal))); // Here

return static_cast<long>(mem_val.size());
}
};



//---------------------------------------------------
// Error information
d:\program files\microsoft visual studio\vc98\include\functional(162) : error C2662: '()' : cannot convert 'this' pointer from 'const struct tzg::CheckVal<unsigned short>' to 'struct tzg::CheckVal<unsigned short> &'
Conversion loses qualifiers
d:\program files\microsoft visual studio\vc98\include\functional(162) : while compiling class-template member function 'bool __thiscall std::binder1st<struct tzg::CheckVal<unsigned short> >::operator ()(struct tagMemoryValue *const & ) const
'
d:\program files\microsoft visual studio\vc98\include\functional(162) : error C2064: term does not evaluate to a function
d:\program files\microsoft visual studio\vc98\include\functional(162) : while compiling class-template member function 'bool __thiscall std::binder1st<struct tzg::CheckVal<unsigned short> >::operator ()(struct tagMemoryValue *const & ) const
'
Generating Code...
Compiling...
ScanBase.cpp
Generating Code...
Compiling...
Test_Scan.cpp
warning C4786: 'std::pair<std::_Tree<unsigned long,std::pair<unsigned long const ,tagMemoryValue *>,std::map<unsigned long,tagMemoryValue *,std::less<unsigned long>,std::allocator<tagMemoryValue *> >::_Kfn,std::less<unsigned long>,std::allocator<tag
MemoryValue *> >::iterator,bool>' : identifier was truncated to '255' characters in the debug information
Generating Code...
Error executing cl.exe.

Test_Scan.exe - 2 error(s), 1 warning(s)
...全文
15 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
hpho 2003-05-10
你需要提供一个operator()const,因为binder1st的operator()是const的所以要保持行为的一致

template<typename T>
struct CheckVal : public binary_function<vector<T> ,//vtVal,
PMEMORYVALUE ,// pMem
bool>{

bool operator() (const vector<T> & vtVal, PMEMORYVALUE pMem)const{
// ...
}
};
回复
ttzzgg_80713 2003-05-09

typedef struct tagMemoryValue
{
PVOID pAddr;
DWORD dwProcId;
BYTE bVal;
WORD wVal;
DWORD dwVal;
FLOAT fVal;

long FillListCtrl(CListCtrl *pCtrl)
{
ASSERT(pCtrl);
ASSERT(pCtrl->IsKindOf(RUNTIME_CLASS(CListCtrl)));
TCHAR buf[MAX_PATH] = { 0 };
long count = 0L;

count = pCtrl->GetItemCount();

_stprintf(buf, _T("0x%x"), pAddr);
pCtrl->InsertItem(count, buf);
_stprintf(buf, _T("%d"), bVal);
pCtrl->SetItemText(count, 1, buf);
_stprintf(buf, _T("%d"), wVal);
pCtrl->SetItemText(count, 2, buf);
_stprintf(buf, _T("%d"), dwVal);
pCtrl->SetItemText(count, 3, buf);

return 1;
}
} MEMORYVALUE, *PMEMORYVALUE;

typedef vector<PMEMORYVALUE> vtMemVal;
typedef map<DWORD, PMEMORYVALUE> mapMemVal;
typedef pair<DWORD, PMEMORYVALUE> prMemVal;

回复
ttzzgg_80713 2003-05-09
楼上的不会是没有加标准库的头文件吧?
回复
积木 2003-05-09
ft,有些东西的定义没有,所以我是看不出来啊,能不能贴全点,我根本没有看到那个错误
有的全是什么 missing ;missing { 一类的
回复
相关推荐
发帖
工具平台和程序库
创建于2007-09-28

2.4w+

社区成员

C/C++ 工具平台和程序库
申请成为版主
帖子事件
创建了帖子
2003-05-09 03:05
社区公告
暂无公告