From -2440770295702202820
X-Google-Thread: f78e5,d9fe358a73c69991
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news3.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!nntp.abs.net!news-FFM2.ecrc.net!news.m-online.net!newsfeed.stueberl.de!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: pavel@despammed.com ("Pavel Kuznetsov")
Newsgroups: comp.std.c++
Subject: Re: Should failure to instantiate a function template abort compilation during overload resolution?
Date: Thu, 11 Aug 2005 14:33:37 GMT
Lines: 77
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <op.svbuucgcrcu39t@ibm-t42.domain.actdsltmp>
References: <1123485075.096196.242990@g44g2000cwa.googlegroups.com> <hinnant-6B7192.21000609082005@syrcnyrdrs-03-ge0.nyroc.rr.com> <pjdKe.3714$zr1.3712@newssvr13.news.prodigy.com> <3ltsd1F14jf4hU1@individual.net>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; format=flowed; delsp=yes; charset=windows-1251
Content-Transfer-Encoding: 8bit
X-Trace: news.demon.co.uk 1123770831 19868 158.152.254.254 (11 Aug 2005 14:33:51 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Thu, 11 Aug 2005 14:33:51 +0000 (UTC)
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Opera M2(BETA1)/8.02 (Win32, build 7668)
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id j7BEXbn5028801;
	Fri, 12 Aug 2005 00:33:37 +1000 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-Delivered-To: std-c++@ucar.edu
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
Xref: g2news1.google.com comp.std.c++:1762

Richard,

> template <typename T>
> struct A
> {
>    friend class B;
> };
>
> template <typename T>
> typename T::TYPE foo (T);     // Does use SFNAE
>
> template <typename T>
> typename A<T>::TYPE foo (T);  // Does not use SFNAE
>
> void foo (int);
>
> void bar ()
> {
>    foo (0);
> }
>
> // ...
>
> typedef int B;

I fail to see why you're saying that SFINAE does not take place in
the second case, and in fact the standard contains a similar example:

   14.8.2/2 <...> Type deduction may fail for the following reasons:
   <...>
   - Attempting to use a type in the qualifier portion of a qualified
     name that names a type when that type does not contain the
     specified member, or if the specified member is not a type where
     a type is required. [Example:
       template <class T> int f(typename T::B*);
       struct A {};
       struct C { int B; };
       int i = f<A>(0);
       int j = f<C>(0);
     ]

   14.8.3/1 <...> If, for a given function template, argument deduction
   fails, no such function is added to the set of candidate functions
   for that template.

> If the compiler did allow you to instantiate class bodies, it would then  
> have a lot of difficulty back tracking.  In this example, a completely  
> unrelated typedef would now generate an error since there is already a  
> 'class B' declared in the namespace.

This is exactly what Comeau Online and VC++8 beta 2 has to say for your
example:

====

"ComeauTest.c", line 23: error: invalid redeclaration of type name "B"  
(declared at
           line 4)
   typedef int B;
               ^

1 error detected in the compilation of "ComeauTest.c".

===

.\test.cpp(36) : error C2371: 'B' : redefinition; different basic types
         .\test.cpp(17) : see declaration of 'B'

-- 
Pavel

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html                       ]



