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