On Mon, Apr 13, 2009 at 5:45 PM, Noah Roberts
Eric Niebler wrote:
Eric Niebler wrote:
Eric Niebler wrote:
There's another consideration that I've been glossing over. mpl::string isn't *really* random access. Since mpl::string<'a','b','c'> designates the same character sequence as mpl::string<'abc'>, it takes O(N) template instantiations to find the N-th element in the sequence, at least in the current implementation. I'd like to fix that, but I don't know how (yet).
Now this is really bothering me. The right thing to do is replace the current implementation with one in which mpl::string is a front- and back-extensible bidirectional sequence, and give up with the random access pretense. :-(
I've made this change. mpl::string is no longer random access (it never really was). Also, I've changed c_str to be a separate metafunction that works with any forward sequence.
Thanks particularly to Noah Roberts for the good feedback.
No problem.
Now someone just needs to make format<> :P
Although a tongue-in-cheek remark, the notion of a compile-time
formatting library somehow appeals to me, if for nothing else for its
sheer absurdity ;)
Due to the limits of preprocessor stringization when dealing with
metaprogramming integers, I suspect it might have its use cases
wherever runtime conversion overhead is best avoided. With mpl::string
it's trivial to create integer-to-string conversion metafunctions, and
it should also not be overly complicated to glue these together into
something bigger if so should desired. I whipped up a quick (and not
very pretty) compile-time _itoa equivalent as a small proof of concept
just for fun (only tested on visual c++ 2008)
#include <iostream>
#include radix_t; template