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)
...全文
80 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
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 { 一类的

24,860

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧