Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a boolean conversion to
intrusive_ptr
. (#535)
This change adds a boolean conversion to `intrusive_ptr`. While type conversions are frowned upon by the Google style guide, boolean conversions of this form are highly idiomatic for C++ smart pointers, and are defined on both `std::unique_ptr` and `std::shared_ptr`. This method allows more syntactically-fluid use of the `GetIf` function on `Attribute`, as with it we can write code like so: ``` if (intrusive_ptr<Int64Attribute> int64_attr = attr.GetIf<Int64Attribute>()) { ... } ``` with the conversion to `bool` allowing for the testing of the introduced `int64_attr` local. Closes #535 COPYBARA_INTEGRATE_REVIEW=#535 from google-research:intrusive_ptr_convert_to_bool@winterrowd d9d75ce PiperOrigin-RevId: 443711224
- Loading branch information