Default parameters in typedef for function

  • Thread starter =?iso-8859-1?Q?Schwarzbauer_G=FCnter?=
  • Start date
?

=?iso-8859-1?Q?Schwarzbauer_G=FCnter?=

Hello,

Does the C++ standard allow default parameters when defining a typedef for a
function type, e.g.

typedef void (*TYPE_Report)(const char* message, const char* details = 0);

This was accepted by MS Visual C++ 6.0, but is rejected in Visual Studio
..NET 2003.
I assume that this change might be because Visual Studio .NET is more C++
standard compliant than previous versions were.
Is this correct?

Is there any way to use default parameters for function types?

thanks
Günter
 
M

Mike Wahler

Schwarzbauer Günter said:
Hello,

Does the C++ standard allow default parameters when defining a typedef for a
function type, e.g.

typedef void (*TYPE_Report)(const char* message, const char* details = 0);

This was accepted by MS Visual C++ 6.0, but is rejected in Visual Studio
.NET 2003.
I assume that this change might be because Visual Studio .NET is more C++
standard compliant than previous versions were.
Is this correct?
Yes.


Is there any way to use default parameters for function types?

Not that I know of.

===================================================================
ISO/IEC 14882:1998(E)

8.3.6 Default arguments

3 A default argument expression shall be specified only in the
parameter-­declaration­-clause of a function declaration or in
a template­-parameter (14.1). If it is specified in a parameter­-
declaration­-clause, it shall not occur within a declarator or
abstract­-declarator of a parameter­-declaration.(88)


(88) This means that default arguments cannot appear, for
example, in declarations of pointers to functions, references
to functions, or typedef declarations.
===================================================================

-Mike
 
?

=?Windows-1252?Q?Schwarzbauer_G=FCnter?=

Mike Wahler said:

Mike , thanks for the quick answer...
Not that I know of.

.... although I don't like it.


Seems like this was no accident, but a deliberate decision.
Does someone know why this was decided this way?

Günter
 
V

Victor Bazarov

Schwarzbauer said:
[...]
Seems like this was no accident, but a deliberate decision.
Does someone know why this was decided this way?

If somebody does, it would be in comp.std.c++.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top