Boost logo

Boost :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2008-01-27 18:12:13


----- Mensaje original -----
De: "vicente.botet" <vicente.botet_at_[hidden]>
Fecha: Domingo, Enero 27, 2008 10:42 pm
Asunto: Re: [boost] [review] Review of Flyweight library started
January21 and still running!: static flyweights
Para: boost_at_[hidden]

> Hi again
>
> I surelly mis something from the standard C++. I'm asking what
> happens if we declare static flyweight as
>
> static flyweight<std::string> static_var1("safe_or_unsafe1");
> static flyweight<std::string>::initializer fwinit;
> static flyweight<std::string> static_var2("safe_or_unsafe2");
>
> Which is the destruction order between static_var1, static_var2
> and the static holder of flyweight<std::string>?

The destruction order is the correct one:

  static_var2
  static_var1
  holder

I guess you're being misled by the definition of the initializer
fwinit: Its presence forces holder initialization *unless* this
initialization has already taken place, which is the case here,
due to the previous definition of static_var1. So, your code
is entirely equivalent to

  static flyweight<std::string> static_var1("safe_or_unsafe1");
  static flyweight<std::string> static_var2("safe_or_unsafe2");

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