DSA - Data Structures and Algorithms
Loading...
Searching...
No Matches
memory.h File Reference

This file contains implementation of memory functions. More...

#include <memory>

Go to the source code of this file.

Functions

template<typename T, typename... Args>
auto dsa::make_unique (Args &&... args) -> typename std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type
 Creates T type object and wraps it std::unique_ptr.

Detailed Description

This file contains implementation of memory functions.

Author
Michal Zygmunt

Definition in file memory.h.

Function Documentation

◆ make_unique()

template<typename T, typename... Args>
auto dsa::make_unique ( Args &&... args) -> typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T>>::type

Creates T type object and wraps it std::unique_ptr.

Function implements std::make_unique from c++14 into c++11. Will work only when T is NOT an array type object (T[])

Template Parameters
Ttype of object created by function
Argsargument types for T object constructor
Parameters
[in]argsarguments used by T object ctor
Returns
std::unique_ptr<T> object of type T

Definition at line 36 of file memory.h.

37 {
38 return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
39 }