diff options
-rw-r--r-- | slicer/slicer/modelPartsTypes.impl.h | 4 | ||||
-rw-r--r-- | slicer/slicer/slicer.h | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index 2121d5d..988d91e 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -14,9 +14,13 @@ template class ModelPartForRoot< IceUtil::Optional<Type> >; \ template<> ModelPartPtr ModelPart::CreateFor<Type>() { return new ModelPartType(nullptr); } \ template<> ModelPartPtr ModelPart::CreateFor(Type & s) { return new ModelPartType(&s); } \ + template<> ModelPartPtr ModelPart::CreateFor(const Type & s) { return CreateFor(const_cast<Type &>(s)); } \ template<> ModelPartPtr ModelPart::CreateFor(IceUtil::Optional<Type> & s) { return new ModelPartForOptional<ModelPartType>(&s); } \ + template<> ModelPartPtr ModelPart::CreateFor(const IceUtil::Optional<Type> & s) { return CreateFor(const_cast<IceUtil::Optional<Type> &>(s)); } \ template<> ModelPartForRootPtr ModelPart::CreateRootFor(Type & s) { return new ModelPartForRoot<Type>(&s); } \ template<> ModelPartForRootPtr ModelPart::CreateRootFor(IceUtil::Optional<Type> & s) { return new ModelPartForRoot<IceUtil::Optional<Type> >(&s); } \ + template<> ModelPartForRootPtr ModelPart::CreateRootFor(const Type & s) { return CreateRootFor(const_cast<Type &>(s)); } \ + template<> ModelPartForRootPtr ModelPart::CreateRootFor(const IceUtil::Optional<Type> & s) { return CreateRootFor(const_cast<IceUtil::Optional<Type> &>(s)); } \ #define MODELPARTFOR(Type, ModelPartType) \ CUSTOMMODELPARTFOR(Type, ModelPartType<Type>, ModelPartType<Type>) diff --git a/slicer/slicer/slicer.h b/slicer/slicer/slicer.h index ba233bb..4513ced 100644 --- a/slicer/slicer/slicer.h +++ b/slicer/slicer/slicer.h @@ -24,14 +24,14 @@ namespace Slicer { template <typename Object> void - SerializeAnyWith(Object object, SerializerPtr serializer) + SerializeAnyWith(const Object & object, SerializerPtr serializer) { - serializer->Serialize(ModelPart::CreateRootFor<Object>(object)); + serializer->Serialize(ModelPart::CreateRootFor<const Object>(object)); } template <typename Serializer, typename Object, typename ... SerializerParams> void - SerializeAny(Object object, SerializerParams && ... sp) + SerializeAny(const Object & object, SerializerParams && ... sp) { SerializeAnyWith(object, new Serializer(sp ...)); } |