Given example below, is there any way to enforce parameter type strictness?
[-- Example begin:
#include
using namespace boost;
// some kind of callback sig.
//
typedef function1 signature;
void fn1(int v) // notice arg by-value (say, user typo)
{
// here, assignments to `v' are lost after
// return
}
void fn2(int & v) // OK
{
// here, assignments to `v' are
// preserved after return
}
int main(int, char**)
{
// I want this to fail at compile-time...
signature f1 = fn1;
// ...and this to work
signature f2 = fn2;
return 0;
}
-- code end]
On my compiler (g++ (GCC) 4.0.2 20051125) everything compiles fine but
ideally, I'd like to fail the first case.
Rationale: Users of my library register callbacks and occasionally
mistype their function signature which causes them to modify temporaries
rather than "out" variables.
Thanks,
--
Slawomir Lisznianski
Paramay Group, LLC
"Programs for Research Machinery"