00001 00002 #ifndef _INSTIGATE_OPEN_SOURCE_INTERNAL_HEADER_IN_CONCEPT 00003 #error This is an internal header file used to implement Instigate STL.\ 00004 It should never be included directly by a program. 00005 #endif 00006 00007 #ifndef INSTIGATE_STL_GENERATOR_HPP 00008 #define INSTIGATE_STL_GENERATOR_HPP 00009 00058 // Headers from this project 00059 00060 // Headers from other projects 00061 00062 // Headers from standard libraries 00063 00064 // Forward declarations 00065 namespace instigate { 00066 namespace stl { 00074 namespace generator { 00075 template <typename G> 00076 struct interface; 00077 template <typename G> 00078 struct requirements; 00079 template <typename R> 00080 struct interface<R (*) ()>; 00081 } 00082 } 00083 } 00084 00112 template <typename G> 00113 struct instigate::stl::generator::interface 00114 : instigate::generic::assignable::interface<G> 00115 { 00117 typedef typename G::result_type result_type; 00118 00125 static result_type invoke(const G& f) 00126 { 00127 return f(); 00128 } 00129 }; 00130 00135 template <typename R> 00136 struct instigate::stl::generator::interface<R (*) ()> 00137 : instigate::generic::assignable::interface<R (*) ()> 00138 { 00140 typedef R result_type; 00141 00148 static result_type invoke(R (*f)()) 00149 { 00150 return f(); 00151 } 00152 }; 00153 00161 template <typename T> 00162 struct instigate::stl::generator::requirements 00163 : instigate::generic::assignable::interface<T> 00164 { 00169 static void require_nested_typename_result_type() 00170 { 00171 typedef instigate::stl::generator::interface<T> I; 00172 typedef typename I::result_type R; 00173 } 00174 00179 static void require_method_invoke() 00180 { 00181 typedef instigate::stl::generator::interface<T> I; 00182 (void)I::invoke; 00183 } 00184 00189 typename instigate::stl::generator::interface<T>::result_type static 00190 check_signature_of_the_invoke(T& f) 00191 { 00192 namespace G = instigate::stl::generator; 00193 return G::interface<T>::invoke(f); 00194 } 00195 00201 requirements() 00202 { 00203 (void)&require_nested_typename_result_type; 00204 (void)&require_method_invoke; 00205 (void)&check_signature_of_the_invoke; 00206 } 00207 00208 }; 00209 00210 // vim:et:tabstop=8:shiftwidth=8:cindent:fo=croq:textwidth=80: 00211 00212 #endif // INSTIGATE_STL_GENERATOR_HPP