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_EQUALITY_COMPARABLE_HPP 00029 #define INSTIGATE_GENERIC_EQUALITY_COMPARABLE_HPP 00030 00039 // Headers from this project 00040 00041 // Headers from other projects 00042 00043 // Headers from standard libraries 00044 00045 // Forward declarations 00046 namespace instigate { 00055 namespace equality_comparable { 00056 struct tag; 00057 template <typename T> struct interface; 00058 template <typename T> struct requirements; 00059 } 00060 } 00061 00068 struct instigate::equality_comparable::tag 00069 { 00070 }; 00071 00076 template<typename T> 00077 struct instigate::equality_comparable::interface 00078 { 00088 static bool equal(const T& a, const T& b) 00089 { 00090 return a == b; 00091 } 00092 }; 00093 00101 template<typename T> 00102 struct instigate::equality_comparable::requirements 00103 { 00108 static void return_type_must_be_convertible_to_bool(const T& a, 00109 const T& b) 00110 { 00111 bool k = instigate::equality_comparable:: 00112 interface<T>::equal(a, b); 00113 (void) k; 00114 } 00115 00120 static void require_equal(const T& a, const T& b) 00121 { 00122 instigate::equality_comparable::interface<T>::equal(a, b); 00123 } 00124 00132 requirements() 00133 { 00134 (void)&requirements<T>::return_type_must_be_convertible_to_bool; 00135 (void)&requirements<T>::require_equal; 00136 } 00137 }; 00138 00139 // vim:et:tabstop=8:shiftwidth=8:cindent:fo=croq:textwidth=80: 00140 00141 #endif // INSTIGATE_GENERIC_EQUALITY_COMPARABLE_HPP