M
Matthias Buelow
Hi,
is there any way to define a function where one or more parameters might
be of any type, since they aren't used in the function?
In particular, I'd need an operator <<() which always throws an error
and doesn't care which type its second argument is, so ideally I'd like
it to be like:
Stream &operator(Stream &s, anytype-here)
{
throw Blobb;
}
Naively, I have tried
Stream &operator(Stream &s, ...)
which doesn't work.
In general, I'd like to be able to define a function f with one or more
parameters which remain of unspecified type, like I could do, for
example, in SML:
fun f x y = 1+x;
(here the type of the second argument, y, is not specialized and is
represented by the type variable 'a).
Is this possible to achieve in C++?
is there any way to define a function where one or more parameters might
be of any type, since they aren't used in the function?
In particular, I'd need an operator <<() which always throws an error
and doesn't care which type its second argument is, so ideally I'd like
it to be like:
Stream &operator(Stream &s, anytype-here)
{
throw Blobb;
}
Naively, I have tried
Stream &operator(Stream &s, ...)
which doesn't work.
In general, I'd like to be able to define a function f with one or more
parameters which remain of unspecified type, like I could do, for
example, in SML:
fun f x y = 1+x;
val 'a f = fn : int -> 'a -> int
(here the type of the second argument, y, is not specialized and is
represented by the type variable 'a).
Is this possible to achieve in C++?