Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #4693
| From | Martijn van Buul <pino@dohd.org> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: const_cast |
| Date | 2011-05-04 19:06 +0000 |
| Organization | Eindhoven University of Technology |
| Message-ID | <slrnis38ui.1ged.pino@mud.stack.nl> (permalink) |
| References | <f044ae2a-88f0-49c2-9f09-619cad881832@glegroupsg2000goo.googlegroups.com> |
* 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