Topic: Methods with variable number arguments like printf - Legal O X g
Author: comeau@panix.com (Greg Comeau)
Date: 1997/01/03 Raw View
In article <rf5ohf75dj9.fsf@vx.cit.alcatel.fr> James Kanze <james-albert.kanze@vx.cit.alcatel.fr> writes:
>jlilley@empathy.com (John Lilley) writes:
>
>|> Morten M. Christensen wrote:
>|> > Is it legal in standard C++ to have methods with a variable
>|> > number of arguments like printf ? I.e. Are the methods below
>|> > legal ?
>|> >
>|> > class X // An example:
>|> > {
>|> > public:
>|> > void printf(...); // Accepted by BC++ and Visual C++
>|> > void operator()(...); // Accepted by BC++, Visual C++ "crashes" on
>|> > this.
>|> > };
>|>
>|> The may96 draft standard says that "..." is valid for normal methods and
>|> functions. I assume it is valid for operator(), because default
>|> arguments are explicitly allowed, and "..." is not explicitly
>|> disallowed. Note that "..." is not valid for operator[] or conversion
>|> operators.
>
>Question: is "..." valid for any operator other than operator()? I
>don't think that the draft makes an explicit statement, but all other
>operators do require a fixed number of parameters (1 or 2), so this
>would seem to rule it out.
Things such as "exactly one parameter" would seem to rule out the possibility
without any change of loopholes.
- Greg
--
Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418-3214
Producers of Comeau C++ 4.0 front-end pre-release
****WEB: http://www.comeaucomputing.com / Voice:718-945-0009 / Fax:718-441-2310
Here:comeau@comeaucomputing.com / BIX:comeau or comeau@bix.com / CIS:72331,3421
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]