89's Site

Hello world!

Author: ffk0716

lvalue and rvalue

拜讀Rvalue References: C++0x Features in VC10, Part 2的心得

Continue reading

RTL

Chisel

Compiler

How A Compiler Works

CMake

https://www.johnlamp.net/cmake-tutorial.html

custom target 和 commands 的靈異現象

Scope exit

自己寫的scope exit
感覺比boost的好用

class Scope_Exit
{
    std::function<void()> func;
    public:
    Scope_Exit(std::function<void()> f): func(f) { }
    ~Scope_Exit() { func(); }
};

#define CONCAT_I(a, b) a##b
#define CONCAT(a, b) CONCAT_I(a, b)
#define SCOPE_EXIT(var) Scope_Exit CONCAT(af_, __COUNTER__) ([&](){var;})

用法

    int a = 0;
    {
        SCOPE_EXIT(a = 5);
        a = 6;
    }
    assert(a == 5);

Recursive lambda functions

std::function<int (int)> factorial = [&] (int i) 
{ 
    return (i == 1) ? 1 : i * factorial(i - 1); 
};

© 2017 89's Site

Theme by Anders NorenUp ↑