Snippets

Federico Fuga Implements std::make_unique (c++14) on c++11

Created by Federico Fuga last modified
#ifndef MAKE_UNIQUE_H
#define MAKE_UNIQUE_H

#include <memory>

namespace utils {

#if (__cplusplus < 201402L)

    template<typename T, typename... Args>
    std::unique_ptr<T> make_unique(Args &&...args) {
        return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
    }	

#else

	using make_unique = std::make_unique;

#endif

}

#endif // MAKE_UNIQUE_H

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.