
2 Sep
2011
2 Sep
'11
5:44 p.m.
On 2 September 2011 11:01, Ilya Bobir <ilya.bobir@gmail.com> wrote:
unsigned int next_id() { static unsigned int previous_id = 0; //0 is not assigned to a type
++previous_id; return previous_id; }
[...]
Would not this be non-thread safe?
That's the second problem that has to be tackled with this code. Would this work: unsigned next_id() { static std::atomic<unsigned> previous_id; return ++previous_id; } -- Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404