다음 코드 (g ++ 4.7.1 사용)를 컴파일 할 수없는 이유는 무엇입니까? 은 "분명()"메소드를 호출 할 수없는 문제를 검사하는 동안 나는이 문제를 가로 질러 온템플릿 클래스 멤버 메서드 내에서 자동 람다 : 형식 이름을 지정하지 않습니다.
main.cpp: In member function 'void Problem<T>::f()':
main.cpp:17:10: error: 'mytestlambda' does not name a type
:
#include <set>
template<typename T>
class Problem
{
public:
void f();
std::set<int> dummyvalue;
};
template<typename T>
void Problem<T>::f()
{
auto mytestlambda = [this](){
dummyvalue.clear();
};
}
int main()
{
return 0;
}
나는 다음과 같은 오류가 발생합니다. 왜 'CONST는'여기
main.cpp: In lambda function:
main.cpp:18:26: error: no matching function for call to 'std::set<int>::clear() const'
main.cpp:18:26: note: candidate is:
In file included from /usr/include/c++/4.7/set:61:0,
from main.cpp:1:
/usr/include/c++/4.7/bits/stl_set.h:580:7: note: void std::set<_Key, _Compare, _Alloc>::clear() [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>] <near match>
/usr/include/c++/4.7/bits/stl_set.h:580:7: note: no known conversion for implicit 'this' parameter from 'const std::set<int>*' to 'std::set<int>*'
을 포함한다 :
추가 '-std = C++ 11'정말 내 진짜 문제에 도달 할 수 있습니다?
C++ 11을 사용할 수 있습니까? – 0x499602D2