do {…} while(false)

前端 未结 25 2456
小鲜肉
小鲜肉 2020-11-28 03:29

I was looking at some code by an individual and noticed he seems to have a pattern in his functions:

 function()
{
 

        
25条回答
  •  迷失自我
    2020-11-28 03:57

    The break as goto is probably the answer, but I will put forward one other idea.

    Maybe he wanted to have a locally defined variables and used this construct to get a new scope.

    Remember while recent C++ allows for {...} anywhere, this was not always the case.

提交回复
热议问题