A
Armen Tsirunyan
Hello all,
I have recently experimented (just for experiment's sake) with
declaring variables and functions of arbitrarily complicated types
without using typedefs, and finally learned to do it. By saying
arbitrarily complicated, I DO mean arbitrarily complicated . This
led me to believe that any piece of code(let's precautiously add
"which doesn't involve templates") can be rewritten without using
typedefs. But...
struct IncrementFunctorClassWithNoOperatorParentheses
{
static int f(int n) { return n+1; }
typedef int(*pf) (int);
operator pf () { return &f; }
};
One might expect that this conversion function can also be declared
without a typedef -
operator int (*) (int) () { ... }
but, alas, this compiles on neither MSVC9.0 nor online comeau. Nor do
any variations of the syntax I was able to invent.
So, I have two question. First, is it possible to declare a
conversion
function to a pointer-to-function without using a typedef, if yes,
how?
And, second (valid if the answer to the first is positive), is there
anything that cannot be declared without a typedef?
Thank you in advance,
Armen Tsirunyan, Software Developer at CQG, Yerevan.
--
comp.lang.c.moderated - moderation address: (e-mail address removed) -- you
must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line. Sorry.
I have recently experimented (just for experiment's sake) with
declaring variables and functions of arbitrarily complicated types
without using typedefs, and finally learned to do it. By saying
arbitrarily complicated, I DO mean arbitrarily complicated . This
led me to believe that any piece of code(let's precautiously add
"which doesn't involve templates") can be rewritten without using
typedefs. But...
struct IncrementFunctorClassWithNoOperatorParentheses
{
static int f(int n) { return n+1; }
typedef int(*pf) (int);
operator pf () { return &f; }
};
One might expect that this conversion function can also be declared
without a typedef -
operator int (*) (int) () { ... }
but, alas, this compiles on neither MSVC9.0 nor online comeau. Nor do
any variations of the syntax I was able to invent.
So, I have two question. First, is it possible to declare a
conversion
function to a pointer-to-function without using a typedef, if yes,
how?
And, second (valid if the answer to the first is positive), is there
anything that cannot be declared without a typedef?
Thank you in advance,
Armen Tsirunyan, Software Developer at CQG, Yerevan.
--
comp.lang.c.moderated - moderation address: (e-mail address removed) -- you
must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line. Sorry.