
I want to cast a value of _1 to a _val of a different type. How do I do that? I tried using static_cast_, it does not compile for me. rule<UInt8Iterator, UInt32()> MyRule; ... MyRule = (long_ | float_) [_val = static_cast_<UInt32>(_1)] Any help is appreciated Regards, Henry

On Tue, Sep 28, 2010 at 1:06 PM, Henry Tan <henryws@gmail.com> wrote:
I want to cast a value of _1 to a _val of a different type. How do I do that? I tried using static_cast_, it does not compile for me.
rule<UInt8Iterator, UInt32()> MyRule;
...
MyRule = (long_ | float_) [_val = static_cast_<UInt32>(_1)]
Any help is appreciated
Well considering that (long_ | float_) created a boost::variant<long,float>, what happens it you cast a boost::variant<long,float> to UInt32? Compile time error of course. If you want it 'simple', create a phoenix function boost::variant<long,float> handle to UInt32. If you want it to execute the fastest, then create a customization point in the spirit grammar and do the same thing in it, a bit more involved, but the fastest execution speed.
participants (2)
-
Henry Tan
-
OvermindDL1