POV-Ray : Newsgroups : povray.off-topic : You lose some... : Re: Some code Server Time
7 Sep 2024 03:23:58 EDT (-0400)
  Re: Some code  
From: Orchid XP v8
Date: 5 Oct 2008 06:08:17
Message: <48e89211$1@news.povray.org>
Slime wrote:
>> const Tree& build_tree(std::vector<SymbolInfo> info)
>> {
>>   std::vector<Tree> trees;
>>
> ...
>>   return trees[0];
>> }
> 
> You are returning a reference to a local variable.

DOH!! >_<

Yeah, that can't be good...

> You might also want to assert( trees.size() > 0 ) to make sure the function 
> worked properly and there's something there to return.

The loop right above that is while(trees.size() > 1). Each pass of the 
loop removes two trees and inserts one tree.

> That's the only actual problem I see. Otherwise I'm a little worried, 
> efficiency-wise, about how many vectors you're copying around, but that may 
> not be worth worrying about at this stage.

Yeah, that too...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.