mrenaud92/cxx-utils — pull request #1 by daniel-j-h (2013-01-11 18:27:54+00:00)
Title: Prevent division by zero, if hardware_concurrency() implementation returns 0.

This prevents a divisions by zero if the return value of hardware_concurrency() is 0.

Unfortunately this is possible; conforming to the following section in the C++11 standard:

> [thread.thread.static]
> unsigned hardware_concurrency() noexcept;

> Returns: The number of hardware thread contexts.
> [Note: This value should only be considered to be a hint. — end note]
> If this value is **not computable or well deﬁned** an implementation **should return 0**.

See for example: http://stackoverflow.com/a/8583292