Do you mean "I am at an impasse"? On 28 May 2015 00:29, "Hotmail (ArbolOne)" <arbol...@hotmail.ca> wrote:
> I am in a in-path. I wrote a class that handles exceptions, > namespace abc{ > class Exception{...}; // This is my very large Exception class > } > > The way I'd like to use this class is by creating a smart pointer to it in > each newly created class, i.e. > namespace abc{ > class m_class0000001{ > private: > std::shared_ptr<abc::Exception> apex; > public: > m_class(){apex.reset(new abc::Exception());} > m_method(){ > apex->setException(...); > throw apex; > } > }; > } > auto apex = std::make_shared<abc::Exception>(); > int main() { > try { > auto obj = std::make_shared<abc::m_class0000001>(); > obj->m_method(); > } catch(std::shared_ptr<abc::Exception>& e) { > e->DisplaySomething(); > } > return 0; > } > But this can be very expensive, since this possibly-very-large class will > be > created in thousands of classes. > On the other hand, I could create the object when or where the exception > occurs, like this: > namespace abc{ > class m_class0000001{ > private: > ... > public: > m_class(){} > m_method(){ > ... /* I don't even know if this is possible */ > auto obj = std::make_shared<abc::Exception>(); > apex->setException(...); > throw apex; > } > }; > } > This creates another problem, what if the exception is std::mem_alloc, I > would ran out of memory, thus I wouldn't be able to create another object. > > I know, I know, this is not a C++ question, but, as I said, I am in a > in-path, I don't know what to do in this case. > Any help would be most appreciated. > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Mingw-w64-public mailing list > Mingw-w64-public@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public >
------------------------------------------------------------------------------
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public