Convenient Containers: A usability-oriented generic container library

This page summarizes the projects mentioned and recommended in the original post on /r/C_Programming

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • CC

    A small, usability-oriented generic container library.

  • stb

    stb single-file public domain libraries for C/C++

  • One way around this problem is to declare the container as a pointer to the element type and then store the container’s metadata, alongside its elements, in the heap block to which the pointer points. This approach is already used for dynamic arrays in several container libraries, most notably stb_ds and sds. They place the metadata before the elements and provide the user with a pointer to the elements themselves (this has the nice effect that users can use the [] operator to access elements).

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • SDS

    Simple Dynamic Strings library for C

  • One way around this problem is to declare the container as a pointer to the element type and then store the container’s metadata, alongside its elements, in the heap block to which the pointer points. This approach is already used for dynamic arrays in several container libraries, most notably stb_ds and sds. They place the metadata before the elements and provide the user with a pointer to the elements themselves (this has the nice effect that users can use the [] operator to access elements).

  • STC

    A modern, user friendly, generic, type-safe and fast C99 container library: String, Vector, Sorted and Unordered Map and Set, Deque, Forward List, Smart Pointers, Bitset and Random numbers. (by stclib)

  • … and then used the _Generic mechanism to provide a fully generic API for the generated types and functions. That approach has some advantages over the approach that CC now takes – it’s simpler, it relies on fewer novel tricks, the code is far easier to understand, it works with the language rather than against or around it, it doesn’t lead to a macro hellscape, etc. But it requires the user to define types, and I felt that eliminating this requirement was important to CC’s identity as a “convenient” library. (Also, I was motivated by the recent standardization of typeof to try something that exploits it.) But maybe someone else can take this technique and use it to make something like the original iteration of CC, or make a generic API for an existing, more broadly scoped container library ( u/operamint ).

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts