http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56915
Shixiong <shixiong at kugelworks dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |shixiong at kugelworks dot
| |com
--- Comment #1 from Shixiong <shixiong at kugelworks dot com> 2013-04-12
07:29:38 UTC ---
I am not an expert of C++11, but I am trying to help you with this ICE. Before
I jump into the compiler to find the bugs, I guess you probably made several
mistakes in your given code.
1) when lambdas are used as parameters, I think, they should be written in
either function pointer (no state) or functional object (with state, dependent
on outside vars).
2) it declared "typename T::type b()", but instantiated the class with int, but
int do not have a filed named type.
3)C++11 seems to only support monomorphic lambdas, if you want to use
polymorphic lambdas, you probably should use other libraries like Boost.
If changed into the following code, it works.
template <typename T>
class A
{
T b(); // Note: still cannot use 'typename T::type b()'
};
template <typename T, typename U>
void waldo(T, U);
template <typename T>
void bar()
{
A<T> (*func_pointer1) (A<T>) = [](A<T> a) { return a; };
void (*func_pointer2) () = []() { };
waldo(func_pointer2,
func_pointer1);
// waldo ([](A<T> a) { return a; }, []() { });
}
int main()
{
bar<int>();
}
Anyway, it is just my personal opinion. If I made mistakes, pls. tell me.