Boost logo

Boost Users :

From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2007-01-02 12:09:26


Doug Gregor wrote:
> On Dec 27, 2006, at 5:00 PM, Slawomir Lisznianski wrote:
>
>>Given example below, is there any way to enforce parameter type
>>strictness?
>>[snip]
>>typedef function1<void, int &> signature;
>>
>>void fn1(int v) // notice arg by-value (say, user typo)
>>{
>> // here, assignments to `v' are lost after
>> // return
>>}
>>[snip]
>> // I want this to fail at compile-time...
>> signature f1 = fn1;
>>[snip]
>>On my compiler (g++ (GCC) 4.0.2 20051125) everything compiles fine but
>>ideally, I'd like to fail the first case.
>
>
> I don't know of any way to enforce parameter type strictness. It
> would probably require looking into the actual function object that
> the user has passed, then using some kind of metaprogram to determine
> if the parameters are strict enough.

I think the signature can to some extend be respected by passing
something line a boost::reference_wrapper<int> instead of an int&.

-Thorsten


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