Reputation: 265
Does std::sort()
typically use threading to increase its performance? I realize that this could vary from implementation to implementation. If not, why not?
Upvotes: 0
Views: 1686
Reputation: 52471
[res.on.data.races]/8 Unless otherwise specified, C++ standard library functions shall perform all operations solely within the current thread if those operations have effects that are visible (4.7) to users.
/9 [ Note: This allows implementations to parallelize operations if there are no visible side effects. —end note ]
std::sort
could, in principle, use parallel execution when sorting elements of fundamental type (it wouldn't be observable whether it does), but not user-defined type (unless explicitly given permission via execution policy parameter, of course). The type's operator<
may not be thread-safe.
Upvotes: 1