Boost logo

Boost Users :

Subject: Re: [Boost-users] [program_options] Clearing variables_map
From: Vladimir Prus (vladimir_at_[hidden])
Date: 2010-04-09 02:38:14


Jason Reich wrote:

> Hello,
>
> I'm using boost::program_options to parse an command line within a running
> program (i.e. not just at startup, whenever a new command comes in), and am
> trying to avoid memory deallocation/reallocation. Is there any way reuse a
> variable_map that has already had options stored into it?
>
> If I use the std::map<>.clear() it seems to clear the stored values, but
> when I next try to parse, the results are still empty. I think this is
> happening because the m_final variable (as far as I can understand).
>
> Is there some reason why the variables_map can't be cleared and reused?

Why do you think that calling clear() and using the same variables_map again
will cut down on memory deallocation/reallocation? It does not seem obvious
to me that it will.

- Volodya


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net