Topic: template class and bind2nd
Author: David Leal =?iso-8859-1?Q?Valma=F1a?= <leal@inad.es>
Date: 2000/08/30 Raw View
Dear members:
I have defined a simple static template class for coping a vector in to
another one if some condition hold for all elements, when I call it in
the following way Microsoft Visual C++ doesn't compile:
stdE::vectorOp<int,std::bind2nd(std::greater<int>,0)>::copy(in,out,index,
std::bind2nd(std::greater<int>(),0));
(see below for looking to output window after compiling)
a) I have checked also that for template function it works, for example,
when I use:
std::find_if(positiveVec.begin(),positiveVec.end(),std::bind2nd(std::greater<int>(),0));
b) And also if I define a positive object function ( particular case of
greater) it works, for example:
stdE::vectorOp<int,stdE::isPositive<int>
>::copy(in,out,index,stdE::isPositive<int> ());
way?
Thank in advance,
David Leal
==========================================================
Output Window after compiling (errors)
:\projects\alsa\modulo de planificacion de
talleres\code\main\stdextensionfunctions.h(36) : error C2275:
'std::greater<int>' : illegal use of this type as an expression
c:\projects\alsa\modulo de planificacion de
talleres\code\main\stdextensionfunctions.h(36) : error C2955: 'vectorOp'
: use of class template requires template argument list
c:\projects\alsa\modulo de planificacion de talleres\code\global
definition library\stlextension\stdevector.h(204) : see declaration of
'vectorOp'
c:\projects\alsa\modulo de planificacion de
talleres\code\main\stdextensionfunctions.h(36) : error C2670: 'copy' :
the template function cannot convert parameter 1 from type 'class
std::vector<int,class std::allocator<int> >'
Error executing cl.exe.
main.exe - 3 error(s), 0 warning(s)
====================================================
Vector operation definition:
====================================================
template <class T, class Op>
class vectorOp
{
public:
static bool copy (const std::vector<T>& in, std::vector<T>& out,
int& index, Op unaryPred)
{
......
}
};
====================================================
--
---------------------------------------------------------
David Leal | Tel: +34 91 404 84 50
INAD,INtelligent ADvisors | Fax: +34 91 403 94 36
Albacete, 4 | e-mail: leal@inad.es
28027 Madrid | http:// www.inad.es
(Edificio de AGF) |
---------------------------------------------------------
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]