Skip to content

Instantly share code, notes, and snippets.

@zrax
Last active August 29, 2015 13:59
Show Gist options
  • Save zrax/10935239 to your computer and use it in GitHub Desktop.
Save zrax/10935239 to your computer and use it in GitHub Desktop.
#define _X_WITH_ID_(x) _x_with_once_id_ ## x ## _
#define _X_WITH_ID(x) _X_WITH_ID_(x)
#define with(decl) \
if (bool _X_WITH_ID(__LINE__) = true) \
for (decl; _X_WITH_ID(__LINE__); _X_WITH_ID(__LINE__) = false)
with (std::lock_guard<std::mutex> lock(m_mutex)) {
// Do stuff
if (failed)
break;
// Do other stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment