operator bool()
authorNicholas Ormrod <njormrod@fb.com>
Wed, 29 Oct 2014 20:03:02 +0000 (13:03 -0700)
committerdcsommer <dcsommer@fb.com>
Wed, 29 Oct 2014 23:08:05 +0000 (16:08 -0700)
Summary:
Among all of the implicit conversions, conversion to bool is
particularly tricky. For this reason, it has a special call-out in flint
among the casts, and canno be overriden.

However, there are legitimate use cases for operator bool. In this case,
we have a iterator that logically represents a bool but in practice
represents a packed integral. This class needs to be implicitly
convertible to bool, and warrants an override.

Push blocking tests have had over a day to complete, but haven't.
Further, the folly change is comment-only.

Test Plan:
Build flint, run it on BitIteratorDetail.h, see no more lint
errors

Reviewed By: andrei.alexandrescu@fb.com

Subscribers: sdwilsh, louisk, njormrod, folly-diffs@

FB internal diff: D1644141

Tasks: 5486739

Signature: t1:1644141:1414607351:29740da758b75187f4f7b6b5a5ad28a523e7080d

folly/detail/BitIteratorDetail.h

index eb8edcd6f67b7abb6d8240206dc5abbe0442f661..34ccb4bcced21a46d464bd95c6d17483997eaf27 100644 (file)
@@ -36,7 +36,7 @@ class BitReference {
  public:
   BitReference(Ref r, size_t bit) : ref_(r), bit_(bit) { }
 
-  operator bool() const {
+  /* implicit */ operator bool() const {
     return ref_ & (one_ << bit_);
   }