Skip to content

Instantly share code, notes, and snippets.

@takashi1975
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save takashi1975/034aa38d67a6878d5207 to your computer and use it in GitHub Desktop.

Select an option

Save takashi1975/034aa38d67a6878d5207 to your computer and use it in GitHub Desktop.
C++11 std::find_if ループ検索例
//Cocos2d-x Layer での使用例を想定
{
auto children = this->getChildren();
auto func = [](Node * node){
bool result = false;
{
//TODO: 判定条件
if (/*判定条件*/)
{
result = true;
}
}
return result;
};
for (auto it = children.begin(); children.end() != (it = std::find_if(it, children.end(), func)); it++)
{
if (auto node = dynamic_cast<Sprite *>(*it))
{
//TODO: WORK
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment