Added serialization support for std::pair objects.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%404029
This commit is contained in:
Davis King 2010-12-24 23:51:44 +00:00
parent b994798e30
commit e2fa9f3248
1 changed files with 34 additions and 0 deletions

View File

@ -50,6 +50,7 @@
- std::wstring - std::wstring
- std::vector - std::vector
- std::map - std::map
- std::pair
- std::complex - std::complex
- dlib::uint64 - dlib::uint64
- dlib::int64 - dlib::int64
@ -63,6 +64,7 @@
- std::wstring - std::wstring
- std::vector - std::vector
- std::map - std::map
- std::pair
- std::complex - std::complex
- dlib::uint64 - dlib::uint64
- dlib::int64 - dlib::int64
@ -602,6 +604,38 @@ namespace dlib
} }
} }
// ----------------------------------------------------------------------------------------
template <typename first_type, typename second_type>
void serialize (
const std::pair<first_type, second_type>& item,
std::ostream& out
)
{
try
{
serialize(item.first,out);
serialize(item.second,out);
}
catch (serialization_error& e)
{ throw serialization_error(e.info + "\n while serializing object of type std::pair"); }
}
template <typename first_type, typename second_type>
void deserialize (
std::pair<first_type, second_type>& item,
std::istream& in
)
{
try
{
deserialize(item.first,in);
deserialize(item.second,in);
}
catch (serialization_error& e)
{ throw serialization_error(e.info + "\n while deserializing object of type std::pair"); }
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template <typename domain, typename range, typename compare, typename alloc> template <typename domain, typename range, typename compare, typename alloc>