|
Boost : |
Subject: Re: [boost] [review][constrained_value] Review of Constrained Value Library begins today
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2008-12-01 12:32:43
Zach Laine wrote:
> The docs include some example code on "using constrained objects in
> debug mode only", and make reference to using unconstrained<> to allow
> use of the .value() member function. Why not replace the .value()
> member function with a free function
> boost::constrained_value::value(), and then write something like this?
>
> #ifndef NDEBUG
> typedef bounded_int<int, 0, 100>::type my_int;
> #else
> typedef int my_int;
> # if IM_FINE_WITH_MACROS
> # define value(x) x
> # else
> inline int value(int x) { return x; }
> # endif
> #endif
>
> Then, as long as the user always writes "value(x)", letting ADL pick
> up the boost::constrained_value::value() free function, the
> macro/inline function above will silently kick in instead if defined.
> This gets rid of any requirements on the quality of the optimizer in
> order to get performance just like an int. Did you already try this
> and find it problematic?
>
Intuitively, I'd say this is problematic - the value(int) version
wouldn't get picked up by ADL.
Sebastian
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk