http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59042
Bug ID: 59042
Summary: Declaration of back_insert_iterator::value_type is
incorrect
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: cdodd at acm dot org
The declaration of std::back_insert_iterator::value_type is incorrect in the
header file. The following small test program should compile without errors or
warnings, demonstrating the problem:
#include <iostream>
#include <iterator>
#include <vector>
template<class OutputIterator>
void output(OutputIterator &&iter, typename OutputIterator::value_type val)
{
*iter++ = val;
}
int main()
{
std::vector<int> vec;
output(back_inserter(vec), 10);
std::cout << vec.size() << std::endl;
return 0;
}
The fix is quite trivial -- just fix the declaration in the header file:
--- libstdc++-v3/include/bits/stl_iterator.h-orig 2013-11-07
10:11:54.991166661 -0800
+++ libstdc++-v3/include/bits/stl_iterator.h 2013-11-07 10:05:40.414571676
-0800
@@ -400,7 +400,7 @@
*/
template<typename _Container>
class back_insert_iterator
- : public iterator<output_iterator_tag, void, void, void, void>
+ : public iterator<output_iterator_tag, typename _Container::value_type,
void, void, void>
{
protected:
_Container* container;
There are probably other places in the library that have similar problems
(front_insert_iterator)