 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Christophe Brun Guest
|
Posted: Tue Aug 05, 2003 12:44 pm Post subject: Construction d'un binder2nd |
|
|
Messieurs dames,
Allez, une petite question avant d'aller prendre un peu le frais en
Bretagne...
Soit le code suivant qui, comme vous vous en doutez, ne compile pas :
Code:
#include <functional>
typedef pair< long, long > range_T;
struct followsRange : public binary_function< const range_T&, const
range_T&, bool >
{
bool operator()( const range_T& range1_P, const range_T& range2_P )
const
{
return ( range2_P.first >= range1_P.second );
}
};
void Binders()
{
range_T range( 0, 0 );
followsRange fct;
binder2nd< followsRange > binder( fct, range );
}
Réponse du compilateur :
BCB5 a écrit:
[C++ Erreur] function.h(322): E2350 Impossible de définir un pointeur
ou une référence sur une référence
[C++ Erreur] Main.cpp(81): E2450 Structure 'binder2nd<followsRange>'
non définie
Question de votre dévoué serviteur :
Dévoué serviteur a écrit:
Pourquoi ?
|
|
| Back to top |
|
 |
Christophe Brun Guest
|
Posted: Tue Aug 05, 2003 2:31 pm Post subject: Re: Construction d'un binder2nd |
|
|
"Christophe Brun" <herode (AT) club-internet (DOT) fr> a écrit dans le message de
news:3f2fa6af$0$9625$7a628cd7 (AT) news (DOT) club-internet.fr...
| Quote: | Messieurs dames,
Ne cherchez plus, je tiens la réponse. |
Pour ceux que ça intéresse, l'erreur vient d'une mauvaise déclaration des
arguments template dans la définition du foncteur followsRange :
| Quote: | struct followsRange : public binary_function< const range_T&, const
range_T&, bool
{
bool operator()( const range_T& range1_P, const range_T&
range2_P ) const
{
return ( range2_P.first >= range1_P.second );
}
};
|
La déclaration correcte est en fait de la forme :
struct followsRange : public binary_function< range_T, range_T, bool >
{
bool operator()( const range_T& range1_P, const range_T& range2_P ) const
{
return ( range2_P.first >= range1_P.second );
}
};
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|