Topic: unnamed enum and function template
Author: Stephan.Bergmann@sun.com (Stephan Bergmann)
Date: Wed, 23 Mar 2005 19:46:35 GMT Raw View
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 ]
Author: dsp@bdal.de (=?ISO-8859-1?Q?=22Daniel_Kr=FCgler_=28ne_Spangenberg=29=22?=)
Date: Thu, 24 Mar 2005 21:36:01 GMT Raw View
Good morning Stephan Bergmann,
Stephan Bergmann schrieb:
> 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=20
> call to f in main, should the compiler complain that the template f is=20
> instantiated with an unnamed type (14.3.1/2: "[...] an unnamed type=20
> [...] shall not be used as a template-argument for a template=20
> 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=20
> the above program, on the grounds that the template f is never a=20
> viable overload for the call (since 1 cannot be converted to X), so=20
> instantiating it for the unnamed enum can be "short circuited" away?=20
> No, right?=20
I think, a similar problem has been described in the following open issue=
s:
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=FCgler
---
[ 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 ]