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

用法

來自本倉庫自己的測試專案 —— CI 真的編譯並執行過,不是為了網站寫的。

// 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 · 專案 tests/examples/gtl

建置

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

原始檔 (1)

  • mcpp_generated/gtl_anchor.c

產生的檔案

  • mcpp_generated/gtl_anchor.c

版本

版本平台 鏡像sha256
1.2.0 最新 LinuxWindowsmacOS GLOBAL CN 1547ab78f627…