Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 5
    Can we get off the train of "raw pointers are so evil". There is nothing wrong with non-owning raw pointers. Commented Mar 15, 2016 at 13:03
  • @StoryTeller The reason for the existence of std::experimental:: observer_ptr is precisely because raw pointers are evil, especially when used as observers, simply because a user can hijack them by mistake. Commented Mar 15, 2016 at 13:06
  • 2
    @StoryTeller you're right. The language feature itself is necessary and 'not evil', but the use of it as part of an interface certainly is. I'll update the answer. Commented Mar 15, 2016 at 13:09
  • 2
    @A.B. I assume you mean when using the C features from the C++ programs? I would encourage you to wrap the C pointers in C++ smart pointers at the earliest opportunity. The custom deleter of the smart pointers makes this possible in every scenario. Commented Mar 15, 2016 at 13:13
  • 1
    @A.B. The win32 API was written in C a long time ago, and the MFC was written before people knew better (and indeed before c++ was mature). Microsoft's APIs are not a model of the future, more a warning about the past ;-) Commented Mar 15, 2016 at 13:21