equality.h
Go to the documentation of this file.00001 #ifndef CPPUT_EQUALITY_H_INCLUDED
00002 # define CPPUT_EQUALITY_H_INCLUDED
00003
00004 # include <cpptl/sharedptr.h>
00005
00006 # ifndef CPPUT_NO_DEFAULT_EQUALITY
00007
00008 # ifdef CPPUT_BOOST_FRIENDLY
00009 namespace boost {
00010 template<class T> class shared_ptr;
00011 }
00012 # endif // CPPUT_BOOST_FRIENDLY
00013
00014
00015 namespace CppUT {
00016
00019 template<class AType, class BType>
00020 struct EqualityTraits
00021 {
00022 static bool equals( const AType &a, const BType &b )
00023 {
00024 return a == b;
00025 }
00026 };
00027
00028
00031 struct NoSpecificEqualityTest
00032 {
00033 };
00034
00035
00038 inline NoSpecificEqualityTest isEqual( ... )
00039 {
00040 return NoSpecificEqualityTest();
00041 };
00042
00043
00045 namespace Impl {
00046 template<typename AType, typename BType>
00047 bool testIsEqual( const AType &, const BType &, bool isEqual )
00048 {
00049 return isEqual;
00050 }
00051
00052 template<typename AType, typename BType>
00053 bool testIsEqual( const AType &a, const BType &b, NoSpecificEqualityTest )
00054 {
00055 return EqualityTraits<AType,BType>::equals( a, b );
00056 }
00057
00058 }
00060
00065 template<typename AType, typename BType>
00066 bool equalityTest( const AType &a, const BType &b )
00067 {
00068 return Impl::testIsEqual( a, b, isEqual( &a, &b ) );
00069 }
00070
00071
00072 # endif // CPPUT_NO_DEFAULT_STRINGIZE
00073
00074
00075 }
00076
00077 #endif // CPPUT_EQUALITY_H_INCLUDED