Skip to content

<random>: Optimize P0952R2 generate_canonical when R is a power of 2 #4750

Description

While reviewing Matt Stephanson (@MattStephanson)'s implementation of #4169 / WG21-P0952R2, statementreply noted in #4740 (comment) :

_Sx doesn't need to be wider than _Result_uint_type when _Rx is a power of 2, as is noted in https://eel.is/c++draft/rand.util.canonical#7 . The $i$-th random value could be shifted by $i \log_2 R - \log_2 x$ bits instead (the 0th random value is shifted right).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedSomething works now, yay!performanceMust go faster

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions