Boost logo

Boost :

From: James Curran (jamescurran_at_[hidden])
Date: 2003-03-04 13:10:46


Jason House wrote:
> Well, I know that in MSVC simply refuses to use strings as template
> parameters... If this truly is illegal by the standard, then a string
> template parameter could default to a type for that string. As far as
> use in other places, maybe use of some keyword as a function. Like
> maybe struct("foo").

    Both the Standard & MSVC6 allow a (const char*) as a template parameter.
What is rejected (by both) is a text literal parameter. For a non-type
parameter, the value must be a constant across all translation units linked
together, hence it must be defined extern.

    template <const char* S> SomeClass { ...};

    SomeClass<"YourParam"> NoGood;

extern const char* MyParam = "MyParam";
    SomeClass<MyParam> Acceptable;

--
Truth,
James Curran
www.noveltheory.com (personal)
www.njtheater.com (professional)

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