Skip to content

Instantly share code, notes, and snippets.

@hexagit
Last active July 20, 2018 08:06
Show Gist options
  • Save hexagit/df98bca83884e14dd0d2a139a217c9ab to your computer and use it in GitHub Desktop.
Save hexagit/df98bca83884e14dd0d2a139a217c9ab to your computer and use it in GitHub Desktop.
アクセス違反でゲームエンジンが落ちないようにしよう!スコープの開始と終了を出力する
// スコープの開始と終了を出力する
struct PrintScope
{
// コンストラクタ
PrintScope(const char* name)
: _Name(name)
{
std::cout << _Indent << "Start " << _Name << std::endl;
_Indent.push_back(' ');
}
// デストラクタ
~PrintScope()
{
_Indent.pop_back();
std::cout << _Indent << "End " << _Name << std::endl;
}
const char* _Name;
static std::string _Indent;
};
std::string PrintScope::_Indent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment