00001 00002 #ifndef _INSTIGATE_OPEN_SOURCE_INTERNAL_HEADER_IN_CONCEPT 00003 #error This is an internal header file used to implement Instigate Open Source.\ 00004 It should never be included directly by a program. 00005 #endif 00006 00007 #ifndef INSTIGATE_GENERIC_ASSIGNABLE_HPP 00008 #define INSTIGATE_GENERIC_ASSIGNABLE_HPP 00009 00034 // Headers from this project 00035 00036 // Headers from other project 00037 00038 // Headers from standard libraries 00039 #include <new> 00040 00041 // Forward declarations 00042 namespace instigate { 00051 namespace assignable { 00052 struct tag; 00053 template <typename T> struct interface; 00054 template <typename T> struct requirements; 00055 } 00056 } 00057 00064 struct instigate::assignable::tag 00065 { 00066 }; 00067 00072 template<typename T> 00073 struct instigate::assignable::interface 00074 { 00081 static void assign(T& a, const T& b) 00082 { 00083 a = b; 00084 } 00085 00094 static T* copy_constructor(char* const p, const T& ob) 00095 { 00096 return ::new (static_cast<void*>(p)) T(ob); 00097 } 00098 }; 00099 00107 template<typename T> 00108 struct instigate::assignable::requirements 00109 { 00114 static void require_assign(T& a, const T& b) 00115 { 00116 instigate::assignable::interface<T>::assign(a, b); 00117 } 00118 00123 static void require_copy_constructor(char* p, const T& ob) 00124 { 00125 instigate::assignable::interface<T>::copy_constructor(p, ob); 00126 } 00127 00134 requirements() 00135 { 00136 &require_assign; 00137 &require_copy_constructor; 00138 } 00139 }; 00140 00141 // vim:et:tabstop=8:shiftwidth=8:cindent:fo=croq:textwidth=80: 00142 00143 #endif // INSTIGATE_GENERIC_ASSIGNABLE_HPP