Hello,

Nordlöw <per.nord...@gmail.com> writes:

> Han anybody written any snippet (template i guess) that realizes memdup
> () using the operator new. Suggested name: new_duplicate.

are you looking for something like this?

template <class T>
T* new_duplicate(const T *const value)
{
  if (!value) {
    return 0;
  } else {
    return new T(*value);
  }
}


But:
Without the check for null, I do not see any advance calling this
function directly compared to a direct call of the copy constructor.

Greetings from Hamburg
Sebastian Waschik



_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to