What could be the cause of the std::system_error?

I am trying to making this loop concurrent :
1
2
3
4
5
for(auto x=args.begin();x!=args.end();x++)
{
    list l;
    if(is_list(*x,l)) *x = l.eval();
}

..and converted it to:
1
2
3
4
5
6
7
8
9
10
11
12
13
for(auto x=args.begin();x!=args.end();x++)
    if(is_list(*x,temp))
        threads.push_back
        (
            std::thread
            (
                [](list l,std::string& ret){ret = l.eval();},
                temp,
                *x
            )
        );
for(auto t = threads.begin();t!=threads.end();t++)
    t->join();

But the creating of the threads fail with a std::system_error thrown.
Why could it happen ?
If you're using GCC to compile this, this exception is thrown because gcc requires the commandline argument -pthread to link any code that uses std::thread.

(specifically, it throws a system_error holding the error code generic:1 and the explanation string "Operation not permitted")
Last edited on
Could you please give a little bit more information on
is_list, ans list.

And also provide information which line throw systen_error
My list is here : https://github.com/manasij7479/minlisp/blob/master/list.h
and is_list just checks whether a string can be converted into a list...if it is, the passed list reference is filled with a list object.
And the exception is thrown when creating a new thread.

@Cubbi: Thanks, that was it...(along with a small bug in the loop itself).
Last edited on
Topic archived. No new replies allowed.