diff --git a/jasmin/core/function.h b/jasmin/core/function.h index e277f9f..de632bd 100644 --- a/jasmin/core/function.h +++ b/jasmin/core/function.h @@ -35,25 +35,25 @@ template <> struct Function : internal::FunctionBase { template S> friend nth::io::serializer_result_type NthSerialize(S &s, - Function<> const *f) { + Function const *f) { return nth::io::serialize(s, s.context(nth::type).get(f)); } template D> friend nth::io::deserializer_result_type NthDeserialize(D &d, - Function<> *&fn) { - return nth::io::deserialize(d, const_cast const *&>(fn)); + Function *&fn) { + return nth::io::deserialize(d, const_cast(fn)); } template D> friend nth::io::deserializer_result_type NthDeserialize( - D &d, Function<> const *&fn) { + D &d, Function const *&fn) { using result_type = nth::io::deserializer_result_type; FunctionIdentifier id; result_type result = nth::io::deserialize(d, id); if (not result) { return result; } auto ®istry = d.context(nth::type); - fn = registry[id]; + fn = registry[id]; return result_type(true); } @@ -134,9 +134,11 @@ struct Function : Function<> { return result_type(s.write_at(*c, nth::bytes(distance))); } - template D> - friend nth::io::serializer_result_type NthSerialize(D &, - Function<> const *); + template S> + friend nth::io::serializer_result_type NthSerialize(S &s, + Function const *f) { + return nth::io::serialize(s, static_cast const *>(f)); + } template D> friend nth::io::deserializer_result_type NthDeserialize(D &d, @@ -179,11 +181,20 @@ struct Function : Function<> { } template D> - friend nth::io::deserializer_result_type NthDeserialize(D &, Function<> *); + friend nth::io::deserializer_result_type NthDeserialize(D &d, + Function *&f) { + Function<> *fn; + auto result = nth::io::deserialize(d, fn); + if (not result) { return result; } + f = static_cast(fn); + return result; + } template D> friend nth::io::deserializer_result_type NthDeserialize( - D &, Function<> const *); + D &d, Function const *f) { + return nth::io::deserialize(d, static_cast const *&>(f)); + } }; namespace internal {