random numbers in bulk
Marc Glisse
marc.glisse@inria.fr
Sun Aug 26 08:52:00 GMT 2012
On Sat, 25 Aug 2012, Ulrich Drepper wrote:
> On Sat, Aug 25, 2012 at 8:29 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
>> Understood, but you do *not* loose performance by having those fill functions templates,
>
> Let's see. The prototypes will then be something like this:
>
> template<typename _RealType = double>
> class normal_distribution
> {
>
> template<typename _UniformRandomNumberGenerator,
> typename _OutputIterator>
> void
> fill(_OutputIterator __f, _OutputIterator __t,
> _UniformRandomNumberGenerator& __urng,
> const param_type& __p);
> };
The std::generate(_n) function seems closer than std::fill. Not sure if
overloading that function (std::generate_n) would make sense, it avoids
changing the interface.
> Now I want to define a specialized function which works for a double
> iterator and all RNGs. That's not possible because it means partial
> specialization.
>
> Therefore I'd have to add another member function to the class. If
> this is what is wanted I can do this (in fact, I have the code ready).
> It just looks worse because the special functions are in some cases
> architecture-specific. This means the code will be littered with
> arch-specific code.
If the goal is to avoid listing several overloads in the class, it is
still possible to dispatch in the (out-of-class) definition of fill. Or is
the goal to make it extensible, in the sense that a user can still add
"specializations" (whatever the technical means used, which don't have to
be what C++ calls specialization)?
--
Marc Glisse
More information about the Libstdc++
mailing list