Silicium
to_unique.hpp
Go to the documentation of this file.
1 #ifndef SILICIUM_TO_UNIQUE_HPP
2 #define SILICIUM_TO_UNIQUE_HPP
3 
4 #include <silicium/config.hpp>
5 #include <memory>
6 
7 namespace Si
8 {
9  template <class T>
10  auto to_unique(T &&t)
11 #if !SILICIUM_COMPILER_HAS_AUTO_RETURN_TYPE
12  -> std::unique_ptr<typename std::decay<T>::type>
13 #endif
14  {
15  typedef typename std::decay<T>::type decayed_T;
16  return std::unique_ptr<decayed_T>(new decayed_T(std::forward<T>(t)));
17  }
18 
19  template <class Pointee, class T>
20  auto to_unique(T &&t)
21 #if !SILICIUM_COMPILER_HAS_AUTO_RETURN_TYPE
22  -> std::unique_ptr<Pointee>
23 #endif
24  {
25  typedef typename std::decay<T>::type decayed_T;
26  return std::unique_ptr<Pointee>(new decayed_T(std::forward<T>(t)));
27  }
28 }
29 
30 #endif
auto to_unique(T &&t) -> std::unique_ptr< typename std::decay< T >::type >
Definition: to_unique.hpp:10
Definition: absolute_path.hpp:19