 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Stephan Bergmann Guest
|
Posted: Wed Mar 23, 2005 7:46 pm Post subject: unnamed enum and function template |
|
|
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
|
Posted: Thu Mar 24, 2005 9:36 pm Post subject: Re: unnamed enum and function template |
|
|
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 |
|
 |
|
|
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
|
|