There was some discussion among the extensions subgroup of the C++ standard committee about the question of how the language might be extended to allow string literals to be used as template arguments. That discussion was inconclusive.
It seems to me that the root of the problem is that C-style strings, and hence string literals, are not first-class builtin types in C++. I've been experimenting with one possible solution to that problem: I've (partially) implemented a "static_string" library and uploaded it to the 'Files' section of Boost's Yahoo Group. Here is the abstract from the (also partial) introductory document:
"The static_string C++ library is an alternative to both string literals and the standard C++ type const std::basic_string<char>. Any operation that can be performed upon a const std::basic_string<char> object at runtime can be performed by the static_string library. Furthermore, the static_string library implements a number of metafunctions that allow these operations to be performed at program compile time. The static_string library is significantly more efficient in its use of both time and space than const std::basic_string<char>."
The static_string library allows strings to be represented by types, so that they can be used as template arguments.
The syntax for using static_string is awkward, but a language extension that would make a library like static_string convenient to use might be worth considering as an alternative to the wholesale introduction of string-literals-as-template-arguments to the core language.
A woefully incomplete version of the static_string library can be found at: http://groups.yahoo.com/group/boost/files/static_string.zip
I guess it's not possible to generate the character sequence out of a string literal with the Boost Preprocessor library? That'd make this a whole lot more convenient to use.
Dirk Gerrits
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost