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…