[antlr-interest] std::string in C++ code

Smith, Eric V. ericsmith at windsor.com
Wed Feb 13 19:01:01 PST 2002


The C++ code generator uses std::string as the return value for
Token.getText(), among places.  I've got a case where I need to use a
special allocator for speed.  What does everyone think of either
templatizing the code either on an allocator, or on std::string.  That way I
could either pass in a myallocator or std::basic_string<char, traits,
myallocator> depending on which way we go.  I guess it would be easier and
cleaner just to make the whole string a template parameter.

OTOH, I'd also like to templatize the uses of vector<>, map<>, stack<> etc.
on the allocator, so maybe the allocator would need to be a template
parameter everywhere.  Clearly I haven't thought this all the way through
yet.

I haven't looked yet to see how many classes I'd have to touch, but I assume
it would be a lot.  I think default template parameters could be used to
keep the user visible changes to a minimum.

Any thoughts from anyone?

Eric.

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list