You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by "Martin Sebor (JIRA)" <ji...@apache.org> on 2006/01/26 01:34:10 UTC
[jira] Created: (STDCXX-126) std::random_shuffle ambiguity with
RandomNumberGenerator
std::random_shuffle ambiguity with RandomNumberGenerator
--------------------------------------------------------
Key: STDCXX-126
URL: http://issues.apache.org/jira/browse/STDCXX-126
Project: STDCXX
Type: Bug
Components: 25. Algorithms
Versions: 4.1.3
Environment: all
Reporter: 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.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (STDCXX-126) std::random_shuffle ambiguity with
RandomNumberGenerator
Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/STDCXX-126?page=comments#action_12364051 ]
Martin Sebor commented on STDCXX-126:
-------------------------------------
Actually, the test case above is slightly wrong. Here's a better one:
$ cat t.cpp && make t
#include <algorithm>
#include <iterator>
template <class IntT>
struct DiffConvertible {
DiffConvertible (IntT) { }
operator IntT () const { return IntT (); }
private:
template <class T> DiffConvertible (T);
};
template <class IntT>
struct Generator {
DiffConvertible<IntT> operator() (IntT n) {
return DiffConvertible<IntT>(n);
}
private:
template <class T> void operator() (T);
};
template <class IntT, class T> void operator+ (T, DiffConvertible<IntT>);
template <class IntT, class T> void operator+ (T, DiffConvertible<IntT>);
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:30: instantiated from here
t.cpp:19: error: 'template<class T> void Generator::operator()(T) [with T = T, IntT = int]' is private
/build/sebor/dev/stdlib/include/algorithm.cc:594: error: within this context
t.cpp:30: 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
> std::random_shuffle ambiguity with RandomNumberGenerator
> --------------------------------------------------------
>
> Key: STDCXX-126
> URL: http://issues.apache.org/jira/browse/STDCXX-126
> Project: STDCXX
> Type: Bug
> Components: 25. Algorithms
> Versions: 4.1.3
> Environment: all
> Reporter: 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.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Assigned: (STDCXX-126) std::random_shuffle ambiguity with
RandomNumberGenerator
Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/STDCXX-126?page=all ]
Martin Sebor reassigned STDCXX-126:
-----------------------------------
Assign To: Martin Sebor
> std::random_shuffle ambiguity with RandomNumberGenerator
> --------------------------------------------------------
>
> Key: STDCXX-126
> URL: http://issues.apache.org/jira/browse/STDCXX-126
> Project: STDCXX
> Type: Bug
> Components: 25. Algorithms
> 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.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Resolved: (STDCXX-126) std::random_shuffle ambiguity with
RandomNumberGenerator
Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/STDCXX-126?page=all ]
Martin Sebor resolved STDCXX-126:
---------------------------------
Resolution: Fixed
Fixed with the referenced change. The test case compiles successfully.
> std::random_shuffle ambiguity with RandomNumberGenerator
> --------------------------------------------------------
>
> Key: STDCXX-126
> URL: http://issues.apache.org/jira/browse/STDCXX-126
> Project: C++ Standard Library
> Type: Bug
> Components: 25. Algorithms
> 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.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira