From e2231ca0f44adc8f15d65482817f56d2979e1ac7 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 24 Jan 2011 15:53:34 -0800 Subject: [PATCH] Move the factory function to the decoder declarator --- src/streamdec.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/streamdec.cpp b/src/streamdec.cpp index 80c56d5..a2a0327 100644 --- a/src/streamdec.cpp +++ b/src/streamdec.cpp @@ -45,14 +45,6 @@ struct Decoder { { return AddList(NULL); } protected: - template - static std::auto_ptr Factory(std::istream *file) - { - std::auto_ptr ret(new T(file)); - if(ret->IsValid()) return ret; - return std::auto_ptr(); - } - static ListType& AddList(FactoryType func) { static ListType FuncList; @@ -66,11 +58,19 @@ protected: }; template struct DecoderDecl : public Decoder { - DecoderDecl() { AddList(Factory); } + DecoderDecl() { AddList(Factory); } ~DecoderDecl() { ListType &list = AddList(NULL); - list.erase(std::find(list.begin(), list.end(), Factory)); + list.erase(std::find(list.begin(), list.end(), Factory)); + } + +private: + static std::auto_ptr Factory(std::istream *file) + { + std::auto_ptr ret(new T(file)); + if(ret->IsValid()) return ret; + return std::auto_ptr(); } }; -- 2.11.4.GIT