Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:
| > "Lars" == Lars Gullik Bjønnes <[EMAIL PROTECTED]> writes:
|
| Lars> There is nothing "unclean" about passing a ref to vector, but a
| Lars> iterator is also nice.
|
| I mean we are building in memory a large structure just for the
| purpo
Lior Silberman <[EMAIL PROTECTED]> writes:
| > If we want to do this exception safe we have to do something like:
| >
| > build_men(Menu & m) {
| > Menu me;
| > ...; // populate me
| > m.swap(me);
| > }
| >
| > to avoid half populated objects, and objects in unknown stat
> "Lars" == Lars Gullik Bjønnes <[EMAIL PROTECTED]> writes:
Lars> There is nothing "unclean" about passing a ref to vector, but a
Lars> iterator is also nice.
I mean we are building in memory a large structure just for the
purpose of iterating over it later.
JMarc
Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:
| > "Lars" == Lars Gullik Bjønnes <[EMAIL PROTECTED]> writes:
|
| Lars> It breaks the "I allocate, I deallocate" idom.
|
| Lars> I'd rather see a Menu & passed in that case. That is the clean
| Lars> way of avoiding a copy.
|
| That's what I
> "Lars" == Lars Gullik Bjønnes <[EMAIL PROTECTED]> writes:
Lars> It breaks the "I allocate, I deallocate" idom.
Lars> I'd rather see a Menu & passed in that case. That is the clean
Lars> way of avoiding a copy.
That's what I did, but I wondered whether it was a good idea. Another
(cleaner?
On 20-Oct-2000 Lior Silberman wrote:
> Menu *tmp = menu.expand();
> ...
> delete tmp;
IMO that this is not time critical code! So I would prefer the cleaner
(and may be slower) solution!
Jürgen
--
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen Vigna
On 22 Oct 2000, Lars Gullik Bjønnes wrote:
> Baruch Even <[EMAIL PROTECTED]> writes:
>
> | On Fri, 20 Oct 2000, Lior Silberman wrote:
> |
> | > I know this _feels_ bad, but I think the most efficient implementation
> | > will be to handle the temporary ourselves:
> | >
> | > Menu* Menu::expand
Baruch Even <[EMAIL PROTECTED]> writes:
| On Fri, 20 Oct 2000, Lior Silberman wrote:
|
| > I know this _feels_ bad, but I think the most efficient implementation
| > will be to handle the temporary ourselves:
| >
| > Menu* Menu::expand (Buffer* buf)
| > {
| > Menu *resulting_menu = new
Lior Silberman <[EMAIL PROTECTED]> writes:
| I know this _feels_ bad, but I think the most efficient implementation
| will be to handle the temporary ourselves:
|
| Menu* Menu::expand (Buffer* buf)
| {
| Menu *resulting_menu = new Menu();
| ...
| // add stuff to the new m
As I said in another e-mail I didn't notice this is regarding an object
created inside the function and local to it. As usual C++ has some dark
sides to it and references may be just as evil as pointers. This is just
such a case.
I haven't looked at the questioned code so I cant offer a real sugg
> If it's a large object that has long c-tor time the best method is to
> return a const refernce as in: Menu const & expand(Buffer *) const;
You are not suggesting to return a reference to a local variable, are you?
If so, this is the most wicked suggestion ever made - including those made
on a
> Well, this is a case of the blind leading the blind... the C++ gurus will
> know, but I'm pretty sure that is referenced counted. My guess is
> that all STL containers are.
There is no requirement in the Standard.
>From what I take from /usr/include/g++-3/, strings are reference counted
for
> And is the vector class reference-counted? I guess the answer is no...
I think I have seen no reqiurement that it be not reference counted,
but I have never seen a reference counted implementation either.
> Am I the only one finding that this is stupid?
No. It is so common that it even got a
On Fri, Oct 20, 2000 at 02:47:42PM -0400, Lior Silberman wrote:
> > Indeed, if the object is local to the function this is not a solution and
> > the only option is to return a const copy of the object.
> I know this _feels_ bad, but I think the most efficient implementation
> will be to handle t
On Fri, 20 Oct 2000, Lior Silberman wrote:
> I know this _feels_ bad, but I think the most efficient implementation
> will be to handle the temporary ourselves:
>
> Menu* Menu::expand (Buffer* buf)
> {
> Menu *resulting_menu = new Menu();
> ...
> // add stuff to the new m
On Fri, 20 Oct 2000, Baruch Even wrote:
> On Fri, 20 Oct 2000, Angus Leeming wrote:
>
> > On Fri, 20 Oct 2000, Baruch Even wrote:
> > > [on the topic of returning large objects from a function]
> > >
> > > If it's a large object that has long c-tor time the best method is to
> > > return a cons
On Fri, 20 Oct 2000, Angus Leeming wrote:
> On Fri, 20 Oct 2000, Baruch Even wrote:
> > [on the topic of returning large objects from a function]
> >
> > If it's a large object that has long c-tor time the best method is to
> > return a const refernce as in: Menu const & expand(Buffer *) const;
>
On Fri, 20 Oct 2000, Baruch Even wrote:
> On 20 Oct 2000, Jean-Marc Lasgouttes wrote:
> > The method Menu::expand in Menubackend.C has the following signature:
> >
> > /// Expands some special entries of the menu
> > /** The entries with the following kind are exanded to a
> >
On 20 Oct 2000, Jean-Marc Lasgouttes wrote:
>
> The method Menu::expand in Menubackend.C has the following signature:
>
> /// Expands some special entries of the menu
> /** The entries with the following kind are exanded to a
> sequence of Command MenuItems: Lastfile
On Fri, 20 Oct 2000, Angus Leeming wrote:
> On Fri, 20 Oct 2000, Jean-Marc Lasgouttes wrote:
> > > "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:
> >
> > Angus> Things are always copied on return. That's why things like
> > Angus> reference counters were invented; the main class holds j
On Fri, 20 Oct 2000, Jean-Marc Lasgouttes wrote:
> > "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:
>
> Angus> Things are always copied on return. That's why things like
> Angus> reference counters were invented; the main class holds just a
> Angus> pointer that points to the data struct
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:
Angus> Things are always copied on return. That's why things like
Angus> reference counters were invented; the main class holds just a
Angus> pointer that points to the data structure. Only the pointer is
Angus> then copied on return.
An
On Fri, 20 Oct 2000, Jean-Marc Lasgouttes wrote:
> The method Menu::expand in Menubackend.C has the following signature:
>
> /// Expands some special entries of the menu
> /** The entries with the following kind are exanded to a
> sequence of Command MenuItems: Lastfile
The method Menu::expand in Menubackend.C has the following signature:
/// Expands some special entries of the menu
/** The entries with the following kind are exanded to a
sequence of Command MenuItems: Lastfiles, Documents,
ViewFormats, ExportFormats, Upd
24 matches
Mail list logo