Re: gtkmm and C++0x



Hi,

Am Mittwoch, den 31.03.2010, 12:02 +0200 schrieb Oscar Lazzarino:
> On Wed, Mar 31, 2010 at 11:31 AM, michi7x7 <mailing-lists michi7x7 de> wrote:
> >
> > I really don't like "auto". C++ is a type-oriented language, auto will just
> > cause problems with highlighters and will most of the time just be used to
> > skip the real type.
> 
> Me neither. It seems to me that "auto" is the sort of feature that
> should be implemented in an IDE, just to make you type faster. Having
> it in the language looks just like another horrible hack in the
> already pleagued C++

What?  Believe me, it can drastically improve the readability of code
like this:

  const Glib::RefPtr<Rsvg::Handle>
    svg = Rsvg::Handle::create_from_file(Util::locate_data_file(basename));

  Rsvg::DimensionData dim;
  svg->get_dimensions(dim);

  const Cairo::RefPtr<Cairo::ImageSurface>
    surface = Cairo::ImageSurface::create(format, dim.width, dim.height);

  svg->render(Cairo::Context::create(surface));
  svg->close();

This is real code from an application of mine.  I really hate breaking
variable initializations into two lines, but there was no choice...

Smart pointers returned by create() methods are the number one use case
of "auto", and we are going to have more of these in gtkmm 3.

--Daniel




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]