std::mem_fun_ref fails to accept a member function whose second argument can be
bound to a default value.  In this example, I use vector<>::resize.  

Test case:
#include <vector>
#include <functional>
#include <algorithm>

using std::vector;
using std::mem_fun_ref;
using std::bind2nd;
using std::for_each;

typedef vector<int>             int_vec;
Test case:

typedef vector<int_vec>         matrix;

void
test(void) {
        matrix M;
        M.resize(4);
        for_each(M.begin(), M.end(),
                bind2nd(mem_fun_ref(&int_vec::resize), 4));
}

Compile: g++ -O3 -W -Wall -Werror -ansi -pedantic-errors  -c vector.cc -o
vector.o

Diagnostic:
vector.cc: In function 'void test()':
vector.cc:18: error: no matching function for call to 'mem_fun_ref(void
(std::vector<int, std::allocator<int> >::*)(long unsigned int, int))'
make: *** [vector.o] Error 1

Known to "work": 4.0.1
Fail: 4.3.2 4.3.3

I'm not sure if this is valid code.  However, the standard seems to indicate
that resize(size_type), is a required member function (or at least interface)
of std::vector.  Does the standard (20.6.13) allow mem_fun_ref and such to bind
to member functions with default values in the tail position?


-- 
           Summary: std::mem_fun_ref fails to accept a member function whose
                    second argument with default value
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fang at csl dot cornell dot edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39136

Reply via email to