From: Marc L. <mar...@gm...> - 2008-07-17 13:07:07
|
Thanks for the info. It would be cool to have the assignment operator integrated in the library which does the resizing. Marc On Wed, Jul 16, 2008 at 5:40 PM, Patrik Jonsson <pa...@uc...> wrote: > You are assigning the return value of foo() to bla1. Since you haven't > defined an assignment operator, this uses the default assignment, which does > not resize the destination. (Assignment is very different from copy > construction for blitz arrays.) If you compiled with -DBZ_DEBUG, you > probably get a size mismatch error. If you copy constructed bla1 it should > work. > > (Note however that wrapping the array in a struct like that will prevent > the expression template machinery from working if you define operators on > bla.) > > cheers, > > /Patrik > > On 7/16/08, Marc Levesque <mar...@gm...> wrote: > >> Hi, >> >> I would like to know why in this example the output is not "5": >> >> [CODE START] >> struct bla >> { >> Array<int,1> bou; >> }; >> >> bla foo() >> { >> bla bla1; >> >> (bla1.bou).resize(5); >> >> bla1.bou = 4,5,6,7,8; >> >> return bla1; >> } >> >> int main() >> { >> bla bla1; >> >> bla1 = foo(); >> >> cout << (bla1.bou).size() << endl; >> >> return 0; >> } >> [CODE END] >> >> instead the array (bla1.bou) in the main is not initialized, the output of >> the size shows 0. I've tested it with the <vector> library and it worked. >> What could be the reason? >> >> Thanks a lot >> >> Marc >> >> ------------------------------------------------------------------------- >> This SF.Net email is sponsored by the Moblin Your Move Developer's >> challenge >> Build the coolest Linux based applications with Moblin SDK & win great >> prizes >> Grand prize is a trip for two to an Open Source event anywhere in the >> world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> _______________________________________________ >> Blitz-support mailing list >> Bli...@li... >> https://lists.sourceforge.net/lists/listinfo/blitz-support >> >> > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Blitz-support mailing list > Bli...@li... > https://lists.sourceforge.net/lists/listinfo/blitz-support > > |