A: 

It depends how often you need to do that and how specifically. There is such a thing as a transforming iterator, and you could make one such that

vcopy( deref_iter( v.begin() ), deref_iter( v.end() ) );

would do what you want. However, that's not that much easier than what you have, and a straightforward function taking a pointer-vector and returning an object-vector would be easier to implement and to use.

Potatoswatter
+3  A: 

You can transform() the container:

struct deref { // NO! I don't want to derive, LEAVE ME ALONE!
    template<typename P>
    const P& operator()(const P* const p) const { return *p; }
};

// ...
    vector<Line*> orig; // assume full ...
    vector<Line> cp(orig.size());
    transform(orig.begin(), orig.end(), cp.begin(), deref());
wilhelmtell
This looks much better.Thanks, i was looking for something like this.
Tom
should be transform (..., ....,...., deref<Line>()) ?
Tom
If it's expensive to create a default `Line` object then don't pass `orig.size()` to the ctor of `cp`. Rather, construct `cp` empty and then call `cp.reserve(orig.size())`. This will result in an extra line of code but will avoid initializing each `Line` object (through the default ctor of `Line`, supposedly an expensive operation) in `cp`.
wilhelmtell
@Tom no, `deref` isn't a template. It's a regular struct that has a template member function. The `transform()` algorithm doesn't need to instantiate the template `deref::operator()()` (i.e. It Just Works(tm)) because the compiler can deduce the template arguments through the function's arguments.
wilhelmtell
@wilhelmtell Thanks for clearing that up
Tom
@Tom the reason I didn't derive from `std::unary_function` (apart from the verbosity of this ritual, which I don't like) is that I'd then have to template `deref` in order to pass the template arguments which `operator()()` uses to `std::unary_function()`. Then, when you use `deref` you'd have to instantiate the template (which is the most annoying side-effect!) as you did in your comment above. All this work, for a couple of typedefs, isn't worth it IMHO.
wilhelmtell