Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <new>
- #include <type_traits>
- #include <utility>
- namespace details {
- template<typename Type>
- struct emplace_arg_t { };
- template<typename T, typename... Args>
- void emplace(emplace_arg_t<T>, void* location, Args&&... args)
- noexcept(std::is_nothrow_constructible<T, Args&&...>::value) {
- new (location) T(std::forward<Args>(args)...);
- }
- template<typename... Args>
- void emplace(emplace_arg_t<void>, void* location, Args&&... args)
- noexcept(noexcept(new (location) auto(std::forward<Args>(args)...))) {
- new (location) auto(std::forward<Args>(args)...);
- }
- }
- template<typename Type = void, typename... Args>
- void emplace(void* location, Args&&... args)
- noexcept(noexcept(details::emplace(details::emplace_arg_t<Type>{}, location, std::forward<Args>(args)...))) {
- details::emplace(details::emplace_arg_t<Type>{}, location, std::forward<Args>(args)...);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement