POV-Ray : Newsgroups : povray.off-topic : Smart little programming tricks, where to find ? : Re: Smart little programming tricks, where to find ? Server Time
11 Oct 2024 01:23:54 EDT (-0400)
  Re: Smart little programming tricks, where to find ?  
From: Vincent Le Chevalier
Date: 19 Mar 2008 18:08:32
Message: <47e19cf0@news.povray.org>
Warp a écrit :
>   Ok, if you want a harder puzzle, here's a curious quirk about C++ (not
> related to memory leaks, though):
> 
> a) This doesn't compile. Without using a compiler, can you tell where
>    is the problem and what is the exact reason why it doesn't compile?
> 
> b) If you can't see it, try it with a compiler. I bet you still can't see
>    the problem... :P
> 
> c) In the erroneous line, can you tell me exactly what that line means?
> 
> d) What is the easiest way (smallest amount of extra code) to make it
>    compile and work as expected?
> 

Well I have no real idea of what goes wrong but I have a proposition for 
d) :-) Down below...

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Replacing
     std::map<A, int, Comp> theMap(Comp());
with
     Comp c; std::map<A, int, Comp> theMap(c);
seems to do the trick as far as I figure. I don't like those anonymous 
objects anyhow ;-)

A trouble with references or some such ? That prevents the full 
instanciation of the map template ?

-- 
Vincent


Post a reply to this message

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