C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Construction d'un binder2nd

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French)
View previous topic :: View next topic  
Author Message
Christophe Brun
Guest





PostPosted: Tue Aug 05, 2003 12:44 pm    Post subject: Construction d'un binder2nd Reply with quote



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





PostPosted: Tue Aug 05, 2003 2:31 pm    Post subject: Re: Construction d'un binder2nd Reply with quote



"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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.