On Sat, 18 Jan 2003 14:14:37 -0500, David Abrahams <[EMAIL PROTECTED]> wrote:
>Gennaro Prota <[EMAIL PROTECTED]> writes: > >> On Sat, 18 Jan 2003 13:13:45 -0500, David Abrahams >> <[EMAIL PROTECTED]> wrote: >> >>>Gennaro Prota <[EMAIL PROTECTED]> writes: >>>> Unfortunately >>>> the committee seems on the road of prohibiting this and other similar >>>> (and potentially more useful) uses of string literals in constant >>>> expressions: >>>> >>>> http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html#366 >>> >>>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 ;-) >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. >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? 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? Do you remember my EXPLICIT_CAST? #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? Why prohibiting such a usage in a constant expression? Genny. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost