AutoPtr
Re: AutoPtr
Thanks for posting the FAQ. Curiously browsed over it and found out that I'm using the ## feature wrong (the other case besides compile directives where macros are still necessary). Never knew it needs another macro to wrap that...
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: AutoPtr
disagree, and anyway the FAQS example shows why a macro doesn't work and why you should not use macros, but don't say anything about what I did (so just simple code expansion for save typing) wich is done also in other libraries and suggested in many books (books that usually people reccomends if you want book names in PM just tell so that you can verify. Most of them are free e-books so you can check yourself without having to buy them) ^^ and makes code more readable and clean:randomMesh wrote: No. Clean and maintainable C++ code doesn't use any macros.
Please do yourself a favour and read the C++ FAQ
few examples:
http://sparkengine.svn.sourceforge.net/ ... iew=markup
http://poco.svn.sourceforge.net/viewvc/ ... iew=markup
What I do (probably wrong) is not to read theory but is to learn from what others did before and from my mistakes, (started with Irrlicht few years ago) and AFTER that I read theory and compare with example's from others. If I see examples of when and where macros are usefull, why avoiding them in similiar situations? (ok take my snippet as bad example if you want but reinventing the wheel is always usefull, at least for learning. )
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Re: AutoPtr
They did both add prefixes to reduce the chance of name-collisions.
Also still check the FAQ, it will at least show you (when clicking through the evil examples) how to make your macro at least safer to use.
Also still check the FAQ, it will at least show you (when clicking through the evil examples) how to make your macro at least safer to use.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: AutoPtr
I suggest just using boost headers and intrusive_ptr. All you need to do is add the following to your main header file:
Makes it pretty easy doesn't it? Just remember that if you store irrlicht objects in an intrusive_ptr created from functions like createXXXX, you need to call drop() once to make the count correct, because the intrusive_ptr will grab it.
Code: Select all
#include <boost/intrusive_ptr.hpp>
namespace boost
{
static inline void intrusive_ptr_add_ref(irr::IReferenceCounted *p)
{
p->grab();
}
static inline void intrusive_ptr_release(irr::IReferenceCounted *p)
{
p->drop();
}
};