I'm trying to run the code for fibonacci series algorithm in parallel.The problem is that my function returns a string and is recursive. I've tried using future and promise,it doesn't seem to work though. Can anyone point out where I'm going wrong?
void fib(int n,promise<string> *x)
    string bit;
    if (n == 0)
    {
         x->set_value("0");
    }
    else if (n == 1) {
        x->set_value("1");
    }
    else if (n > 1) {
        promise <string> p1;
        promise <string> p2;
        thread *t = new thread[2];
        t[0] = thread(fib, n-1,&p1);
        t[0] = thread(fib, n - 2,&p2);
        t[0].join();
        t[1].join();
        future<string> ret = p1.get_future();
        future<string> re = p2.get_future();
        string a = ret.get();
        string b = re.get();
        x->set_value( a + b);
    }
}
 
    