本文整理汇总了C++中Program::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Program::begin方法的具体用法?C++ Program::begin怎么用?C++ Program::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Program
的用法示例。
在下文中一共展示了Program::begin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
CompiledProgram::CompiledProgram(Program in_program)
{
mProgSize=0;
for (Program::iterator i=in_program.begin(); i!=in_program.end(); i++)
{
mProgSize+=i->size();
}
mpProg=VirtualAlloc(
NULL,
mProgSize,
MEM_COMMIT | MEM_RESERVE,
PAGE_READWRITE
);
if (mpProg == NULL )
exit(0);
size_t progPos=0;
for (Program::iterator i=in_program.begin(); i!=in_program.end(); i++)
{
memcpy((unsigned char*) mpProg+progPos, &(*i)[0], i->size());
progPos+=i->size();
}
DWORD flOldProtect;
if (!VirtualProtect(mpProg, size(), PAGE_EXECUTE, &flOldProtect))
exit(0);
if (!FlushInstructionCache(GetCurrentProcess(), mpProg, size()))
exit(0);
}
示例2: end
bool Program::operator==(const Program& rhs) const {
return MaxLabel == rhs.MaxLabel &&
MaxCheck == rhs.MaxCheck &&
FilterOff == rhs.FilterOff &&
Filter == rhs.Filter &&
std::equal(begin(), end(), rhs.begin());
}
示例3: mutateProgram
Program MutationCache::mutateProgram(const Program& program, Mutation mutation)
{
auto start = program.begin();
auto programLen = program.size();
auto instruction = getMutationInstruction(mutation);
auto position = getMutationPosition(mutation);
switch(getMutationType(mutation))
{
case addition:
{
Program result(start, start + position);
result.push_back(instruction);
result.insert(result.end(), start + position, program.end());
return result;
}
break;
case removal:
{
Program result(start, start + position);
result.insert(result.end(), start + position + 1, program.end());
return result;
}
break;
case substitution:
{
Program result = program;
result[position] = (result[position] + instruction) % instructionCount;
return result;
}
default:
throw;
}
}