Hello all, I'm trying to match ordinal numbers (1st, 2nd, 3rd, 4th etc) like this. *xpr::as_xpr ("Some Text") * * >> xpr::repeat<1, 2>(_d) * * >> ("st"|"nd"|"rd"|"th") ;* Compilation fails at 3rd line with the following error error C2296: '|' : illegal, left operand has type 'const char [3]' ; what am i missing ? did I give the construct correctly ? Thanks in advance, Surya
On Thu, Mar 11, 2010 at 2:29 AM, Surya Kiran Gullapalli
>> ("st"|"nd"|"rd"|"th") ;
That is because "st"|"nd"|etc... you are trying to 'or' two string constants, that makes no sense in C++. You need to 'infect' the whole line by wrapping the first one with as_xpr as: >> (as_xpr("st")|"nd"|"rd"|"th") ;
On Thu, Mar 11, 2010 at 15:58, OvermindDL1
On Thu, Mar 11, 2010 at 2:29 AM, Surya Kiran Gullapalli
wrote: >> ("st"|"nd"|"rd"|"th") ;
That is because "st"|"nd"|etc... you are trying to 'or' two string constants, that makes no sense in C++. You need to 'infect' the whole line by wrapping the first one with as_xpr as: >> (as_xpr("st")|"nd"|"rd"|"th") ;
Thanks, it worked. I thought the first as_xpr would infect everything. but i was mistaken. Surya
On Thu, Mar 11, 2010 at 3:57 AM, Surya Kiran Gullapalli
On Thu, Mar 11, 2010 at 15:58, OvermindDL1
wrote: On Thu, Mar 11, 2010 at 2:29 AM, Surya Kiran Gullapalli
wrote: >> ("st"|"nd"|"rd"|"th") ;
That is because "st"|"nd"|etc... you are trying to 'or' two string constants, that makes no sense in C++. You need to 'infect' the whole line by wrapping the first one with as_xpr as: >> (as_xpr("st")|"nd"|"rd"|"th") ;
Thanks, it worked. I thought the first as_xpr would infect everything. but i was mistaken.
You enclosed all of those in parenthesis which created a new 'scope' (not by the technical definition, but it works here), thus you need to 're-infect' anew since they get run together before the external definition. :)
participants (2)
-
OvermindDL1
-
Surya Kiran Gullapalli