Hal Finkel wrote:
Eric,
Thank you, I'll use the predicate approach for now. I like the idea of using an array base because I have a lot of existing C and C++ code which treats complex numbers as a 2 element array, and accesses the members using the [] operator. I think this is common in high-performance scientific codes. I'm afraid doing it another way could lead to the generation of a large number of conditionals which the optimizer can't figure out how to eliminate (meaning (idx ? imag() : real()), I'd have to test this on several platforms), or the introduction of a lot of casts.
If you're going that route, you could just drop boost::array and use native arrays: proto::terminal< double[2] >::type Then your grammar changes to: proto::and_< proto::terminal<_>, proto::if_<boost::is_array<proto::_value>()>
HTH, -- Eric Niebler BoostPro Computing http://www.boostpro.com