The Assignment Operator Revisited by Richard Gillam Advisory Software Engineer, Text & International IBM Center for Java Technology–Silicon Valley If you think you know it all in the C++ world, it must mean you’re not talking to your colleagues very much. If I had any pretensions to knowing it all when I wrote my assignment-operator article (" The Anatomy of the Assignment Operator ," C++ Report, Nov/Dec 1997), they didn’t last long afterwards. The assignment-operator article drew a huge response, with a lot of people sending me corrections and disagreements of various kinds. The issues have been mounting up, so I thought maybe a follow-on article to discuss the issues would be appropriate.
It is not uncommon to see different pieces of code that have basically the same structure, but contain variation in the details. Ideally we would be able to reuse the structure, and factor out the variations. In 'C' this might be done by using function pointers, as in the C Standard Library qsort function or in C++ by using virtual functions. Unfortunately this differed to runtime what is known at compile time, and became with a runtime overhead. C++ introduces generic programming, with template s, eliminating the need for runtime binding, but at first glance this still looks like a compromise, after all, the same algorithm will not work optimally with every data structure. Sorting a linked list is different to sorting an array.
References The following paper is a good introduction to some of the issues of writing robust generic components: D. Abrahams: ``Exception Safety in Generic Components'' , originally published in M.
Leaking memory is probably the single most painful aspect of native code – its the reason managed was ever born. At work, our code routes ‘new’ calls through _aligned_malloc_dbg . This CRT API, along with cousins like _malloc_dbg and _calloc_dbg , takes extra parameters containing a file name and line number, and so enables the CRT to report the exact location of an unreleased allocation upon process termination:
This feature is well documented , but yet from what I see – doesn’t get the usage it deserves. Here’s a quick, beginner-oriented rehash – if only to refer my teammates. Problem and Immediate Solution
C++ FQA Lite: Main page This is C++ FQA Lite. C++ is a general-purpose programming language, not necessarily suitable for your special purpose.
Recent changes - 11 changed FAQs. In a list , or in a chain , or here: [4.1] , [4.2] , [6.3] , [6.12] , [10.3] , [15.22] , [27.15] , [35.13] , [35.14] , [35.15] , [39.6] . Translated into 16 languages. English , Belorussian / Minsk , Bosnian / Serbian / Croatian , Bulgarian , Chinese (GB, Mainland) , Chinese (Big5, Taiwan) , French , German , Greek , Korean , Polish , Portuguese , Romanian , Russian , Spanish , Turkish .
What is the difference between vector and deque? When should you use each one? And how can you properly shrink such containers when you no longer need their full capacity? These answers and more, as we consider news updates from the standards front. Problem JG Question
Also see Part 2 and Part 3 . Programming languages typically make a distinction between normal program actions and erroneous actions. For Turing-complete languages we cannot reliably decide offline whether a program has the potential to execute an error; we have to just run it and see. In a safe programming language, errors are trapped as they happen.