mcpp index

compat.gtl

#include

Greg's Template Library — C++20 hash maps, btrees, bit vectors and utilities (header-only)

#include <gtl/phmap.hpp>
mcpp add compat.gtl@1.2.0

Usage

From this repository's own test project — built and run by CI, not written for the website.

// compat.gtl — exercise the two container families that are the reason to pull
// gtl in: the Swiss-table flat_hash_map and the ordered btree_set. Every check
// asserts observable behaviour (contents, ordering, erasure), not just that the
// headers compile.
#include <gtl/phmap.hpp>
#include <gtl/btree.hpp>
import std;

int main() {
    bool ok = true;
    auto check = [&](bool cond, std::string_view what) {
        if (!cond) {
            std::println("FAIL: {}", what);
            ok = false;
        }
    };

    // ---- flat_hash_map ---------------------------------------------------
    gtl::flat_hash_map<std::string, int> m;
    for (int i = 0; i < 1000; ++i) m.emplace(std::format("k{}", i), i);
    check(m.size() == 1000, "flat_hash_map size after 1000 emplaces");
    check(m.at("k0") == 0 && m.at("k999") == 999, "lookup returns what was stored");
// …

tests/examples/gtl/tests/containers.cpp · project tests/examples/gtl

Build

targets
gtl (lib)
language
c++23
C standard
c11
import std
no
include dirs
*/include

Sources (1)

  • mcpp_generated/gtl_anchor.c

Generated files

  • mcpp_generated/gtl_anchor.c

Versions

VersionPlatforms Mirrorssha256
1.2.0 latest LinuxWindowsmacOS GLOBAL CN 1547ab78f627…