Menu

Change to ScopeGuard - allow array deletion

Pandion
2007-04-26
2013-04-08
  • Pandion

    Pandion - 2007-04-26

    Hi,

    Would it be possible to add a funtion to the scopeguard header, as proposed here by Andrei:
    <<http://leafe.com/archives/showMsg/106096>>

    inline delete_array( void* p )
    {
    delete [] p;
    }

    This would allow one to do:
    char *c = new char[110];

    Loki::ScopeGuard = Loki::MakeGuard(delete_array, c);

    Regards,
    Dieter Rosch

     
    • Richard Sposato

      Richard Sposato - 2007-04-27

      Hi Dieter,

      Yes, it is possible, but ... I don't see a compelling reason to do so.  The delete_array function has a very specific purpose, and adding that would beg the questions of "Why add that, and not other inline functions which also have very specific purposes?  Why not also add inline functions to close ports, close files, etc...?"

      Also, what if somebody wanted to use delete_array (or any similar function), and not want to use ScopeGuard.  Why should that person be forced to include ScopeGuard.h to get a simple inline function which is not directly related to ScopeGuard?

      I don't recommend adding it.

      Sincerely,

      Rich

       
      • Peter Kuemmel

        Peter Kuemmel - 2007-05-17

        For new features please open a new request in the tracker

        https://sourceforge.net/tracker/?atid=396647&group_id=29557&func=browse

        Otherwise it could get lost in the depth of the forum.

        Peter

         
    • Peter Kuemmel

      Peter Kuemmel - 2007-05-17

      For new features please open a new request in the tracker

      https://sourceforge.net/tracker/?atid=396647&group_id=29557&func=browse

      Otherwise it could get lost in the depth of the forum.

      Peter

       
    • Peter Kuemmel

      Peter Kuemmel - 2007-07-01
       

Log in to post a comment.