This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++/3113: DR 109: missing binders for non-const sequence elements
- To: bkoz at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, kenny dot simpson at gs dot com, nobody at gcc dot gnu dot org, theonetruekenny at yahoo dot com
- Subject: Re: libstdc++/3113: DR 109: missing binders for non-const sequence elements
- From: bkoz at gcc dot gnu dot org
- Date: 11 Jun 2001 17:56:27 -0000
Synopsis: DR 109: missing binders for non-const sequence elements
Responsible-Changed-From-To: unassigned->bkoz
Responsible-Changed-By: bkoz
Responsible-Changed-When: Mon Jun 11 10:56:25 2001
Responsible-Changed-Why:
Mine.
State-Changed-From-To: open->feedback
State-Changed-By: bkoz
State-Changed-When: Mon Jun 11 10:56:25 2001
State-Changed-Why:
Umm. Here's a testcase:
#include <vector>
#include <algorithm> // for_each
#include <functional>
class Elem
{
public:
void print(int i) const { }
void modify(int i) { }
};
// libstdc++/3113
void test01()
{
std::vector<Elem> coll(2);
// OK
std::for_each(coll.begin(), coll.end(),
std::bind2nd(std::mem_fun_ref(&Elem::print), 42));
// OK
std::for_each(coll.begin(), coll.end(),
std::bind2nd(std::mem_fun_ref(&Elem::modify), 42));
}
int main()
{
test01();
return 0;
}
making the following change:
2001-06-11 benjamin kosnik <bkoz@fillmore.constant.com>
libstdc++/3113
* include/bits/stl_function.h (binder2nd): Fix as per DR 109.
(binder1st): Same.
* include/bits/std_queue.h: Add c++config.h.
Index: include/bits/std_queue.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/std_queue.h,v
retrieving revision 1.3
diff -c -p -r1.3 std_queue.h
*** std_queue.h 2001/03/31 20:15:42 1.3
--- std_queue.h 2001/06/11 17:54:46
***************
*** 28,34 ****
#define _CPP_QUEUE 1
#pragma GCC system_header
!
#include <bits/stl_algobase.h>
#include <bits/stl_alloc.h>
#include <bits/stl_construct.h>
--- 28,34 ----
#define _CPP_QUEUE 1
#pragma GCC system_header
! #include <bits/c++config.h>
#include <bits/stl_algobase.h>
#include <bits/stl_alloc.h>
#include <bits/stl_construct.h>
Index: include/bits/stl_function.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_function.h,v
retrieving revision 1.2
diff -c -p -r1.2 stl_function.h
*** stl_function.h 2001/03/04 21:34:01 1.2
--- stl_function.h 2001/06/11 17:54:48
*************** public:
*** 199,204 ****
--- 199,210 ----
operator()(const typename _Operation::second_argument_type& __x) const {
return op(value, __x);
}
+ #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+ // 109. Missing binders for non-const sequence elements
+ operator()(typename _Operation::second_argument_type& __x) const {
+ return op(value, __x);
+ }
+ #endif
};
template <class _Operation, class _Tp>
*************** public:
*** 224,229 ****
--- 230,241 ----
operator()(const typename _Operation::first_argument_type& __x) const {
return op(__x, value);
}
+ #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+ // 109. Missing binders for non-const sequence elements
+ operator()(typename _Operation::first_argument_type& __x) const {
+ return op(__x, value);
+ }
+ #endif
};
template <class _Operation, class _Tp>
Still doesn't make the above compile:
%COMP.sh 3113.cc
/mnt/hd/bliss/src.gcc/libstdc++-v3/include/bits/stl_function.h: In member
function `int std::binder2nd<_Operation>::operator()(typename
_Operation::first_argument_type&) const [with _Operation =
std::const_mem_fun1_ref_t<void, Elem, int>]':
/mnt/hd/bliss/src.gcc/libstdc++-v3/include/bits/stl_algo.h:91: instantiated from `_Function std::for_each(_InputIter, _InputIter, _Function) [with _InputIter = std::__normal_iterator<Elem*, std::vector<Elem, std::allocator<Elem> > >, _Function = std::binder2nd<std::const_mem_fun1_ref_t<void, Elem, int> >]'
3113.cc:18: instantiated from here
/mnt/hd/bliss/src.gcc/libstdc++-v3/include/bits/stl_function.h:236: void value
not ignored as it ought to be
/mnt/hd/bliss/src.gcc/libstdc++-v3/include/bits/stl_function.h: In member
function `int std::binder2nd<_Operation>::operator()(typename
_Operation::first_argument_type&) const [with _Operation =
std::mem_fun1_ref_t<void, Elem, int>]':
/mnt/hd/bliss/src.gcc/libstdc++-v3/include/bits/stl_algo.h:91: instantiated from `_Function std::for_each(_InputIter, _InputIter, _Function) [with _InputIter = std::__normal_iterator<Elem*, std::vector<Elem, std::allocator<Elem> > >, _Function = std::binder2nd<std::mem_fun1_ref_t<void, Elem, int> >]'
3113.cc:21: instantiated from here
/mnt/hd/bliss/src.gcc/libstdc++-v3/include/bits/stl_function.h:236: void value
not ignored as it ought to be
Not quite sure how to solve this last bit. However, the patch doesn't cause any other problems and so it likely to go in anyway.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3113&database=gcc