Commit 7f4d795c by songxinkai

~

parent 5008fb2e
......@@ -3,3 +3,4 @@
.*.swp
*bin
*bin.finish
bazel-*
c
\ No newline at end of file
/root/.cache/bazel/_bazel_root/10b47e0969b5a5941f6ac84b9ec5df3b/execroot/__main__/bazel-out/k8-fastbuild/bin
\ No newline at end of file
/root/.cache/bazel/_bazel_root/10b47e0969b5a5941f6ac84b9ec5df3b/execroot/__main__
\ No newline at end of file
/root/.cache/bazel/_bazel_root/10b47e0969b5a5941f6ac84b9ec5df3b/execroot/__main__/bazel-out/k8-fastbuild/genfiles
\ No newline at end of file
/root/.cache/bazel/_bazel_root/10b47e0969b5a5941f6ac84b9ec5df3b/execroot/__main__/bazel-out
\ No newline at end of file
/root/.cache/bazel/_bazel_root/10b47e0969b5a5941f6ac84b9ec5df3b/execroot/__main__/bazel-out/k8-fastbuild/testlogs
\ No newline at end of file
a
\ No newline at end of file
/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so
\ No newline at end of file
......@@ -13,6 +13,30 @@ int print_sum(int a, int b, int c){
class classA {
public:
int m_a;
std::function<int(int, int)> m_func[2] = {
[this](int a, int b){
if (m_a % 2 == 0) {
return a;
}else{
return b;
}
},
[this](int a, int b){
if (m_a % 2 == 0) {
return a;
}else{
return b;
}
}
};
classA(){
m_a = 0;
}
void step(){
std::cout << m_func[0](m_a, m_a*2) << std::endl;
m_a ++;
}
void testPrint(int a){
std::cout << a << std::endl;
}
......@@ -31,6 +55,10 @@ int main(){
classA cla;
std::function<void(int)> func4 = std::bind(&classA::testPrint, &cla, std::placeholders::_1);
func4(44);
cla.step();
cla.step();
cla.step();
cla.step();
std::function<int(int, int)> func5 = std::bind(print_sum, 1, std::placeholders::_1, std::placeholders::_2);
func5(55, 1);
......
// g++-4 will meet internal compiler error
// g++-5.2 above fix this bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61362#c8
#include <functional>
struct Node {
size_t length;
};
template<typename N>
class C {
public:
size_t longest = 0;
std::function<void(const N )> f = [this](N node) {
if(node->length > this->longest) this->longest = node->length;
};
};
int main() {
Node n;
n.length = 5;
C<Node*> c;
c.f(&n);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment