POV-Ray : Newsgroups : povray.off-topic : Error mesage : Re: Error mesage Server Time
7 Sep 2024 19:14:05 EDT (-0400)
  Re: Error mesage  
From: Ben Chambers
Date: 4 May 2008 03:40:29
Message: <481d686d@news.povray.org>
Darren New wrote:
> Warp wrote:
>> MyType value = something;
>> std::cout << "The value is: " << value << "\n";
> 
> Here's something I've been wondering about that. Say you have your own 
> type, and you want a set of flags like hex/oct/decimal or setfill or 
> something like that. I.e., you want to be able to say
> 
> std::cout << prettyprintindent(4) << myvalue << "\n";
> 
> Where does the "4" there get stored? And how can you make it so that 
> (say) passing -1 puts back what it was before the previous call for the 
> same stream? It would seem that you'd need some sort of data structure 
> mapping streams to pretty print indent levels, yes? And no automated way 
> of cleaning that up with a destructor?
> 
> What am I missing here?

I believe you would create a separate class which inherits from OStream, 
and give it a data member to store the 4 in.  You would then define the 
function prettyprintindent(int) to return your subclass.  Since it 
inherits, it can still be used like a regular OStream.

...Chambers


Post a reply to this message

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