Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
For the out-of-band Slashdot experience (mostly headlines), follow us on Twitter, or Facebook. ×

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

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).

The computer is to the information industry roughly what the central power station is to the electrical industry. -- Peter Drucker

Working...