Skip to content

Instantly share code, notes, and snippets.

@rodgert
Created October 12, 2017 16:07
Show Gist options
  • Save rodgert/9becfe26ce0748a6d6e697f0c530ecca to your computer and use it in GitHub Desktop.
Save rodgert/9becfe26ce0748a6d6e697f0c530ecca to your computer and use it in GitHub Desktop.
foo
template<typename T, typename... Args>
T* aligned_emplace(Args&&... args) {
if (auto p = std::aligned_alloc(std::hardware_destructive_interference_size, sizeof(T))) {
new (p) T(std::forward<Args>(args)...);
return p;
}
throw std::bad_alloc();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment