[constrained-value] zero-overhead

One more wish/requirement for cv. Maybe this is already met? I haven't checked. I want to be able to select a policy that does nothing, and on (reasonably modern compilers) achieve performance comparable to the underlying (int) type. That is, I want to use this like logging - where I can switch it off at compile time and make the overhead negligible.

Neal, I just tested this out last night and it already achieves this (on reasonably modern compilers ;-) but you may have to switch from "Debug" mode to "Release" mode, i.e. switch on optimizations. That was with VC++2005. Cheers -- Martin
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Neal Becker Sent: 30 August 2007 12:08 To: boost@lists.boost.org Subject: [boost] [constrained-value] zero-overhead
*** WARNING ***
This mail has originated outside your organization, either from an external partner or the Global Internet. Keep this in mind if you answer this message.
One more wish/requirement for cv.
Maybe this is already met? I haven't checked.
I want to be able to select a policy that does nothing, and on (reasonably modern compilers) achieve performance comparable to the underlying (int) type. That is, I want to use this like logging - where I can switch it off at compile time and make the overhead negligible.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
SELEX Sensors and Airborne Systems Limited Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL A company registered in England & Wales. Company no. 02426132 ******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ********************************************************************

Dowie, Martin (SELEX) (UK) wrote:
Neal,
I just tested this out last night and it already achieves this (on reasonably modern compilers ;-)
There should still be some differences, because of the ABI. C++ compilers usually use a mangled C ABI, which behaves differently for struct or class types, even if those have the same size and alignment requirements as some other built-in types.

From: Neal Becker I want to use this like logging - where I can switch it off at compile time and make the overhead negligible.
I wrote a simple test function: int test() { bounded_int<int, -3, 7>::type b(5); b++; b -= 1; return b; } I compiled it with gcc 4.01, optimisations turned on. I had to add explicit 'inline' to several functions, and then the assembler output was as follows: __Z4testv: LFB1019: pushl %ebp LCFI17: movl $5, %eax movl %esp, %ebp LCFI18: popl %ebp ret I dare to say it couldn't be optimised more now... ;-) Best regards, Robert
participants (4)
-
Dowie, Martin (SELEX) (UK)
-
Mathias Gaunard
-
Neal Becker
-
Robert Kawulak