Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #10183

Re: dynamic vector as function parameter

Newsgroups comp.lang.c++
Subject Re: dynamic vector as function parameter
From Paavo Helde <myfirstname@osa.pri.ee>
References <j4t9oo$vj0$1@gregory.bnet.hr> <j4te9t$ji6$1@dont-email.me> <j4tkme$io4$1@gregory.bnet.hr>
Organization PKI
Message-ID <Xns9F624BFDFCCCmyfirstnameosapriee@216.196.109.131> (permalink)
Date 2011-09-15 16:28 -0500

Show all headers | View raw


"A" <a@a.a> wrote in news:j4tkme$io4$1@gregory.bnet.hr:

>> There are no drawbacks besides performance, I guess.  Which ones are
>> *you* thinking of?  You're probably aware of the overhead you're
>> going to incur by creating the vector of only one element.  Can't you
>> just call function DEF directly?
> 
> DEF function is just a dumb example it is more complex than this. Not
> to be overanalized :)
> 
> My main concern here are memory leaks and to check with experts here
> if this is the way to pass it when I want to avoid creating a
> variable. 

Yes, that's OK. This is creating a temporary object which will be destroyed 
automatically in the end of the full expression (semicolon here). In 
general, it is hard to produce a memory leak in C++ without a 'new' or 
'malloc'. 

cheers
Paavo

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

dynamic vector as function parameter "A" <a@a.a> - 2011-09-15 18:38 +0200
  Re: dynamic vector as function parameter Victor Bazarov <v.bazarov@comcast.invalid> - 2011-09-15 13:57 -0400
    Re: dynamic vector as function parameter "A" <a@a.a> - 2011-09-15 21:45 +0200
      Re: dynamic vector as function parameter Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-15 16:28 -0500
        Re: dynamic vector as function parameter "A" <a@a.a> - 2011-09-16 13:49 +0200
      Re: dynamic vector as function parameter Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-09-17 23:48 +0000
        Re: dynamic vector as function parameter "A" <a@a.a> - 2011-09-18 16:37 +0200
          Re: dynamic vector as function parameter Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-09-18 17:37 +0000

csiph-web