00001 00002 /* 00003 * Copyright © 2008-2010 Instigate CJSC, Armenia 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free 00017 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef _INSTIGATE_OPEN_SOURCE_INTERNAL_HEADER_IN_CONCEPT 00021 #error This is an internal header file used to implement Instigate Open Source.\ 00022 It should never be included directly by a program. 00023 #endif 00024 00025 #ifndef INSTIGATE_GENERIC_ASSIGNABLE_HPP 00026 #define INSTIGATE_GENERIC_ASSIGNABLE_HPP 00027 00035 // Headers from this project 00036 00037 // Headers from other project 00038 00039 // Headers from standard libraries 00040 #include <new> 00041 00042 // Forward declarations 00043 namespace instigate { 00044 namespace generic { 00053 namespace assignable { 00054 struct tag; 00055 template <typename T> struct interface; 00056 template <typename T> struct requirements; 00057 } 00058 } 00059 } 00060 00067 struct instigate::generic::assignable::tag 00068 { 00069 }; 00070 00075 template<typename T> 00076 struct instigate::generic::assignable::interface 00077 { 00084 static void assign(T& a, const T& b) 00085 { 00086 a = b; 00087 } 00088 00097 static T* copy_constructor(char* const p, const T& ob) 00098 { 00099 return ::new (static_cast<void*>(p)) T(ob); 00100 } 00101 }; 00102 00110 template<typename T> 00111 struct instigate::generic::assignable::requirements 00112 { 00113 private: 00118 static void require_assign(T& a, const T& b) 00119 { 00120 instigate::generic::assignable::interface<T>::assign(a, b); 00121 } 00122 00127 static void require_copy_constructor(char* p, const T& ob) 00128 { 00129 instigate::generic::assignable::interface<T> 00130 ::copy_constructor(p, ob); 00131 } 00132 00134 public: 00141 requirements() 00142 { 00143 (void)require_assign; 00144 (void)require_copy_constructor; 00145 } 00146 00147 private: 00149 requirements(const requirements&) throw(); 00150 00152 requirements& operator=(const requirements&) throw(); 00153 }; 00154 00155 00156 // vim:et:tabstop=8:shiftwidth=8:cindent:fo=croq:textwidth=80: 00157 00158 #endif // INSTIGATE_GENERIC_ASSIGNABLE_HPP