mcpp index

compat.tl-optional

#include

tl::optional — std::optional with monadic operations and reference support (header-only)

#include <tl/optional.hpp>
mcpp add compat.tl-optional@1.1.0

用法

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

// compat.tl-optional — assert value/empty state, observers, mutation, monadic
// chaining, reference binding, and constexpr construction through the public
// header. The test uses only the standard library in addition to tl/optional.
#include <tl/optional.hpp>

#include <cstdio>
#include <string>
#include <type_traits>

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

    tl::optional<int> value = tl::make_optional(42);
    tl::optional<int> empty = tl::nullopt;
    check(value.has_value() && *value == 42, "value construction and observer");
    check(!empty.has_value(), "nullopt constructs an empty optional");
// …

tests/examples/tl-optional/tests/optional.cpp · 專案 tests/examples/tl-optional

建置

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

原始檔 (1)

  • mcpp_generated/tl_optional_anchor.c

產生的檔案

  • mcpp_generated/tl_optional_anchor.c

版本

版本平台 鏡像sha256
1.1.0 最新 LinuxWindowsmacOS CN GLOBAL 88ece79f3de5…