|
Boost : |
From: Beman Dawes (beman_at_[hidden])
Date: 2001-05-02 08:05:47
At 01:20 PM 5/1/01 -0400, Doug Gregor wrote:
>>
>> I think this is the least bad option. Most operator()'s are const, and
in
>> the case where the function object has _only_ a non-const operator(), a
>> dummy const version (that throws an exception) will have to be added by
>the
>> user.
>
>It strikes me as dangerous that we put off what is usually a compile-time
>check for const-correctness until run-time. However, I see no other way
to
>get both const and non-const versions working properly: using
>either virtual
>functions or type erasure, both const and non-const must be instantiated,
so
>
>even if const is invalid for a specific function object something must
>happen
>- but it has to be at run-time. Perhaps that is just the price of
>flexibility.
What about declaring but not defining, to turn it into a link-time error?
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk