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

            Bug ID: 59079
           Summary: a lambda with a parameter that depends on
                    vector<>::value_type typedef leads to compiler error
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ahu at ds9a dot nl

Created attachment 31194
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31194&action=edit
small test file that fails to compile

Thanks for the c++2011 support, it makes me happy! However, the following fails
to compile in g++ 4.6.3 and 4.8.3 (at least), and I think it is valid c++2011.

#include <vector>
#include <functional>

template<typename T>
void buildvect(const T& vect, 
          std::function<double(typename T::value_type)> yTransform)
{}

int main()
{
  std::vector<int> blah{1,2,3,4};
  buildvect(blah, [](int a) { return 1.0*a;});
}

Delivers:
t.cc: In function ‘int main()’:
t.cc:12:45: error: no matching function for call to
‘buildvect(std::vector<int>&, main()::__lambda0)’
   buildvect(blah, [](int a) { return 1.0*a;});
                                             ^
t.cc:12:45: note: candidate is:
t.cc:5:6: note: template<class T> void buildvect(const T&,
std::function<double(typename T::value_type)>)
 void buildvect(const T& vect, 
      ^
t.cc:5:6: note:   template argument deduction/substitution failed:
t.cc:12:45: note:   ‘main()::__lambda0’ is not derived from
‘std::function<double(typename T::value_type)>’
   buildvect(blah, [](int a) { return 1.0*a;});
                                             ^
Does compile in clang 3.3, does compile if T::value_type is replaced by int.

Thanks!

Reply via email to