[CMake] Re: Changing MD -> MT (+patch for free toolkit)

Mathieu Malaterre mathieu.malaterre at gmail.com
Tue Feb 19 03:11:45 EST 2008


On Feb 19, 2008 5:43 AM, Gonzalo Garramuño <ggarra at advancedsl.com.ar> wrote:
> Mathieu Malaterre wrote:
> > Ok this was yet-another-weird-dll thingy, one cannot do:
> >
> > class GDCM_EXPORT String : std::string { ... }
> >
>
> Please, learn a little bit more about C++.

Oh thank you ! I'll take your advice right away, mister expert. So
could you please let me know why *in my particular case* this is
wrong:
1. I did not add any data member
2. I did not overload the dstor

Please do not copy some random comment found on the internet and
instead comment on my particular implementation with the following 1
and 2 restrictions. Thanks.

> You should never inherit
> from std::string (or any std::* container) as their functions or
> destructor are not virtual.  That can (and will) spell disaster for
> anyone else trying to use your library/functions or even for yourself if
> you go through pointers or references.

I know exactly what I was doing, and I still need a 'string-like'
class with an overloaded operator:

  inline std::istream& operator>>(std::istream &is, MyString &ms);

Having std::string as member rather than inherited would means *tons*
of duplicated code, and in my particular case inheriting was perfectly
safe.

Je ne vous salut pas monsieur,
-- 
Mathieu


More information about the CMake mailing list