00001 // $Id: safe_bool.cti 1742 2010-11-04 14:51:56Z g0dil $ 00002 // 00003 // Copyright (C) 2007 00004 // Fraunhofer (FOKUS) 00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY 00006 // Stefan Bund <g0dil@berlios.de> 00007 // 00008 // This program is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program 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 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program; if not, write to the 00020 // Free Software Foundation, Inc., 00021 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 00026 //#include "safe_bool.ih" 00027 00028 // Custom includes 00029 00030 #define prefix_ inline 00031 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00032 00033 template <typename T> 00034 prefix_ senf::comparable_safe_bool<T>::operator bool_type() 00035 const 00036 { 00037 return (static_cast<const T*>(this))->boolean_test() 00038 ? &safe_bool_base::this_type_does_not_support_comparisons : 0; 00039 } 00040 00041 template <typename T> 00042 prefix_ bool senf::comparable_safe_bool<T>::operator!() 00043 const 00044 { 00045 return ! (static_cast<const T*>(this))->boolean_test(); 00046 } 00047 00048 template <typename T> 00049 prefix_ senf::comparable_safe_bool<T>::~comparable_safe_bool() 00050 {} 00051 00052 template <typename T, typename U> 00053 prefix_ void senf::operator==(const safe_bool<T>& lhs, const safe_bool<U>& rhs) 00054 { 00055 lhs.this_type_does_not_support_comparisons(); 00056 } 00057 00058 template <typename T, typename U> 00059 prefix_ void senf::operator!=(const safe_bool<T>& lhs, const safe_bool<U>& rhs) 00060 { 00061 lhs.this_type_does_not_support_comparisons(); 00062 } 00063 00064 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00065 #undef prefix_ 00066 00067 00068 // Local Variables: 00069 // mode: c++ 00070 // fill-column: 100 00071 // c-file-style: "senf" 00072 // indent-tabs-mode: nil 00073 // ispell-local-dictionary: "american" 00074 // compile-command: "scons -u test" 00075 // comment-column: 40 00076 // End: