mcpp index

compat.type-safe

#include

Strongly typed wrappers and type-safe utility types for C++ (header-only)

#include <type_safe/optional.hpp>
mcpp add compat.type-safe@0.2.4

用法

来自本仓库自己的测试项目 —— CI 真的编译并运行过,不是为了网站写的。

#include <type_safe/optional.hpp>
#include <type_safe/strong_typedef.hpp>

#include <cstdio>
#include <type_traits>

struct user_id : type_safe::strong_typedef<user_id, int> {
    using strong_typedef::strong_typedef;
};

int main() {
    bool ok = true;
    auto check = [&](bool condition, const char* what) {
        if (!condition) {
            std::printf("FAIL: %s\n", what);
            ok = false;
        }
    };

    static_assert(!std::is_convertible<user_id, int>::value,
                  "strong typedefs must not implicitly convert to their representation");

// …

tests/examples/type-safe/tests/type_safe.cpp · 项目 tests/examples/type-safe

构建

targets
type_safe (lib)
language
c++23
C standard
c11
import std
no
include dirs
*/include, */external/debug_assert

源文件 (1)

  • mcpp_generated/type_safe_anchor.c

生成的文件

  • mcpp_generated/type_safe_anchor.c

版本

版本平台 镜像sha256
0.2.4 最新 LinuxWindowsmacOS CN GLOBAL a631d03c18c6…