
Robert Kawulak wrote:
From: Chris Quick question, if I made a NullErrorPolicy, and had compiler optimization on. Shouldn't the compiler remove all bounded checks? (empty) There would be no need for me to worry about optimization and slowness.
This would be probably be the proper way rather than myint types;
#ifdef MYDEBUG typedef NullErrorPolicy Policy; #else typedef throw_exception <http://student.agh.edu.pl/%7Ekawulak/constrained_value/refere nce/structboost_1_1constrained__value_1_1throw__exception.html
<my_exception>
Policy; #endif
And why not simply as described in http://tinyurl.com/6bda78 ?
Because if I have 100 uses of constrained, I don't have 100 typedefs or more templates. I only need that one Policy typedef, and in my code: #ifdef MYDEBUG typedef NullErrorPolicy Policy; #else typedef throw_exception<my_exception> Policy; #endif struct A { bounded_int<int, 0, 100, Policy> a; bounded_int<int, 50, 100, Policy> b; bounded_int<int, 2, 3, Policy> c; }; It would be the same for compiler optimization as unconstrained, wouldn't it? It should remove any useless code.