Skip to content

Instantly share code, notes, and snippets.

@pikajude
Created October 8, 2013 20:41
Show Gist options
  • Save pikajude/6891278 to your computer and use it in GitHub Desktop.
Save pikajude/6891278 to your computer and use it in GitHub Desktop.
template <class T, class V, class Fn>
vector<V> flat_map(vector<T> elems, Fn trans) {
vector<V> results;
for (auto elem: elems) {
auto inte = trans(elem);
results.insert(results.end(), inte.begin(), inte.end());
}
return results;
}
vector<Result> Board::find(vector<string> strings) {
return flat_map(strings, [](string s) {
return vector<Result>();
});
}
/*
solve.cpp:88:10: error: no matching function for call to 'flat_map'
return flat_map(strings, [](string s) {
^~~~~~~~
solve.cpp:78:11: note: candidate template ignored: couldn't infer template argument 'V'
vector<V> flat_map(vector<T> elems, Fn trans) {
^
1 error generated.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment