GithubHelp home page GithubHelp logo

hanlulugeren / cplusplus_smartpointer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cognitiveprogrammer/cplusplus_smartpointer

0.0 1.0 0.0 26 KB

This repository contains description of C++11 and C++14 Smart Pointers Trilogy of shared_ptr, unique_ptr and weak_ptr

License: MIT License

C++ 100.00%

cplusplus_smartpointer's Introduction

C++14 Smart Pointers : The trilogy which must be used day in and day out

Prior to arrival of smart pointers as part of boost library, C++ was notorious for memory leaks and errors related to memory handling. In fact, it was very difficult to track memory usage and ownerships in relatively big programs

C++11 and C++14 has taken a great leap forward with regard to memory management and have standardize the smart pointers for the same. This can potentially reduce if not altogether remove the problems associated with memory management in C++

There are multiple sets of smart pointers which are extremely useful, however, as a normal programmer we'll end up using at most 3 of them. These 3 smart pointers are called as a trilogy and is known as

  • shared_ptr<>
  • unique_ptr<>
  • weak_ptr<>

They are pretty much sufficient to handle most of the programming needs related to dynamically allocated memory.

The modules below (1,2,&3) are dedicated to respective pointers. Please do not escape the sequence as module 2 refers to module 1 and module 3 refers to module 1 & 2.

Module - 1 : Usage of shared_ptr<>

This module will describe the properties of shared_ptr<> as well as how the use this smart pointer in C++ programs

Module - 2 : Usage of unique_ptr<>

This module will describe the properties of unique_ptr<> as well as how the use this smart pointer in C++ programs

This program will use examples of module 1 to properly demonstrate the difference between these two pointers.

Module - 3 : Using of weak_ptr<>

This module will describe the properties of weak_ptr<> as well as how the use this smart pointer in C++ programs

The weak_ptr<> is generally used with shared_ptr<> and this module will use both of them drastically

Module - 4 : The std::move semantics

This module will describe the move semantics and how std::move can be used with shared_ptr<> and unique_ptr<>.

This will also touch upon when and how to use std::move()

cplusplus_smartpointer's People

Contributors

9lean avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.