00001 #ifndef _INSTIGATE_OPEN_SOURCE_INTERNAL_HEADER_IN_CONCEPT 00002 #error This is an internal header file used to implement Instigate Open Source.\ It should never be included directly by a program. 00003 #endif 00004 00005 #ifndef INSTIGATE_GENERIC_EQUALITY_COMPARABLE_HPP 00006 #define INSTIGATE_GENERIC_EQUALITY_COMPARABLE_HPP 00007 00032 // Headers from this project 00033 00034 // Headers from other projects 00035 00036 // Headers from standard libraries 00037 00038 // Forward declarations 00039 namespace instigate { 00048 namespace equality_comparable { 00049 struct tag; 00050 template <typename T> struct interface; 00051 template <typename T> struct requirements; 00052 } 00053 } 00054 00061 struct instigate::equality_comparable::tag 00062 { 00063 }; 00064 00069 template<typename T> 00070 struct instigate::equality_comparable::interface 00071 { 00081 static bool equal(const T& a, const T& b) 00082 { 00083 return a == b; 00084 } 00085 }; 00086 00094 template<typename T> 00095 struct instigate::equality_comparable::requirements 00096 { 00101 static void return_type_must_be_convertible_to_bool(const T& a, 00102 const T& b) 00103 { 00104 bool k = instigate::equality_comparable:: 00105 interface<T>::equal(a, b); 00106 } 00107 00112 static void require_equal(const T& a, const T& b) 00113 { 00114 instigate::equality_comparable::interface<T>::equal(a, b); 00115 } 00116 00124 requirements() 00125 { 00126 &return_type_must_be_convertible_to_bool; 00127 &require_equal; 00128 } 00129 }; 00130 00131 // vim:et:tabstop=8:shiftwidth=8:cindent:fo=croq:textwidth=80: 00132 00133 #endif // INSTIGATE_GENERIC_EQUALITY_COMPARABLE_HPP