Section: 29.5.9.6.2 [rand.dist.samp.pconst] Status: NAD Submitter: Stephan Tolksdorf Opened: 2007-09-21 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [rand.dist.samp.pconst].
View all issues with NAD status.
Discussion:
probabilities()
similarly applies
to the method densities()
of piecewise_constant_distribution
.
The design of the constructor
template <class InputIteratorB, class InputIteratorW> piecewise_constant_distribution( InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW);
is unnecessarily unsafe, as there is no separate end-iterator given for the weights. I can't see any performance or convenience reasons that would justify the risks inherent in such a function interface, in particular the risk that input error might go unnoticed.
Possible resolution: I propose to add an InputIteratorW lastW
argument to the interface.
[ Stephan Tolksdorf adds pre-Bellevue: ]
In reply to the discussion in N2424 I'd like to make the same comments as for 736.
[ Bellevue: ]
In N2424. There is already precedent elsewhere in the library. Follows existing convention. NAD.
Proposed resolution:
See N2424 for the proposed resolution.
[ Stephan Tolksdorf adds pre-Bellevue: ]
In 29.5.9.6.2 [rand.dist.samp.pconst]:
Proposed wording a)
Change in para. 2
Constructs a
piecewise_constant_distribution
object withn = 1
,p0 = w0 = 1
,b0 = 0
, andb1 = 1
and change in para. 5
A
vector<result_type>
whosesize
member returnsn
and whoseoperator[]
member returnsthe weightpk
wk
as a double value when invoked with argumentk
fork = 0, ..., n-1
Proposed wording b)
Change both occurrences of
"piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW, InputIteratorW lastW)and change in para. 3
the length of the sequencew
starting fromfirstW
shall be at leastn
,*firstW
shall return a valuew0
that is convertible todouble
, and anywk
fork >= n
shall be ignored by the distribution[firstW, lastW)
shall form a sequencew
of lengthn
whose leading elementw0
shall be convertible todouble