Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2005-03-31 14:51:10


Bruce Trask <Bruce.Trask_at_[hidden]> writes:

> Hi,
>
> I want to express a "string" value at compile time. I am assuming that
> I have to go with mpl::vector<char> and then convert it at runtime to
> its string format.

I think you mean

   vector_c< char, ... >

That is basically the only way to get types that are guaranteed to be
different if the contents of the string are different.

> I also have tried using
>
> struct TestString
> {
> static const char* getName()
> {
> return "TestStringName";
> }
> };
>
> and then have the user specify TestString and then I write my other code
> to call getName() on the type at runtime.
>
> Are these two choices the best I can hope for with regard to compile-
> time "string" values?

char const test_string[] = "TestStringName";

A pointer or reference to test_string can be used as a template
parameter as long as test_string is declared at namespace scope.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net