From -1970170533097621109
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc772,ef0c226459c03bdf
X-Google-Attributes: gidfc772,public
X-Google-Thread: f78e5,edd477ec92e5348f
X-Google-Attributes: gidf78e5,public
From: "Andrei Alexandrescu" <alexandrescua@micromodeling.com>
Subject: Re: Protected Inheritance
Date: 1999/02/17
Message-ID: <36c9a628.0@10.1.1.65>#1/1
X-Deja-AN: 445221524
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <Pine.GSO.3.95-960729.990131142619.5694B-100000@finan.ncl.ac.uk> <slrn7bbi9a.q1a.sbnaran@localhost.localdomain> <sUPt2.16333$202.8056314@news1.teleport.com> <79aesq$qlr$1@uuneo.neosoft.com> <HEbu2.18017$202.8772558@news1.teleport.com> <36b9fd49.0@10.1.1.65> <AwGu2.19901$202.9740872@news1.teleport.com> <36C046BE.4233@clipper.ens.fr>
X-Submission-Address: c++-submit@netlab.cs.rpi.edu
X-Original-Date: 16 Feb 1999 21:47:20 -0500
X-Complaints-To: news@news.unimelb.edu.au
X-Approved-For-Group: harkness@skeptics.org comp.lang.c++.moderated
X-Trace: izvestia.its.unimelb.edu.au 919231234 13167 128.250.29.16 (17 Feb 1999 06:00:34 GMT)
Organization: unknown
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANspa5OEDnX0m9pzZAQEhgwF/SpmgkPr6mM3/KLiIq8vbBrvrcnCDXxcu t9+pjGwYu+Q2NPgDjo8UsgEFCtd2dIYH =zQsv
X-Warning-To-Moderators: This article has been processed and accepted using a cryptographic program by the moderator of comp.lang.c++.moderated. Its content must not be changed or it will be automatically cancelled. If you don't like the article or its crossposting, return it to the submitter.  (You can delete this message if you are the last moderator to see it.)
NNTP-Posting-Date: 17 Feb 1999 06:00:34 GMT
Newsgroups: comp.std.c++,comp.lang.c++.moderated

Valentin Bonnard wrote in message <36C046BE.4233@clipper.ens.fr>...
>No, sadly it won't, because of some strange [moderators, I can say
>stupid ?]
>rule in the standard, which prohibits making template parameters
>friends.

Guess what. I removed the "class" keyword in my friend declaration and MSVC
6 gladly accepted the code.

template <class T>
class DontDeriveFromMyTemplateParameter
{
    friend T;
    DontDeriveFromMyTemplateParameter() {}
};

class Something : virtual public
DontDeriveFromMyTemplateParameter<Something>
{
public:
    Something() {}
};

class SomethingElse : public Something
{
};

Something s1;          // fine
SomethingElse s2;      // compile-time error

So, who's right?
Also, to Scott: I tried the copy constructor loophole and I couldn't
instantiate MoreDerived as you predicted. Again: who's right?

Andrei



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]

      [ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
      [ about comp.lang.c++.moderated. First time posters: do this! ]



