Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Default parameters in typedef for function

Reply
Thread Tools

Default parameters in typedef for function

 
 
=?iso-8859-1?Q?Schwarzbauer_G=FCnter?=
Guest
Posts: n/a
 
      08-26-2004
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

 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      08-26-2004

"Schwarzbauer GŁnter" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.(8


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

-Mike


 
Reply With Quote
 
 
 
 
=?Windows-1252?Q?Schwarzbauer_G=FCnter?=
Guest
Posts: n/a
 
      08-26-2004

"Mike Wahler" <(E-Mail Removed)> wrote in message
news:cFqXc.1082$(E-Mail Removed) nk.net...
>
> "Schwarzbauer GŁnter" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello,
> >
> > Does the C++ standard allow default parameters when defining a
> > typedef for a function type?

> Yes.


Mike , thanks for the quick answer...

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

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

 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      08-26-2004
Schwarzbauer GŁnter wrote:
> [...]
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CRTP-problem: How can the base class typedef a derived class' typedef? oor C++ 0 05-20-2008 12:39 PM
typedef function with void parameters Chris Dollin C Programming 14 12-24-2007 12:57 AM
Mixing default and non-default parameters in Constructor? desktop C++ 2 06-06-2007 08:25 PM
About typedef -- define the function pointer or define function model? robin liu C Programming 3 04-21-2006 03:26 PM
Are default function parameters in allowed in function templates? BRG C++ 11 01-04-2005 02:48 PM



Advertisments