Re: writing robust software?
On 14 Sep., 00:56, Frank Buss <f...@frank-buss.de> wrote:
There are some general rules how to write robust software, e.g. on this
page:
http://jwinblad.com/resources/robustsw.php
[..]
Especially with C++0x there should be some nice solutions
for bugs I do often:
- array out of bounds errors
Use std::array instead of C arrays and ask your
favorite vendor whether the implementation has
debugging iterators.
- memory leaks, dangling pointers etc.
What about the combination of shared_ptr and
weak_ptr?
Some array out of bounds errors could be avoided with functional
programming styles. E.g. the Qt metacompiler has a "foreach" keyword. Wit=
h
C++ templates and for_each, or iterators, you can do something similar, b=
ut
the syntax is really cumbersome, so usually I do a normal for-loop. Maybe
C++0x helps? But how could I detect array out of bounds errors?
C++Ox provides the new range-based for statement
as in:
std::vector<T> v = ..;
for (const auto& e : v) {
//
}
Several implementations provide debugging iterators
that validate during runtime out-of-bound situations.
HTH & Greetings from Bremen,
Daniel Kr=FCgler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]