Tutorial :boost smart pointers and BOOST_NO_MEMBER_TEMPLATES



Question:

After some struggling I managed to get boost smart pointers to build for Windows CE/Mobile at warning level 4.

I found the least-resistance-way to get rid of compile errors and warnings to be

#define BOOST_NO_MEMBER_TEMPLATES  

What does it actually mean? Did I sell my soul to the devil? Will all hell break loose when I actually use the types?


Solution:1

There shouldn't be any bad effects per se, just a loss of functionality.

A member template is a member function that is a template, for example:

struct foo  {      template <typename T>      void i_am_not_supported_sometimes(void);  };  

So you don't get undefined behavior or anything, you just can't program things in a most generic manner. I think a definitive "is this bad" answer depends on exactly what it was being used for and what the work-around was.

Looking at smart_ptr, for example, the no-member-templates version literally just takes out the member templates, such as:

template<class Y>  explicit shared_ptr( Y * p ): px( p ), pn( p ) // Y must be complete  {      boost::detail::sp_enable_shared_from_this( this, p, p );  }  

And replaces Y with T, so you lose the ability for some automatic conversions.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »