POV-Ray : Newsgroups : povray.off-topic : Coding in the mainstream : Re: Coding in the mainstream Server Time
29 Jul 2024 04:27:31 EDT (-0400)
  Re: Coding in the mainstream  
From: clipka
Date: 7 Jun 2012 10:04:46
Message: <4fd0b4fe$1@news.povray.org>
Am 07.06.2012 14:12, schrieb Invisible:
>>> ...or rather, to /use/ run-time polymorphism, you need to do manual
>>> memory management, and manual memory management is infamously hard.
>>
>> ... or use Boost's (or C++11's) smart pointers.
>
> Wouldn't that mean I'd have to somehow install Boost and tell the IDE
> where the hell to find it?

As for the smart pointers, actually no - the smart pointers magic is all 
header files, so you just need to copy those to a suitable subdirectory 
of your own project and add that directory to the list of preprocessor 
include directories.

And if you use VS 2010 (or later), it's even as simple as activating the 
C++11 (aka "C++0x") features. The C++11 smart pointers are actually 
identical to the boost smart pointers, except that they live in a 
different namespace.


The only caveat not explicitly warned about in the smart pointers 
documentation is that the smart pointer assignment operator ("=") is 
implemented as a swap operation, so to create another smart pointer 
referencing the same object you need to explicitly make use of the smart 
pointers' copy constructor:

   typedef shared_ptr<FooType> FooPtr; // really helps

   FooPtr A(new FooType());
   FooPtr B;
   B = FooPtr(A); // NOT just "B = A;"

or just

   FooPtr B(A);


shared_ptr is complemented with weak_ptr.


>> Sane IDEs don't use the Win32 C API for GUI (or for most anything else
>> for that matter); instead, they come with a fancy object-oriented
>> framework of libraries hiding all the uglies from you. (MFC used to be
>> the thing for MS Visual C++; they have something new by now, same thing
>> they use for C#.)
>
> Interesting. Is /that/ why I keep having to install the "VisualStudio
> C++ runtime" every few weeks?

Not really. That's just the /general/ habit of dynamically-linked 
software. Usually the VS C++ Runtime should simply discover that the VS 
C++ Runtime is already installed though.


> I'm told back in the days of the old mainframes, /all/ user output was
> through a printer. It literally didn't /have/ a video display /at all/.
> So the PRINT command in BASIC? It used to actually *print* stuff! :-D

Yup. Heard that, too. Haven't ever seen any proof with my own eyes 
though, so it must be urban legend :-P


Post a reply to this message

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