2012/8/26 Ulrich Drepper <drep...@gmail.com>: > On Sun, Aug 26, 2012 at 7:20 AM, Ulrich Drepper <drep...@gmail.com> wrote: >> What I could imagine working is that the iterator fill/generate_n >> functions are defined and in addition the special versions which use >> pointers of the result_type of the distribution. > > How about the following? This version adds one more version of the > fill() function which takes result_type pointers. All these functions > have a default definition which simply falls back to the iterator > version. Specializations can overload the new variant of the function > and it all works without modifying anything in the class definition.
The signature using _OutputIterator need to be changed to _ForwardIterator, because output iterator has no equality comparison (as has already been remarked by someone else before). The function really should have a different name, as mentioned by others. I also agree with others that generate would be a better name than fill. The typedef "pointer" should be removed, because it is not used at all. > As far as possible specification is concerned, only the iterator > versions would have to be specified. The new interface is a > transparently added implementation detail. > > If people agree this is acceptable and the consensus is that > generate_n() is the better name I can submit a patch so that the > remaining <random> work can be submitted. Still ways to go... Personally I consider it as very unfortunate that an overload for pointers should be necessary here. To solve the specialization problem I'm in favour to provide free function templates instead (I also think that they should better get an initially underscored name like _generate). To solve the access problem I would suggest to isolate the minimum needed access and to provide public available functions with underscored names. This would allow to provide overloads instead that are based on some constrained API. Just an idea, - Daniel