Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
4.1.2
-
None
-
all
Description
The requirement on the Size template argument to std::generate_n() in lib.alg.generate, p2 is that it be convertible to an integral type which does not imply that it be possible to decrement or otherwise modify its value. I.e., the program below is expected to compile successfully.
$ cat t.cpp && nice make t
#include <algorithm>
struct Size {
operator int()
private:
void operator=(Size&);
};
template void std::generate_n (int*, Size, int ());
int main () { }
eccp -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG -D_RWSTD_USE_CONFIG -I/build/sebor/eccp-3.6-11s/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 -A -x --template_directory=/build/sebor/eccp-3.6-11s/lib -g --display_error_number --remarks --diag_suppress 193,236,340,401,261,479,487,678,679,815 t.cpp
"/build/sebor/dev/stdlib/include/algorithm", line 431: error #349: no operator
"--" matches these operands
operand types are: – Size
for (; _n > 0; --n, ++_first)
^
detected during instantiation of "void std::generate_n(_OutputIter,
_Size, _Generator) [with _OutputIter=int *, _Size=Size,
_Generator=int ()]" at line 9 of "t.cpp"
1 error detected in the compilation of "t.cpp".
Attachments
Issue Links
- relates to
-
STDCXX-121 std::search_n() assumes Size can be incremented
- Resolved
-
STDCXX-84 std::fill_n() assumes Size can be decremented
- Closed