I'll attempt to answer.
What could I write in my report? "This function is a random number generator that randomly picks a number from a the distribution to whom it was passed over" |
"The std::mt19937 class is the C++ implementation of the Mersenne Twister, a widely used general-purpose pseudorandom number generator (PRNG)." That's how I would personally word it.
https://en.wikipedia.org/wiki/Mersenne_Twister
If I am using namespace std, all the "std::" in your code can be left out, right? |
Yes. You can use "using namespace std;", although the devil is in the detail, because it dumps the entire namespace into your code. Misusing "using namespace std;" can cause naming conflicts if you define functions or other classes/objects that become ambiguous when already defined in the std namespace. It's up to you, just be aware of what you're doing.
https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice
Also you included the templates "Random" and "Chrono" |
I think you're misusing terminology here.
When you "#include <name>", you're not necessarily including a template definition, you're including a
header file. A header file contains the declarations/definitions of classes/functions/objects so that you, the user of those items, can have access to them.
See:
https://en.wikipedia.org/wiki/Include_directive
C++ standard library header files often contain templates, but they don't have to. It's two separate concepts.
Is chrono a class that I can use due to the template "chrono"? |
chrono is not a class or a template, it's a namespace, and also the name of the header file that contains definitions of useful date and time utilities, which are defined in the std::chrono namespace.
https://en.cppreference.com/w/cpp/chrono
https://www.geeksforgeeks.org/namespace-in-c/
Simplified example:
1 2 3 4 5 6 7
|
namespace std {
namespace chrono {
class system_clock {
// etc.
};
}
}
|
And is it necessary to write chrono:: even though I have included the template?
|
I would keep the chrono:: in your code, but you could get rid of it by doing
using namespace std::chrono;
... but I don't recommend getting in the habit of doing that.
assume mt19937 is a class from <random>? |
Yes, mt19937 is a class defined in the <random> header file.
The std:: also implies it is part of the standard library. |
Yes.
E.g. that vectors are not part of the standard library, thus one has to #include them? |
No. It's all part of the C++ standard library. std::vector. To get anything from the standard library, you need to #include something. Whether that's <vector> or <iostream> or <cstdlib>, etc.
Hope that clears some things up.