Added an implicit conversion to unsigned long for extracting the checksum

of crc32 objects.
This commit is contained in:
Davis King 2015-01-31 11:25:16 -05:00
parent ff451abbdf
commit cd9c5709d4
3 changed files with 11 additions and 1 deletions

View File

@ -55,6 +55,9 @@ namespace dlib
const std::vector<char>& item
);
inline operator unsigned long (
) const { return get_checksum(); }
inline unsigned long get_checksum (
) const;

View File

@ -101,6 +101,13 @@ namespace dlib
- returns the current checksum
!*/
operator unsigned long (
) const;
/*!
ensures
- returns get_checksum()
!*/
void swap (
crc32& item
);

View File

@ -65,7 +65,7 @@ namespace
std::vector<char> buf;
for (int i = 0; i < 4000; ++i)
buf.push_back(i);
DLIB_TEST(crc32(buf).get_checksum() == 492662731);
DLIB_TEST(crc32(buf) == 492662731);
}
} a;