🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Rob Chambers Sat, 26 Aug 1995 08:18
Is this a legal template function? BC says yes. MSVC says no.
#1851
Author: 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. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads