Skip to content

Instantly share code, notes, and snippets.

@pervognsen
Last active November 15, 2017 18:29
Show Gist options
  • Save pervognsen/a93253b7572d2aecf6f7 to your computer and use it in GitHub Desktop.
Save pervognsen/a93253b7572d2aecf6f7 to your computer and use it in GitHub Desktop.
__attribute__((noreturn)) void unreachable()
{
__builtin_unreachable();
}
#define assume(x) if (x) ; else unreachable()
// Placement new without the null pointer check
template<class T, class... Args>
void construct(T* p, Args&&... args)
{
assume(p);
new(p) T(std::forward<Args>(args)...);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment