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.
Right now the random generator is
static, but this adds one generator to each cpp file that calls fornc::random. Should it beinlineinstead?I have a file
mylib.cppthat usesnc::random::rand<float>({5, 10})and I compile it as a library. and I have another filemain.cppthat calls fornc::random::seed((int)time(nullptr))and uses the library, but I was getting the same random values all the time.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.