Boost logo

Boost Users :

Subject: [Boost-users] [Function] requiring an exact match in function signature?
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2010-04-02 19:04:49


Hello,
 
I'm wondering if there is a way to force boost::function to only accept
functions/functors with the exact same signature.
 
I need this because there are cases in my program where passing a function
with a different but convertible signature is almost certainly an error,
and it would really be nice if such uses triggered a compiler error.
 
For instance, boost::function will readily convert a mutator function
with this signature:
 
T mutate(const T&)
 
to a function with this signature:
 
void mutate(T&)
 
even though the two functions clearly have different semantics.
 
I know I could force the signatures to be the same by simply using
a plain function pointer, but I want to give the user the flexibility
to pass in function objects (functors) as well.
 
Any suggestions?
 
Cheers,
Nate.
_________________________________________________________________
Got a phone? Get Hotmail & Messenger for mobile!
http://go.microsoft.com/?linkid=9724464


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net