[bind10-dev] suggested team call agenda
Francis Dupont
fdupont at isc.org
Wed Dec 12 08:30:57 UTC 2012
> Yeah, in this discussion, we should at least distinguish the direct
> use of pointer value as boolean like
>
> Foo* foo;
> if (foo) {
> ...
> }
=> IMHO this is bad style because foo is in no way a boolean.
> and the use of smart pointer objects in a boolean context via
> (an implicit call to) boolean type conversion operator
>
> shared_ptr<Foo> foo;
> if (foo) { // this is actually "if (foo.convert_to_bool())"
> ...
> }
=> IMHO this is good style because shared_ptr has the boolean operator.
> I tried to explain the difference in
> http://bind10.isc.org/ticket/2377#comment:19 but there still seems to
> be some confusion.
=> there should not: the test part of a "if" is a boolean so there is
either no ambiguity or a typing error (unfortunately hidden by most
compilers).
> Note that here I'm not talking about whether or not the first is a
> bad/acceptable style. I'm simply pointing out that it doesn't
> (necessarily) make sense to discuss the former style based on whether
> the latter style is acceptable.
=> I fully agree.
Regards
Francis Dupont <fdupont at isc.org>
More information about the bind10-dev
mailing list