Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Improvements to std::counting_semaphore #3746

@achabense

Description

@achabense

For std::counting_semaphore:

  1. _Least_max_value is required to be non-negative. There are already a lot of runtime checks for std::counting_semaphore's methods. For better coding experience, please consider adding static_assert(_Least_max_value >= 0, ...) for the class.
  2. _Wait is public but is only used by other members. Please consider declaring it as private.
  3. This check is conceptually unsafe as _Prev + _Update can possibly lead to signed integer overflow. Please consider replacing it with _Update <= _Least_max_value - _Prev. (Additionally, _Prev + _Update > 0 is implicitly guaranteed by previous checks and may be omitted here.)
    _STL_VERIFY(_Prev + _Update > 0 && _Prev + _Update <= _Least_max_value,

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions