Re: [boost] possible addition to operators library

2003-03-07 Thread Sam Partington
10:55 AM Subject: Re: [boost] possible addition to operators library Daniel Frey wrote: Daniel Frey wrote: No problem. IIRC it was Peter Dimov who came up with the safe-bool idiom first. At least I saw it first from him. Another way which works but results in worse error messages

Re: [boost] possible addition to operators library

2003-03-07 Thread Daniel Frey
Sam Partington wrote: Hi all, Hate to sound pushy, but I've no answer on this, were the patches ok? Would you like me to repost them? Or should I just drop it? No, please don't drop it. I think it's a good idea, but I haven't found the time to look at your patches closely. I will try

Re: [boost] possible addition to operators library

2003-03-07 Thread David Abrahams
Sam Partington [EMAIL PROTECTED] writes: Hi all, Hate to sound pushy, but I've no answer on this, were the patches ok? Would you like me to repost them? Or should I just drop it? The code looks OK, but the submission won't be complete without patches for the docs and tests. -- Dave

Re: [boost] possible addition to operators library

2003-03-07 Thread Beman Dawes
At 11:08 AM 3/7/2003, David Abrahams wrote: Sam Partington [EMAIL PROTECTED] writes: Hi all, Hate to sound pushy, but I've no answer on this, were the patches ok? Would you like me to repost them? Or should I just drop it? The code looks OK, but the submission won't be complete without

Re: [boost] possible addition to operators library

2003-02-27 Thread Sam Partington
Daniel Frey wrote: Daniel Frey wrote: No problem. IIRC it was Peter Dimov who came up with the safe-bool idiom first. At least I saw it first from him. Another way which works but results in worse error messages is this: template class T, class B = ::boost::detail::empty_base struct

Re: [boost] possible addition to operators library

2003-02-26 Thread Sam Partington
Hi all, Sorry I've been off air for a bit. I'll try to answer as much as I can in this email. Daniel Frey wrote: I also think it would be fair to mention Dave as a contributor, too, as he provided the way to reduce the overhead. Of course, that bit was still there from the first time through,

Re: [boost] possible addition to operators library

2003-02-26 Thread Daniel Frey
Sam Partington wrote: Daniel Frey wrote: I also think it would be fair to mention Dave as a contributor, too, as he provided the way to reduce the overhead. Of course, that bit was still there from the first time through, also whoever came up with the original unspecified-bool-type

Re: [boost] possible addition to operators library

2003-02-25 Thread David Abrahams
Sam Partington [EMAIL PROTECTED] writes: Hi, While making myself an interim shared_resource class, I found myself reusing the shared_ptr safe-bool conversion, and thought that really the idiom ought to go into the operators library. I am unsure about the name, but for now bool_testable

Re: [boost] possible addition to operators library

2003-02-25 Thread Daniel Frey
Essentially you supply a operator! and it supplies an unspecified-bool-type conversion operator. Nice idea! I already had something similar in mind, but you managed to make it really generic. //Key //T: primary operand type //t: values of type T // TemplateSupplied Operations

Re: [boost] possible addition to operators library

2003-02-25 Thread Daniel Frey
Daniel Frey wrote: The only problem I see is that an instance of safe_bool_conversion is created which is not really needed. I suggest to rely on the operator! provided by T: template class T, class B = ::boost::detail::empty_base struct bool_testable : B { private: typedef bool

Re: [boost] possible addition to operators library

2003-02-25 Thread Sam Partington
Daniel Frey wrote: Nice idea! I already had something similar in mind, but you managed to make it really generic. Not really, all I've done is to borrow the code from shared_ptr, and to put into a shape like one of the existing unary operator helpers in operator.hpp. Thanks anyway though :-)

Re: [boost] possible addition to operators library

2003-02-25 Thread David Abrahams
Sam Partington [EMAIL PROTECTED] writes: I thought of this too, but this limits the user to using a member based operator!. So I couldn't do this : class A : public boost::bool_testableA { public: int get(); }; bool operator!(const A a) { return a.get() == 0; } Of course

Re: [boost] possible addition to operators library

2003-02-25 Thread Daniel Frey
Sam Partington wrote: I thought of this too, but this limits the user to using a member based operator!. So I couldn't do this : class A : public boost::bool_testableA { public: int get(); }; bool operator!(const A a) { return a.get() == 0; } Of course I've never

Re: [boost] possible addition to operators library

2003-02-25 Thread Sam Partington
I think I agree, we want to provide as little restrictions as possible. Also seems to me that anyone who declares a global template operator! deserves some problems! So, now with David's suggestion, I've attached what I propose. I've tested to a small extent on MSVC6 and gcc 2.95, which are all

Re: [boost] possible addition to operators library

2003-02-25 Thread David Abrahams
Daniel Frey [EMAIL PROTECTED] writes: Sam Partington wrote: I thought of this too, but this limits the user to using a member based operator!. So I couldn't do this : class A : public boost::bool_testableA { public: int get(); }; bool operator!(const A a) { return

Re: [boost] possible addition to operators library

2003-02-25 Thread David Abrahams
Sam Partington [EMAIL PROTECTED] writes: I think I agree, we want to provide as little restrictions as possible. Also seems to me that anyone who declares a global template operator! deserves some problems! I don't know why you think so. So, now with David's suggestion, I've attached what

Re: [boost] possible addition to operators library

2003-02-25 Thread David Abrahams
Daniel Frey [EMAIL PROTECTED] writes: That won't work as you made it a nested struct so it is still different for all instantiations. I think Dave meant to go for this one: Yup, that's what I meant. BTW, so this safe_bool thing can get further re-used it might make sense to make a special

Re: [boost] possible addition to operators library

2003-02-25 Thread Daniel Frey
David Abrahams wrote: Daniel Frey [EMAIL PROTECTED] writes: That won't work as you made it a nested struct so it is still different for all instantiations. I think Dave meant to go for this one: Yup, that's what I meant. BTW, so this safe_bool thing can get further re-used it might

Re: [boost] possible addition to operators library

2003-02-25 Thread David Abrahams
Daniel Frey [EMAIL PROTECTED] writes: David Abrahams wrote: Daniel Frey [EMAIL PROTECTED] writes: That won't work as you made it a nested struct so it is still different for all instantiations. I think Dave meant to go for this one: Yup, that's what I meant. BTW, so this safe_bool

Re: [boost] possible addition to operators library

2003-02-25 Thread Douglas Paul Gregor
On Tue, 25 Feb 2003, David Abrahams wrote: namespace boost { struct safe_bool { int value; typedef int safe_bool::*type; }; } struct myclass { operator boost::safe_bool::type() const { return expression ? boost::safe_bool::value : 0; } };