bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error with bind2nd() and ptr_fun()


From: Alex Vinokur
Subject: Error with bind2nd() and ptr_fun()
Date: Thu, 07 Feb 2002 11:49:25 +0200

===============================================================
Windows98
gpp : GNU C++ version 2.95.3 20010315/djgpp (release) (djgpp)
      compiled by GNU C version 2.95.3 20010315/djgpp (release).
===============================================================


Here is a program and compilation results.

The compiler detects some error
  and informs about "Internal compiler error".

Is there an error in my program?

Or only "Internal compiler error" caused that (!?)

  Thanks.



//============= C++ Code : BEGIN =============
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <functional>

// -------------------------------
class AAA
{
  private :
    string name_;
    int  value_;

  public :
    AAA () {}
    AAA (const string& name_i, int value)
 : name_ (name_i), value_ (value)
    {}
    ~AAA () {}

    int  get_value () {return value_;}
    void set_value (int value) {value_ = value;}
};


// ---------------------------
int foo1 (AAA& inst)
{
  inst.set_value (inst.get_value() + 100);
  return inst.get_value();
}

// ---------------------------
int foo2 (AAA& inst, int value)
{
  inst.set_value (inst.get_value() + value);
  return inst.get_value();
}


// ---------------------------
int main()
{
vector<AAA> vect;

  vect.push_back( AAA("xxx", 3) );
  vect.push_back( AAA("yyy", 5) );

  for_each(vect.begin(), vect.end(), foo1);
  for_each(vect.begin(), vect.end(), ptr_fun (foo1));

  for_each(vect.begin(), vect.end(), bind2nd(ptr_fun(foo2), 200)); //
Line#53

  return 0;
}

//============= C++ Code : END ===============


//=========== Compilation : BEGIN ============

%gpp aaa.c

d:/sys/djgpp/lang/cxx/stl_function.h: In instantiation of
`binder2nd<pointer_to_binary_function<AAA &,int,int> >':
d:/sys/djgpp/lang/cxx/stl_function.h:231:   instantiated from
`bind2nd<pointer_to_binary_function<AAA &,int,int>, int>(const
pointer_to_binary_function<AAA &,int,int> &, const int &)'
aaa.c:53:   instantiated from here
d:/sys/djgpp/lang/cxx/stl_function.h:223: forming reference to reference
type `AAA &const'
d:/sys/djgpp/lang/cxx/stl_function.h:223:
`binder2nd<pointer_to_binary_function<AAA &,int,int> >::operator
()(...)' must be a nonstatic member function
d:/sys/djgpp/lang/cxx/stl_algo.h: In function `class
binder2nd<pointer_to_binary_function<AAA &,int,int> > for_each<AAA *,
binder2nd<pointer_to_binary_function<AAA &,int,int> > >(AAA *, AAA *,
binder2nd<pointer_to_binary_function<AAA &,int,int> >)':
aaa.c:53:   instantiated from here
d:/sys/djgpp/lang/cxx/stl_algo.h:83: warning: cannot pass objects of
type `AAA' through `...'
d:/sys/djgpp/lang/cxx/stl_function.h: At top level:
d:/sys/djgpp/lang/cxx/stl_function.h: In instantiation of
`binder2nd<pointer_to_binary_function<AAA &,int,int> >::operator
()(...)':
d:/sys/djgpp/lang/cxx/stl_algo.h:83:   instantiated from `for_each<AAA
*, binder2nd<pointer_to_binary_function<AAA &,int,int> > >(AAA *, AAA *,
binder2nd<pointer_to_binary_function<AAA &,int,int> >)'
aaa.c:53:   instantiated from here
d:/sys/djgpp/lang/cxx/stl_function.h:223:
`binder2nd<pointer_to_binary_function<AAA &,int,int> >::operator
()(...)' must be a nonstatic member function
d:/sys/djgpp/lang/cxx/stl_function.h: In function `{error}
binder2nd<pointer_to_binary_function<AAA &,int,int> >::operator
()(...)':
d:/sys/djgpp/lang/cxx/stl_function.h:223: Internal compiler error in
`layout_decl', at stor-layout.c:247
Please submit a full bug report.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

//=========== Compilation : END ==============


  ===========================
  Alex Vinokur
    mailto:address@hidden
    mailto:address@hidden
    http://up.to/alexvn
    http://go.to/alexv_math
  ===========================





reply via email to

[Prev in Thread] Current Thread [Next in Thread]