make_unique.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * libnbt++ - A library for the Minecraft Named Binary Tag format.
  3. * Copyright (C) 2013, 2015 ljfa-ag
  4. *
  5. * This file is part of libnbt++.
  6. *
  7. * libnbt++ is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * libnbt++ is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with libnbt++. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef MAKE_UNIQUE_H_INCLUDED
  21. #define MAKE_UNIQUE_H_INCLUDED
  22. #include <memory>
  23. namespace nbt
  24. {
  25. ///Creates a new object of type T and returns a std::unique_ptr to it
  26. template<class T, class... Args>
  27. std::unique_ptr<T> make_unique(Args&&... args)
  28. {
  29. return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
  30. }
  31. }
  32. #endif // MAKE_UNIQUE_H_INCLUDED