http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52892

Adrien Guinet <adrien at guinet dot me> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |adrien at guinet dot me

--- Comment #2 from Adrien Guinet <adrien at guinet dot me> 2012-05-29 09:26:29 
UTC ---
Hello everyone,

Im ay have an issue related to this issue, if that can help:

#include <iostream>

struct A
{
    void f(int i) { std::cout << "f " << i << " " << _i << std::endl; }
    void f2(int i) { std::cout << "f2 " << i << " " << _i << std::endl; }
    int _i; 
};

template <typename F, F f>
struct class_f
{
    typedef F f_type;
    static constexpr f_type f_value = f;
    static constexpr f_type get() { return f; }
};


int main()
{
    typedef class_f<decltype(&A::f), &A::f> ff_t;

    // This does not compile
    class_f<ff_t::f_type, ff_t::f_value> ff; 

    // This does not compile either
    class_f<ff_t::f_type, static_cast<ff_t::f_type>(&A::f)> ff2;

    // This does
    class_f<ff_t::f_type, &A::f> ff_works;
}

It looks like using a function pointer that has been "instantiated" as an
"f_type" makes the compilation fails. here is the output of g++-4.7 with the
first "failing" tests :

$ g++-4.7 -std=c++0x ftempl.cpp
ftempl.cpp: In function ‘int main()’:
ftempl.cpp:24:37: error: could not convert template argument ‘class_f<void
(A::*)(int), &A::f>::f_value’ to ‘void (A::*)(int)’
ftempl.cpp:24:41: error: invalid type in declaration before ‘;’ token


$ g++-4.7 --version
g++-4.7 (Debian 4.7.0-8) 4.7.0

Reply via email to