[Function] "constness" lost on Function Signature

main.cpp 1>..\main.cpp(22) : error C2679: '=' binaire : aucun opérateur trouvé qui accepte un opérande de partie droite de type 'bool (__cdecl *)(const int,float,float)' (ou il n'existe pas de conversion acceptable) 1> C:\Documents and Settings\dfc\Bureau\boost_1_44\boost/function/function_template.hpp(1103):
Hi,
I am using boost::function and have some issues on using it with visual
studio 2005.
If I declare a boost::function with some "const" argument this "constness"
seems to be lost on boost function siganture. Then, future assigment to this
function whith correct "const" argument lead to wrong matching. See code
snipset below.
This work fine under gcc 4.4 and visual 2010.
----------------------------------------------------------------------------------
#include <iostream>
#include <vector>
#include

AMDG On 2/4/2011 1:53 AM, nicolas david wrote:
I am using boost::function and have some issues on using it with visual studio 2005. If I declare a boost::function with some "const" argument this "constness" seems to be lost on boost function siganture. Then, future assigment to this function whith correct "const" argument lead to wrong matching. See code snipset below. This work fine under gcc 4.4 and visual 2010.
---------------------------------------------------------------------------------- <snip> class container_test { public: typedef boost::function
FunctionType; bool static defaultFunctor(const int, float, float) { return true; } //void apply_functor( const FunctionType IsInside = defaultFunctor){} }; <snip> ---------------------------------------------------------------------------------- error send by visual 2005 compiler with "const". If change "const int" to "int" it works. ( sorry for the "french")
This is a compiler bug. Whether the argument is declared const shouldn't affect anything outside of the function body. bool static defaultFunctor(const int, float, float); is exactly equivalent to bool static defaultFunctor(int, float, float); In Christ, Steven Watanabe

This is a compiler bug.
OK, thank you for the information
bool static defaultFunctor(const int, float, float);
is exactly equivalent to
bool static defaultFunctor(int, float, float);
You're right. I shoul'd better try with some "pass by const reference" and use struct or class on my example and not int/float Nicolas David
participants (2)
-
nicolas david
-
Steven Watanabe