Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

C++boost syntax – meaning of <>

I was generating a random number with the boost library, namely:

   boost::random::random_device rng;
   boost::random::uniform_int_distribution<> index_dist(0, chars.size() - 1);

Now I understand that uniform_int_distribution is class, but what’s the meaning of the empty <>? Is it a template?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It is indeed a template.
With no given datatype it will fall back to a default datatype to work with.

You can see that the default in this case is a regular int.

https://www.boost.org/doc/libs/1_51_0/doc/html/boost/random/uniform_int_distribution.html

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading