Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Should Random Number Initializers Take Iterators by Reference or by Value?

0
Posted

Should Random Number Initializers Take Iterators by Reference or by Value?

0

(See also the thread started with Pete Becker’s message c++std-lib-10785.) The concern is that section 5.1.1, table 5.2 (Pseudo-random number engine requirements), specifies that engines can be constructed and seeded using an iterator range [it1, it2) of unsigned integral values. It appears surprising to the user that, unlike any other function or class in the standard library, the iterators are not both passed by value, but it1 is passed by reference, and is modified during the construction or seeding. Any solution has to satisfy the following requirements (see also section III.E of N1452): • Engine constructors and seeding are visible and meant to be used by users. • Engines may be compounded of other engines; the compounding engine must be able to initialize its compounds. • Engines may have a large state (up to several KB) that should not be initialized twice for efficiency reasons. There are two solutions to remedy this problem. The first keeps the iterator range, but passes the i

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.