Savarese Software Research Corporation
make_smart_ptr.h
Go to the documentation of this file.
1 /* Copyright 2016, 2017 Savarese Software Research Corporation
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.savarese.com/software/ApacheLicense-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
21 #ifndef __SSRC_WISP_UTILITY_MAKE_SMART_PTR_H
22 #define __SSRC_WISP_UTILITY_MAKE_SMART_PTR_H
23 
24 #include <ssrc/wisp-packages.h>
25 
26 #include <memory>
27 
29 
30 template<typename T, typename P>
31 struct smart_ptr_factory { };
32 
33 template<typename T>
34 struct smart_ptr_factory<T, std::shared_ptr<T> > {
35  template<typename... Args>
36  inline static std::shared_ptr<T> make(Args && ...args) {
37  return std::make_shared<T>(std::forward<Args>(args)...);
38  }
39 };
40 
41 template<typename T>
42 struct smart_ptr_factory<T, std::unique_ptr<T> > {
43  template<typename... Args>
44  inline static std::unique_ptr<T> make(Args && ...args) {
45  return std::make_unique<T>(std::forward<Args>(args)...);
46  }
47 };
48 
49 template<typename SmartPtr, typename... Args>
50 inline SmartPtr make_smart_ptr(Args && ...args) {
52 }
53 
55 
56 #endif

Savarese Software Research Corporation
Copyright © 2006-2012 Savarese Software Research Corporation. All rights reserved.