[
https://issues.apache.org/jira/browse/STDCXX-126?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Martin Sebor closed STDCXX-126.
-------------------------------
Regression test committed in
[r650361|http://svn.apache.org/viewvc?rev=650361&view=rev].
> std::random_shuffle ambiguity with RandomNumberGenerator
> --------------------------------------------------------
>
> Key: STDCXX-126
> URL: https://issues.apache.org/jira/browse/STDCXX-126
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 25. Algorithms
> Affects Versions: 4.1.3
> Environment: all
> Reporter: Martin Sebor
> Assignee: Martin Sebor
> Priority: Minor
> Fix For: 4.1.4
>
>
> From 25.2.11, p3 [lib.alg.random.shuffle]:
> -3- Note random_shuffle() can take a particular random number generating
> function object rand such that if n is an argument for rand, with a positive
> value, that has type iterator_traits<RandomAccessIterator>::difference_type,
> then rand(n) returns a randomly chosen value, which lies in the interval [0,
> n), and which has a type that is convertible to
> iterator_traits<RandomAccessIterator>::difference_type.
> The program below conforms to the requirement above yet fails to compile:
> $ cat t.cpp && make t
> #include <algorithm>
> #include <iterator>
> #include <cstddef>
> template <class IntT>
> struct Generator
> {
> struct DiffConvertible {
> DiffConvertible (IntT) { }
> operator IntT () const { return IntT (); }
> };
> DiffConvertible operator() (DiffConvertible n) const {
> return DiffConvertible (IntT (n));
> }
> private:
> void operator() (unsigned) { }
> void operator() (unsigned long) { }
> };
> int main ()
> {
> Generator<std::iterator_traits<int*>::difference_type> gen;
> std::random_shuffle<int*>(0, 0, gen);
> }
> gcc -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG -pthreads
> -D_RWSTD_USE_CONFIG -I/build/sebor/gcc-4.0.2-15s/include
> -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/../rwtest
> -I/build/sebor/dev/stdlib/../rwtest/include
> -I/build/sebor/dev/stdlib/tests/include -pedantic -nostdinc++ -g -W -Wall
> -Wextra -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long t.cpp
> /build/sebor/dev/stdlib/include/algorithm.cc: In function 'void
> std::random_shuffle(_RandomAccessIter, _RandomAccessIter,
> _RandomNumberGenerator&) [with _RandomAccessIter = int*,
> _RandomNumberGenerator = Generator<int>]':
> t.cpp:26: instantiated from here
> t.cpp:18: error: 'void Generator<IntT>::operator()(unsigned int) [with IntT =
> int]' is private
> /build/sebor/dev/stdlib/include/algorithm.cc:594: error: within this context
> t.cpp:26: instantiated from here
> /build/sebor/dev/stdlib/include/algorithm.cc:594: error: void value not
> ignored as it ought to be
> make: *** [t.o] Error 1
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.