Gennaro Prota <[EMAIL PROTECTED]> writes: >>>>Huh? They're already prohibited. >>> >>> I meant that they (you ;-)) want to prohibit any use of string >>> literals in constant expressions. >> >>Nobody "wants to". > > Ah ok. Everybody has always been wanting to ;-)
Desires and intentions are sometimes different. >>It's not well-defined in the standard what it means to treat a string >>literal as an integral constant expression. Nobody ever intended them >>to be integral constant expressions. > > Here we go. What is that supposed to mean? >>In standardization, you don't >>resolve problems like this by exploiting loopholes, and especially >>during this stage of standardization, which is dedicated to closing >>them. If you want to enable a new capability, you deal with it >>separately and intentionally. > > I see. Can we expect an "extension" for C++0x then? Not unless someone makes a formal proposal. Are you volunteering? > As I hinted at in a previous post, the limitations about integral > constant expressions are a little odd to me. For instance, why > prohibiting the comma operator? I don't know; maybe because there's some implication about order of evaluation? Did you check D&E? > Do you remember my EXPLICIT_CAST? Nope. > #define EXPLICIT_CAST(dst_type, expr) \ > ( static_cast< check_helper<dst_type, \ > sizeof(implicit_cast<dst_type>(expr)) > \ > :: type>(expr) ) > > The intent was for it to be suitable for constant expressions. Well, > as you may have noticed the check_helper<> template was there just > because I couldn't do something like: > > > template <typename T> > void implicit_cast (typename identity<T>::type x) { > return x; > } > > > template <typename T> > char implicit_cast (...); > > #define EXPLICIT_CAST(dst_type, expr) \ > ( sizeof( implicit_cast<dst_type>(expr) ) \ > , \ > static_cast<dst_type>(expr) \ > ) > > > This seems natural: you use sizeof to check whether implicit > conversion happens, then you discard its result. What's wrong with > it? For one thing, it doesn't check whether an implicit conversion occurs. For another thing, it would be a compile-error if the expression *can* be implicitly converted to the destination type, which makes no sense to me. But I assume that's not what you're concerned with here ;-) > Why prohibiting such a usage in a constant expression? Yer askin' the wrong guy. -- David Abrahams [EMAIL PROTECTED] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost