Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random generator #218

Open
brccabral opened this issue Sep 19, 2024 · 0 comments
Open

Random generator #218

brccabral opened this issue Sep 19, 2024 · 0 comments

Comments

@brccabral
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant