Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror

Comment: Re:I don't know why this dominates the first page. (Score 1) 690

by alex_tibbles (#14649865) Attached to: Ultra-Stable Software Design in C++?
std::copy vs.

        int n;
        while (cin >> n)
                v.push_back (n);

Once you put in some braces to limit the lifetime and scope of n (your temporary), and when you factor in the implicit boolean conversion in the while clause, and the fact the code that calls 'copy' to perform a copying operation, I don't think you have much of a readability case. You have 5 lines (including enclosing braces) where std::copy needs 1.

On auto_ptr, perhaps you're forgetting that the intended use is to convert dynamic lifetime into scoped lifetime, like the built-ins. Eg. having member auto_ptrs instead of member pointers (and therefore the dtor doesn't have to call delete). Yes, I agree it is stupid to write Java style C++ new-ing every object instance, where a stack instance would work, giving you immediate, simple lifetime control (by tieing it to scope).

...there can be no public or private virtue unless the foundation of action is the practice of truth. - George Jacob Holyoake

Working...