Question about functional operators on bit-ops (~, &, |, ^, +)
This is more of a newbie question I admit but then that's appropriate here as I understand. :) Really, my question comes down to perhaps ignorance of the ISO spec (need to get around to buying a copy! -- and YES, I know EXACTLY what I'd be getting into! ;) and determine whether this is really just lack of conformance on my compiler's part (you know the one, using Dinkumware 1.0 for 5 years) or an issue addressed by boost. Anyway, cut to the chase: I am looking for unary (binary) functions of this form: // TEMPLATE STRUCT compliment template<class _Ty> struct compliment : std::unary_function<_Ty, _Ty> { inline _Ty operator()(const _Ty& _X) const {return (~_X); } }; // TEMPLATE STRUCT unary_no_op template<class _Ty> struct unary_no_op : std::unary_function<_Ty, _Ty> { inline _Ty operator()(const _Ty& _X) const {return (_X); } }; That is, wrappers for compliment (~), unary positive (+), binary bitwise-and (&), bitwise-or (|) and bitwise-XOR (^) as well as the second concept I listed: the unary_no_op, which though functionally similar to unary "+" is none the less unique in that is really does nothing, where as +_X calls _X.operarot+(). [Yes, I know the "no-op" unary is somewhat silly in its usefulness but I only suggest it for abstraction purposes. I can give an example how it would be useful, but the code would likely be flawed in other senses to I'll reserve that until I need to justify such a construct.] Anyway, so first: Am I just missing something? I don't think the standard defines a "compliment" functional object but if it does, can someone tell me? And if as I believe it's not, given the usefulness of such a template functional object (regardless of boost's Lambda lib), where would I find the definition in boost of such functors listed above? If it's not defined, is there any reason we'd not like to see such an operator standardized? I mean, I'd be happy to do the trivial work of create such a list for boost but then I can only believe if it was wanted it would have been done. Then again, it's wanted by me so I suppose it's not completely unreasonable to expect it to be here but that's a whole other issue. So is there a standard (std:: or boost::) complement class, bitwise_and, etc. that is NOT confused with the ISO646 definitions? Thanks in advance and hope I was clear and did not offend with this possibly silly question. Jeffrey.
participants (1)
-
Jeffrey C. Jacobs