Boost logo

Boost :

From: JOAQUIN M. LOPEZ MUÑOZ (joaquin_at_[hidden])
Date: 2008-09-02 16:57:44


Hi Christian,
________________________________________
De: boost-bounces_at_[hidden] [boost-bounces_at_[hidden]] En nombre de Christian Larsen [contact_at_[hidden]]
Enviado el: martes, 02 de septiembre de 2008 21:55
Para: boost_at_[hidden]
Asunto: Re: [boost] [flyweight] post-review version available
>
> JOAQUIN M. LOPEZ MUÑOZ skrev:
> > I've tried to address most of the suggestions and comments
> > raised during the review. The two most important changes
> > are:
> > 1. Alberto Barbati's insightful review has led to the
> > introduction of so-called key-value flyweights
> > (http://tinyurl.com/5mnwjp ).
> > [...]
>
> I just read the start of the tutorial, and I like what I see. I haven't
> tried using the library yet, though. But I have a question regarding the
> last assignment in the "Key extractors" section.[...]
>
> struct texture_filename_extractor {...};
> flyweight<key_value<std::string,texture,
> texture_filename_extractor> > fw;
> ...
> fw=texture("sand.texture"); // OK now
>
> I get it that this is to show the need for key extractors, but isn't it
> possible to also assign without creating already existing textures?[...]
> Wouldn't the optimal way to perform this assignment be something like:
>
> typedef flyweight<key_value<std::string,texture,
> texture_filename_extractor> > texture_fw;
> texture_fw fw;
> ...
> fw=texture_fw("sand.texture"); // No unnecessary construction?

Yep, you're absolutely correct. The suboptimal assignment 'fw=
texture("sand.texture")' is used just to show where key extractors are
needed.

> If this is the case, I think it would improve the documentation if a
> note was added after the example that this is the best way to do an
> assignment from a "new" texture. Please correct me if I'm wrong.

Yes, the docs can be misleading here. I'll either clarify the point in
the docs or else rewrite the snippet in a way that makes it impossible
to optimize the expression, something like

  void foo(const texture& x)
  {
    flyweight<key_value<std::string,texture> > fw(x);
  }

Thanks for your feedback,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk