Ugh, sorry for late answer. I was ill and thinked about this subject.

"Martin v. Loewis" wrote:

> > Please answer somebody wether it is a bug and wether I should submit it to
> > GNATS.
>
> I believe this is not a bug, because there are no const-qualified
> function types in C++.
>
> If you don't agree, please let us known what you think the value of
> TFunc is. IMO, the only reasonable assumption is that it is tfunc_t as
> in
>
> typedef void (tfunc_t)(int, int);
>
> Then, the argument type would be
>
> typedef const tfunc_t & afunc_t;
>
> in
>
> void tpl_func(afunc_t func);
>
> However, this creates a const-qualified function type, which is
> impossible.

You probably meant bool instead of void in typedef:
typedef bool (tfunc_t)(int, int);

I cannot agree with you, my variant is:
typedef bool (*tfunc_t)(int, int);

In my opinion, tfunc_t is a pointer to function, not reference. This is because
the function name (without a context) is a pointer to that function, not a
reference. If I am wrong, please, let me know.

So, the argument type:
typedef const tfunc_t& afunc_t;
is a const reference to a pointer to function, not a const reference to
function.

Thus, I beleive that compiler wrongly considers TFunc as a reference to
function, it should consider TFunc as a (const) reference to a pointer to
function.

Am I thinking right way?

Regards,
Alexei.


PS.
This is that code, if someone has forgotten something:
============================
template <class TFunc>
void tpl_func (const TFunc& func)
{
        return;
}

static bool compare_ints (int a, int b)
{
        return (a < b);
}

void trigger_the_bug ()
{
        tpl_func (compare_ints);
}
===============================


Reply via email to