Logical AND, OR: Is left-to-right evaluation guaranteed?
问题 Is left-to-right evaluation of logical operators ( && || ) guaranteed? Let\'s say I have this: SDL_Event event; if (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { // do stuff } } Is this guaranteed to be the same as this? SDL_Event event; if (SDL_PollEvent(&event) && event.type == SDL_QUIT) { // do stuff } This can also be very important, let\'s say we have two requirements, a and b . Requirement a is much more likely to fail then b . Then it\'s more efficient to say if (a && b) than