Giter Club home page Giter Club logo

safelist's Introduction

safelist -- An memory-safe linked list in C++

Build Status

This repository contains a header-only reimplementation of std::list using the memory constructs introduced in C++11. The goals of this project is as follows:

  • Have a delete-free implementation of a linked list
  • Prevent use-after-free memory errors
  • Prevent dangling pointers
  • Prevent memory leaks

Other problems, such as null-pointer dereferencing are still very much possible and will still occur, but will be more predictable.

Usage

The safelist is designed as a drop-in replacement for std::list, so replacing it should not be a problem. Include safelist.hpp wherever you would normally include list, and change your types accordingly.

Not everything is implemented exactly as it is in std::list. Key differences are:

  • Allocator is not specifiable, and is the default allocator
  • Features are lacking according to what it says in Progress
  • Not all typedefs are implemented
  • Not all undefined behaviour works the same way. For instance, iterating past the end causes a loop back to the start.
  • The move variant of merge() is missing, because there is no real benefit to it in this implementation.
  • The move variant of splice() is missing for the same reason.

Progress

Basic use

  • Empty constructor
  • Count constructor
  • Range constructor
  • Assignment operators
  • Push back/push front
  • Emplace back/emplace front
  • Pop back/pop front
  • Iterators
  • Const iterators
  • Reverse iterators
  • Const reverse iterators
  • Insert at iterator
  • Emplace at iterator
  • Delete at iterator
  • Sizing
  • Resizing

Comparisons

  • Equality/inequality
  • Greater than/less than

Algorithmic use

  • sort
  • merge
  • splice
  • remove (if)
  • reverse
  • unique

Why would you do this?

I learned about C++ smart pointers but since the main things I write code for are university assignments (not a lot of memory management in general) and programming contest submissions (no need for readable, maintainable code) so I never looked into it.

For the summer I wanted a programming challenge to do, so here it is.

safelist's People

Contributors

bertptrs avatar

Stargazers

Balázs Kovács avatar Don Robert Pornaras avatar

Watchers

 avatar  avatar

Forkers

scroot

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.