Commit 97300eb3 authored by Davis King's avatar Davis King

Moved the definition of the serialization friend functions out of the

vector_normalizer class because apparently not defining them this way prevents
someone from being able to invoke them by saying dlib::serialize().

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403391
parent 7351113c
...@@ -232,34 +232,17 @@ namespace dlib ...@@ -232,34 +232,17 @@ namespace dlib
temp_out.swap(item.temp_out); temp_out.swap(item.temp_out);
} }
template <typename mt>
friend void deserialize ( friend void deserialize (
vector_normalizer& item, vector_normalizer<mt>& item,
std::istream& in std::istream& in
) );
{
deserialize(item.m, in);
deserialize(item.sd, in);
// Keep deserializing the pca matrix for backwards compatibility.
matrix<double> pca;
deserialize(pca, in);
if (pca.size() != 0)
throw serialization_error("Error deserializing object of type vector_normalizer\n"
"It looks like a serialized vector_normalizer_pca was accidentally deserialized into \n"
"a vector_normalizer object.");
}
template <typename mt>
friend void serialize ( friend void serialize (
const vector_normalizer& item, const vector_normalizer<mt>& item,
std::ostream& out std::ostream& out
) );
{
serialize(item.m, out);
serialize(item.sd, out);
// Keep serializing the pca matrix for backwards compatibility.
matrix<double> pca;
serialize(pca, out);
}
private: private:
...@@ -272,6 +255,8 @@ namespace dlib ...@@ -272,6 +255,8 @@ namespace dlib
mutable matrix_type temp_out; mutable matrix_type temp_out;
}; };
// ----------------------------------------------------------------------------------------
template < template <
typename matrix_type typename matrix_type
> >
...@@ -280,6 +265,47 @@ namespace dlib ...@@ -280,6 +265,47 @@ namespace dlib
vector_normalizer<matrix_type>& b vector_normalizer<matrix_type>& b
) { a.swap(b); } ) { a.swap(b); }
// ----------------------------------------------------------------------------------------
template <
typename matrix_type
>
void deserialize (
vector_normalizer<matrix_type>& item,
std::istream& in
)
{
deserialize(item.m, in);
deserialize(item.sd, in);
// Keep deserializing the pca matrix for backwards compatibility.
matrix<double> pca;
deserialize(pca, in);
if (pca.size() != 0)
throw serialization_error("Error deserializing object of type vector_normalizer\n"
"It looks like a serialized vector_normalizer_pca was accidentally deserialized into \n"
"a vector_normalizer object.");
}
// ----------------------------------------------------------------------------------------
template <
typename matrix_type
>
void serialize (
const vector_normalizer<matrix_type>& item,
std::ostream& out
)
{
serialize(item.m, out);
serialize(item.sd, out);
// Keep serializing the pca matrix for backwards compatibility.
matrix<double> pca;
serialize(pca, out);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template < template <
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment