Move constructor and const member variables

前端 未结 5 957
自闭症患者
自闭症患者 2020-12-30 21:24

I like the idea of const member variables especially when I wrap C functions into classes. The constructor takes a resource handle (e.g. a file descriptor) that stays valid

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-30 21:56

    No, there is no way to do this. I would suggest that if you're really attached to the handle variable being const you should have a non-const flag member variable that indicates whether or not destruction should do anything.

提交回复
热议问题