mcpp index

compat.reflectcpp

Compile-time reflection and serialization for C++ structs (core + JSON)

mcpp add compat.reflectcpp@0.25.0

用法

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

// Behavioral test: struct -> JSON -> struct, through the JSON backend.
//
// The package compiles two umbrella TUs plus the vendored yyjson. All three have
// to be present and agree: leave out src/yyjson.c and this fails to LINK; get the
// include roots wrong and rfl/json/save.hpp picks a different yyjson than the one
// compiled, which fails at runtime rather than at build time. So the assertions
// go all the way to parsed values.
#include <rfl.hpp>
#include <rfl/json.hpp>

#include <cassert>
#include <optional>
#include <string>
#include <vector>

struct Point {
    int x;
    int y;
};

struct Document {
    std::string name;
// …

tests/examples/reflectcpp/tests/json_roundtrip.cpp · 项目 tests/examples/reflectcpp

构建

targets
reflectcpp (lib)
language
c++23
C standard
c11
import std
no
include dirs
*/include, */include/rfl/thirdparty

源文件 (3)

  • */src/reflectcpp.cpp
  • */src/reflectcpp_json.cpp
  • */src/yyjson.c

版本

版本平台 镜像sha256
0.25.0 最新 LinuxWindowsmacOS GLOBAL CN de74d3793fd3…