我在 std::find 中使用的非静态类成员函数中有一个 lambda 函数。
//Somewhere in the header...
Gtk::ComboBoxText *optionChoiceComboBoxText = nullptr; // Initialized later in code
std::vector<OptionData> optionList;
int currentOptionPositionInList = -1;
// In Interface.cpp
Interface::optionChangedHandler() {
currentOptionPositionInList = std::distance(optionList.begin(),
find(optionList.begin(), optionList.end(), [&](OptionData const& o) {
std::string s = optionChoiceComboBoxText->get_active_text();
return s == o.name;
})); //Error is here
}
Run Code Online (Sandbox Code Playgroud)
这是注释的错误:
[ 66%] Building CXX object CMakeFiles/RNS.dir/src/GUI/Interface.cpp.o
In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iterator:64,
from /usr/include/glibmm-2.4/glibmm/ustring.h:29,
from /usr/include/glibmm-2.4/glibmm/exception.h:25,
from /usr/include/glibmm-2.4/glibmm/error.h:23,
from /usr/include/glibmm-2.4/glibmm/thread.h:49,
from …Run Code Online (Sandbox Code Playgroud) 我想传递std::array具有已知类型的类,但模板函数专门化的大小未知:
class foo {
public:
void bar<class T>(T arg1, int arg2, int arg3) {
//For any other T
}
void bar<std::array<rs::float3, size>>(T arg1, arg2) {
//Specific function for type std::array of rs::float3's and unknown length (size is not a type, just variable).
}
Run Code Online (Sandbox Code Playgroud)