jgehrcke commented on code in PR #15049:
URL: https://github.com/apache/arrow/pull/15049#discussion_r1055410378
##########
cpp/src/arrow/dataset/file_base.h:
##########
@@ -200,6 +200,9 @@ class ARROW_DS_EXPORT FileFormat : public
std::enable_shared_from_this<FileForma
fs::FileLocator destination_locator) const = 0;
/// \brief Get default write options for this format.
+ ///
+ /// May return nullptr if this file format does not yet support writing
Review Comment:
Well. This is interesting! Thanks for raising this.
My C++ is veeery rusty. So, I needed to read a bit. I looked at
https://www.nextptr.com/question/qa1372136808/shared_ptr-initialized-with-nullptr-is-null-or-empty
and
https://stackoverflow.com/questions/37234969/is-it-correct-to-return-null-shared-ptr
and decided to
```cpp
return std::shared_ptr<FileWriteOptions>(nullptr);
```
I think that's what you meant, right? I like that this is explicit. Pushing
a commit.
Someone [pointed out
that](https://stackoverflow.com/questions/37234969/is-it-correct-to-return-null-shared-ptr#comment103737709_37235251)
> I would not use return `shared_ptr<Object>(nullptr);` as `return
shared_ptr<Object>();` is enough. It is a style preference: I don't write
unnecessary stuff, as it might make think others that they are necessary.
I humbly disagree, and like the longer version more. But I usually don't
write C++ so :shrug:
The terminology discussion around "empty" is a bit of a comedy show to me
:-) :clown_face: Not sure if the term "empty" is useful in practice. From said
cppreference page:
> an empty shared_ptr may have a non-null stored pointer
Someone on Stack Overflow _tries to_ clarify:
> The page you linked calls a shared_ptr that owns nothing empty, and a
shared_ptr that points to nothing (i.e., whose get() == nullptr) null. (Empty
is used in this sense by the standard; null isn't.)
Then someone says
> A null-but-nonempty shared_ptrs can be useful!
Someone else replies
> What can a null-but-nonempty shared_ptr do that a non-null-and-nonempty
shared_ptr can't?
Not sure what I am saying and if I want to know about this at all, but it is
possible for a shared_ptr to be non-null but still be empty, as of the
_aliasing constructor_ which
> originates from Bloomberg and was proposed for the standard before it was
implemented in Boost (see
[N1851](http://www.open-std.org/jtc1/SC22/wg21/docs/papers/2005/n1851.pdf)). I
prefer the standard's term "shares ownership with r" to the phrasing "owns
whatever r owns"
SO quotes all from
[here](https://stackoverflow.com/questions/25920681/what-is-the-difference-between-an-empty-and-a-null-stdshared-ptr-in-c).
Trying to fill this rabbit hole and put a lid on it :rabbit:
Thanks for the detour :palm_tree:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]