C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

unnamed enum and function template

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Stephan Bergmann
Guest





PostPosted: Wed Mar 23, 2005 7:46 pm    Post subject: unnamed enum and function template Reply with quote



Hi all,

Is the following valid C++ or not?

void f(int, int) {}
class X {};
template< typename T > void f(X const &, T const &);
enum { E };
int main() { f(1, E); }

Specifically, when determining the set of canditate functions for the
call to f in main, should the compiler complain that the template f is
instantiated with an unnamed type (14.3.1/2: "[...] an unnamed type
[...] shall not be used as a template-argument for a template
type-parameter."), or should it just ignore the template f, a la SFINAE?

If SFINAE does not apply here, is a compiler still allowed to accept the
above program, on the grounds that the template f is never a viable
overload for the call (since 1 cannot be converted to X), so
instantiating it for the unnamed enum can be "short circuited" away?
No, right?

-Stephan

---
[ 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 ]

Back to top
Daniel Krügler
Guest





PostPosted: Thu Mar 24, 2005 9:36 pm    Post subject: Re: unnamed enum and function template Reply with quote



Good morning Stephan Bergmann,

Stephan Bergmann schrieb:

Quote:
Hi all,

Is the following valid C++ or not?

void f(int, int) {}
class X {};
template< typename T > void f(X const &, T const &);
enum { E };
int main() { f(1, E); }

Specifically, when determining the set of canditate functions for the
call to f in main, should the compiler complain that the template f is
instantiated with an unnamed type (14.3.1/2: "[...] an unnamed type
[...] shall not be used as a template-argument for a template
type-parameter."), or should it just ignore the template f, a la SFINAE?

If SFINAE does not apply here, is a compiler still allowed to accept
the above program, on the grounds that the template f is never a
viable overload for the call (since 1 cannot be converted to X), so
instantiating it for the unnamed enum can be "short circuited" away?
No, right?

I think, a similar problem has been described in the following open issues:

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#488
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#489

Greetings from Bremen,

Daniel Krügler

---
[ 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 ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.