Does this really work? You make a copy of the original object that will be returned as part of the result and then you change that copy. That will not affect the original object. You should use an "iterator_array" instead of a "const_iterator_array" and then you should be able to directly modify "profileiter".