[Bug c++/51884] lambda with templates

jason at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Mar 5 20:08:00 GMT 2013


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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2013-03-05 20:07:20 UTC ---
Slightly reduced again.  Note that this testcase uses a normal local class
rather than a lambda; the only C++11 feature it uses is local types as template
arguments.

template<typename _Tp> struct is_same { static const int value = 0; };
template<int> struct enable_if {
  typedef void type;
};
struct thread {
  struct _Impl_base {
    virtual void _M_run();
  };
  template<typename _Callable>
   struct _Impl : _Impl_base  {  };
  template<typename _Callable>
   thread(const _Callable& __f) {
     _M_start_thread(_M_make_routine(__f));
   }
  template<typename _Callable>
    _Impl<_Callable> _M_make_routine(const _Callable& __f);
};
template <typename T, typename = void> struct foo;
template <typename T> struct foo<T,typename enable_if<is_same<T>::value>::type>
{
  template <bool Bar>  void bar() const  {
    struct A { } a;
    thread thr(a);
  }
};
int main() {
 foo<int> f;
 f.bar<true>();
}



More information about the Gcc-bugs mailing list