Is there a proper 'ownership-in-a-package' for 'handles' available?

后端 未结 2 1955
感情败类
感情败类 2020-12-04 02:31

Handles have proper semantics other than pointers. So for me an example like this (extracted from the Rule of Zero):

class module {
public:
    explicit modu         


        
相关标签:
2条回答
  • 2020-12-04 03:05

    std::experimental::unique_resource

    0 讨论(0)
  • 2020-12-04 03:18

    The type unique_ptr is less general than the phrase "handle", yes. But why shouldn't it be? Just one of your "handle" examples (say, the one that is an integer index), is precisely as general as unique_ptr. You can't compare one specific kind of handle with "all handles ever".

    If you want a single, concrete C++ type (or type template) that is a handle without actually defining any specific handling semantics then... I can't help you. I don't think anyone tractibly could.

    0 讨论(0)
提交回复
热议问题