Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit171e326

Browse files
committed
Create serialize.hpp
1 parentbbe79a4 commit171e326

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

‎Util/stdcxx26/serialize.hpp‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* @file serialize.hpp
3+
* @author Xuhua Huang
4+
* @brief
5+
* @version 0.1
6+
* @date 2025-06-19
7+
*
8+
* @copyright Copyright (c) 2025
9+
*
10+
*/
11+
12+
#pragma once
13+
#ifndef SERIALIZE_HPP
14+
#defineSERIALIZE_HPP
15+
16+
#include<print>
17+
18+
namespaceutil {
19+
20+
voidinspect(constauto& obj) {
21+
constauto& [...values] = obj;
22+
23+
std::print("Object has: {} elements\n",sizeof...(values));
24+
25+
int count =0;
26+
27+
(std::print("Elem: {}: {}\n", count++, values), ...);
28+
}
29+
30+
voidserialize(constauto& obj) {
31+
constauto& [...values] = obj;
32+
static_assert(sizeof...(values) ==std::size(obj.names));
33+
34+
std::size_t index =0;
35+
std::print("{{");
36+
(std::print("\"{}\": {},", obj.names[index++], values), ...);
37+
std::print("}}");
38+
}
39+
40+
}
41+
42+
#endif// !SERIALIZE_HPP

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp