00001 #ifndef STATIC_CONTAINER_COMPARE_METHODS_H
00002
00003 #define STATIC_CONTAINER_COMPARE_METHODS_H
00004
00005 #include <algorithm>
00006 #include <boost/operators.hpp>
00007
00008 namespace static_container {
00010 template < typename SubClass >
00011 class compare_methods : public boost::less_than_comparable1< SubClass >, public boost::equality_comparable1< SubClass > {
00012 public:
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 bool operator == ( const SubClass& other ) const {
00023 return equal( other );
00024 }
00025
00026 bool operator < ( const SubClass& other ) const {
00027 return std::lexicographical_compare(
00028 static_cast< const SubClass* >( this )->begin(), static_cast< const SubClass* >( this )->end(),
00029 other.begin(), other.end() );
00030 }
00031
00033 template < typename OtherContainer >
00034 bool equal( const OtherContainer& cont ) const {
00035 if ( static_cast< const SubClass* >( this )->size() == cont.size() ) {
00036 return std::equal(
00037 static_cast< const SubClass* >( this )->begin(),
00038 static_cast< const SubClass* >( this )->end(),
00039 cont.begin() );
00040 } else {
00041 return false;
00042 }
00043 }
00044 };
00045 }
00046
00047 #endif