>> On Mon, Mar 9, 2009 at 1:03 PM, Kirk, Benjamin (JSC-EG311)
>> <[email protected]> wrote:
>>> 
>>> OMG, just derive from std::map<>, implement a proper descructor, and be done
>>> with it!!! ;-)
>> 
>> I know you are trying to get me to bite... OK it worked.
> 
> Really?  I could have sworn he was making fun of my mapvector.h, with
> an offhand "who would be nuts enough to derive from std::map?" crack.
> :-)
> 
>> std containers don't have virtual destructors so you can't do that!
> 
> Actually, you can - you just need to make sure that the derived class
> *only* gets destructed from a pointer-to-derived, never from a
> pointer-to-base.  Dangerous stuff.
> 
> (and not applicable to mapvector, I might add, which doesn't need a
> special destructor)


HA! busted.  Actually, it is the PeriodicBoundaries class, which has an
implemented destructor, albeit empty.  Also, an amusing comment ;-)

/** 
 * The constraint matrix storage format.
 * We're using a class instead of a typedef to allow forward
 * declarations and future flexibility.  Is there some issue with
 * deriving from standard containers, i.e. don't do it because they
 * don't have virtual destructors?
 */
class PeriodicBoundaries : public std::map<unsigned int, PeriodicBoundary>
{
public:
  PeriodicBoundary *boundary(unsigned int id);

  PeriodicBoundaries() {}

  ~PeriodicBoundaries();

  // The periodic neighbor of \p e in direction \p side, if it
  // exists.  NULL otherwise
  const Elem *neighbor(unsigned int boundary_id, const MeshBase &mesh, const
Elem *e, unsigned int side);

private:
};


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Libmesh-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to