|
Boost Users : |
Subject: Re: [Boost-users] compile-time string literal manipulation?
From: Eric Niebler (eric_at_[hidden])
Date: 2010-10-27 19:41:53
On 10/27/2010 2:46 PM, Stiles Watson wrote:
> I'm a new to metaprogramming so please bare with the stupid questions:
>
> I have a requirement to convert string literals to a specified format at
> compile-time. In otherwords, given a literal like "3A689", I need to
> verify the value and, if not valid, generate a correct value such that:
>
> //pseudocode
> const char ch[] = verify<"3A689">::valid_value;
>
> would result in something like:
>
> const char ch[] = "03A689X";
>
> Can I use Boost to write a template to do this?
>
> I know that is extremely vague, but does anyone have any thoughts?
Use mpl::string:
http://www.boost.org/doc/libs/1_44_0/libs/mpl/doc/refmanual/string.html
You might find the interface less than ideal. C++ doesn't allow strings
as template parameters.
-- Eric Niebler BoostPro Computing http://www.boostpro.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