Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #4693
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!.POSTED!not-for-mail |
|---|---|
| From | Martijn van Buul <pino@dohd.org> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: const_cast |
| Date | Wed, 4 May 2011 19:06:58 +0000 (UTC) |
| Organization | Eindhoven University of Technology |
| Lines | 14 |
| Message-ID | <slrnis38ui.1ged.pino@mud.stack.nl> (permalink) |
| References | <f044ae2a-88f0-49c2-9f09-619cad881832@glegroupsg2000goo.googlegroups.com> |
| Reply-To | pino+comp_lang_c++@dohd.org (Martijn van Buul) |
| NNTP-Posting-Host | news.stack.nl |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Trace | mud.stack.nl 1304536018 58571 2001:610:1108:5011::97 (4 May 2011 19:06:58 GMT) |
| X-Complaints-To | abuse@stack.nl |
| NNTP-Posting-Date | Wed, 4 May 2011 19:06:58 +0000 (UTC) |
| User-Agent | slrn/0.9.9p1 (FreeBSD) |
| X-Favourite-Drink | Alcoholic, yet fluid |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c++:4693 |
Show key headers only | View raw
* asit: > is there any way to know if const_cast fails ?? const_cast can't "fail", other than with a compiler error if you're casting away more than just 'const'. However, this doesn't mean that the resulting code will actually work. It may still trigger undefined behaviour, and there's no way to "detect" that at runtime. In that respect, const_cast *always* fails; you're throwing away a valuable contract, and is inherently dangerous. I suppose it is still preferable over a C-style cast, though. -- Martijn van Buul - pino@dohd.org
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
const_cast asit <lipun4u@gmail.com> - 2011-05-04 11:40 -0700 Re: const_cast Noah Roberts <dont@email.me> - 2011-05-04 11:55 -0700 Re: const_cast Martijn van Buul <pino@dohd.org> - 2011-05-04 19:06 +0000 Re: const_cast Qi <no@no.no> - 2011-05-05 10:05 +0800
csiph-web