Topic: Proposal: is_literal<> type traits


Author: AlbertoBarbati@libero.it (Alberto Ganesh Barbati)
Date: Mon, 12 Nov 2007 05:26:24 GMT
Raw View
Hi,

if this hasn't done already, I would propose to add the following type
trait to section [meta.unary.prop]:

  template <class T>
  struct is_literal;

  Condition: T is a literal type (3.9)

I believe this is needed because I can't see a practical way to detect
the literal-ness of T without some assistance from the compiler. (In
particular, the main problem is detecting the presence of a constexpr
constructor.)

Regards,

Ganesh

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: =?iso-8859-1?q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Mon, 12 Nov 2007 08:44:40 CST
Raw View
On Nov 12, 6:26 am, AlbertoBarb...@libero.it (Alberto Ganesh Barbati)
wrote:
> if this hasn't done already, I would propose to add the following type
> trait to section [meta.unary.prop]:
>
>   template <class T>
>   struct is_literal;
>
>   Condition: T is a literal type (3.9)
>
> I believe this is needed because I can't see a practical way to detect
> the literal-ness of T without some assistance from the compiler. (In
> particular, the main problem is detecting the presence of a constexpr
> constructor.)

Hi Ganesh, this proposal does indeed exist:

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#719

Your use-case would be another good reason to add it, I guess ;-)

Greetings from Bremen,

Daniel

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]