Last active
November 15, 2017 18:29
-
-
Save pervognsen/a93253b7572d2aecf6f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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