pointers - Enforce NULL checking in c++ -


my method can return kind of pointer ( example boost::shared_ptr ) , pointer may null. there way enforce users of code check, if empty or not ?

some example of such things - scals's option container, may boost has boost::option ?

you can following:

  • return smart pointer type throws exception if accessed , set null.
  • throw exception instead of returning null pointer
  • return std::optional (or boost::optional) expresses intent (i.e. "value may missing") better pointer

Comments

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -