mirror of https://github.com/davisking/dlib.git
Added serialization support for std::pair objects.
--HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%404029
This commit is contained in:
parent
b994798e30
commit
e2fa9f3248
|
@ -50,6 +50,7 @@
|
|||
- std::wstring
|
||||
- std::vector
|
||||
- std::map
|
||||
- std::pair
|
||||
- std::complex
|
||||
- dlib::uint64
|
||||
- dlib::int64
|
||||
|
@ -63,6 +64,7 @@
|
|||
- std::wstring
|
||||
- std::vector
|
||||
- std::map
|
||||
- std::pair
|
||||
- std::complex
|
||||
- dlib::uint64
|
||||
- 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>
|
||||
|
|
Loading…
Reference in New Issue