alibaba / alibaba/yalantinglibs
[struct_pb] std::out_of_range: unknown key
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 327
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 2
Description
### Search before asking
- [x] I searched the [issues](https://github.com/alibaba/yalantinglibs/issues) and found no similar issues.
### What happened + What you expected to happen
support unknown
### Reproduction way
```
struct person : struct_pb::base_impl {
int age;
std::string name;
};
struct person2 : struct_pb::base_impl {
int age;
std::string name;
int salary;
};
REFLECTION(person, age, name);
REFLECTION(person2, age, name, salary);
int main() {
person p1{};
p1.age = 100;
p1.name = "abc";
std::string s;
struct_pb::to_pb(p1, s);
person2 p2{};
struct_pb::from_pb(p2, s);
std::cout << p2.age << std::endl;
std::cout << p2.name << std::endl;
std::cout << p2.salary << std::endl;
p2.salary = 1000;
struct_pb::to_pb(p2, s);
person p3{};
struct_pb::from_pb(p3, s);
std::cout << p3.age << std::endl;
std::cout << p3.name << std::endl;
return 0;
}
```
got error
```
100
abc
0
libc++abi: terminating due to uncaught exception of type std::out_of_range: unknown key
```
### Anything else
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.