Skip to content

Instantly share code, notes, and snippets.

@marijanp
Last active January 26, 2022 11:31
Show Gist options
  • Save marijanp/00e9f7d38fb6fa96526e4110f7ec86f7 to your computer and use it in GitHub Desktop.
Save marijanp/00e9f7d38fb6fa96526e4110f7ec86f7 to your computer and use it in GitHub Desktop.
C++ notes

Dealing with raw pointers

int facory_function(Type *t);

int main (int argc, char *argv[]) {
  const std::unique_ptr<Type> t_ptr{ [] {
    Type *t = nullptr;
    if (factory_function(t)) {
      return t;
    }
    else {
      return t;
    }
  } ()};
  
  return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment