|
libpsynth 0.2.1
|
00001 00015 /* 00016 * Copyright (C) 2009 Juan Pedro BolĂvar Puente 00017 * 00018 * This file is part of Psychosynth. 00019 * 00020 * Psychosynth is free software: you can redistribute it and/or modify 00021 * it under the terms of the GNU General Public License as published by 00022 * the Free Software Foundation, either version 3 of the License, or 00023 * (at your option) any later version. 00024 * 00025 * Psychosynth is distributed in the hope that it will be useful, 00026 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00027 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00028 * GNU General Public License for more details. 00029 * 00030 * You should have received a copy of the GNU General Public License 00031 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00032 * 00033 */ 00034 00035 #ifndef PSYNTH_TYPE_TRAITS_H_ 00036 #define PSYNTH_TYPE_TRAITS_H_ 00037 00038 #include <memory> 00039 #include <type_traits> 00040 #include <boost/pointee.hpp> 00041 00042 namespace psynth 00043 { 00044 namespace base 00045 { 00046 00047 template <typename Ptr> 00048 struct pointee : public boost::pointee<Ptr> {}; 00049 template <typename T> 00050 struct pointee<typename std::unique_ptr<T>> { typedef T type; }; 00051 template <typename T> 00052 struct pointee<typename std::shared_ptr<T>> { typedef T type; }; 00053 00054 template <typename Ptr> 00055 struct pointer {}; 00056 00057 template <typename Ptr> 00058 struct pointer <Ptr*> 00059 { 00060 template <typename T> 00061 struct apply { typedef T* type; }; 00062 }; 00063 00064 template <typename Ptr> 00065 struct pointer <std::unique_ptr<Ptr> > 00066 { 00067 template <typename T> 00068 struct apply { typedef std::unique_ptr<T> type; }; 00069 }; 00070 00071 template <typename Ptr> 00072 struct pointer <std::shared_ptr<Ptr> > 00073 { 00074 template <typename T> 00075 struct apply { typedef std::shared_ptr<T> type; }; 00076 }; 00077 00078 template <typename Ptr> 00079 struct pointer <std::auto_ptr<Ptr> > 00080 { 00081 template <typename T> 00082 struct apply { typedef std::auto_ptr<T> type; }; 00083 }; 00084 00085 #if 0 00086 00087 template <typename Ptr> 00088 struct pointer <boost::unique_ptr<Ptr> > 00089 { 00090 template <typename T> 00091 struct apply { typedef boost::unique_ptr<T> type; }; 00092 }; 00093 00094 template <typename Ptr> 00095 struct pointer <boost::shared_ptr<Ptr> > 00096 { 00097 template <typename T> 00098 struct apply { typedef boost::shared_ptr<T> type; }; 00099 }; 00100 00101 #endif 00102 00103 } /* namespace base */ 00104 } /* namespace psynth */ 00105 00106 #endif /* PSYNTH_TYPE_TRAITS_H_ */
1.7.4