🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1851

Is this a legal template function? BC says yes. MSVC says no.

#1851
From: Rob Chambers
Date: Sat, 26 Aug 1995 08:18
36 lines
1484 bytes
Hi! I've looked all through the ARM and I can't find a reason why I
shouldn't be able to do this:

11: template<class T>
12: inline void DeleteArray(T* &pat)
13:     {
14:     if (NULL != pat)
15:         {
16:        delete [] pat;
17:         pat = NULL;
18:         }
19:     }

and call it like this:

30:        double *pad = new double[10];
31:        DeleteArray(pad);

When I compile this with Borland C++ 4.0, it works just fine. When I
compile it with MS Visual C++ 2.0 I get the following error:

    test.cpp(31) : error C2607: 'initializing' : cannot implicitly
    convert a 'double*' to a 'double**& ' that is not const

Who's right? Borland or Microsoft? Is it legal or not?

[[ Your code looks perfectly legal to me.  I'd say it was a Microsoft bug.
	- fjh (moderator). ]]

Thanks,
Rob Chambers
robc@thinkman.com
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <41m3tl$3ok@pulm1.accessone.com>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 26 Aug 95 08:18:40 GMT
Approved: fjh@cs.mu.oz.au
Return-Path: <daemon@ncar.UCAR.EDU>
From: robc@thinkman.com (Rob Chambers)
Newsgroups: comp.std.c++
Subject: Is this a legal template function? BC says yes. MSVC says no.
X-Original-Date: Sat, 26 Aug 1995 03:18:07 GMT
Message-ID: <41m3tl$3ok@pulm1.accessone.com>
X-Newsreader: Forte Free Agent 1.0.82