Boost logo

Boost :

From: Atsushi Togawa (togawa_at_[hidden])
Date: 2000-11-09 05:37:46


on 00.11.9 6:53 PM, Michel André at michel.andre_at_[hidden] wrote:

> I have tried this approach with templates but
> there seems to be an error when using const char* as
> template parameter. Also the myenum constructor fails
> to compile (BTW I use MSVC).

 The standard(14.3.2.2) says,
"[Note: A string literal (2.13.4) is not an acceptable template-argument
because a string literal is an object with internal linkage."

 The template will work if the 2nd argument is a pointer to an external
character array instead of a string literal. In an example, the following
code will work.

 char p[] = "MyEnum1"; // this variable must be extern
 typedef EnumVal<1,p> MyEnum1;


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk