Skip to content

Random generator #218

Description

@brccabral

Right now the random generator is static, but this adds one generator to each cpp file that calls for nc::random. Should it be inline instead?

I have a file mylib.cpp that uses nc::random::rand<float>({5, 10}) and I compile it as a library. and I have another file main.cpp that calls for nc::random::seed((int)time(nullptr)) and uses the library, but I was getting the same random values all the time.

add_library(mylib mylib.cpp)
add_executable(myprogram main.cpp)
target_link_libraries(myprogram mylib)

I tested inline std::mt19937_64 generator_; and now my library does generates different values.

I am not entirely sure if this is a fix, otherwise I would make a PR, but my library only works with inline.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions