Skip to content

Instantly share code, notes, and snippets.

@piotrbla
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotrbla/56e2e6cecc1ada2170cd to your computer and use it in GitHub Desktop.
Save piotrbla/56e2e6cecc1ada2170cd to your computer and use it in GitHub Desktop.
Lamdziwo w cpp lambda c++
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
template <typename T>
class Bucket {
T value;
public:
Bucket() {}
Bucket(T value);
T getValue() { return value; }
void add(T _Right) { value += _Right; }
};
template<class T>
Bucket<T>::Bucket(T value):value(value) {}
int main()
{
Bucket<string> b("Low");
Bucket<string> c("Hi");
Bucket<string> d("Hi");
vector <Bucket<string>> x;
x.push_back(b); x.push_back(c); x.push_back(d);
auto n = count_if(x.begin(), x.end(),
[](Bucket<string> p) {return p.getValue()=="Hi";});
cout << n << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment