g++ doesn't find the right ctor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

the following code does not compile:
struct A
{
    template<typename T> A(const T *, const float *T::*) {}
};

struct B
{
    float *f;
};

int main()
{
    B x;
    A y(&x, &B::f);
    return 0;
}

Output is:
g++ -Wall -O3 -Wextra main.cpp -o test
main.cpp: In function ‘int main()’:
main.cpp:14: error: no matching function for call to ‘A::A(B*, float* B::*)’
main.cpp:2: note: candidates are: A::A(const A&)

It compiles if I change B to
struct B
{
	const float *f;
};

or the A ctor to
template<typename T> A(const T *, float *T::*) {}

I believe g++ is at fault here. Or am I expecting too much?

Regards,
	Matthias


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux