alibaba / alibaba/yalantinglibs
Dont declare too many symbols in user namespace
- 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
https://github.com/alibaba/yalantinglibs/blob/f05e5c9871accf81628166c91aad8dd7d9e8c9e4/thirdparty/iguana/iguana/reflection.hpp#L645-L648
https://github.com/alibaba/yalantinglibs/blob/f05e5c9871accf81628166c91aad8dd7d9e8c9e4/thirdparty/iguana/iguana/reflection.hpp#L573-L579
@qicosmos as above codes show, it may produce many symbols declare in user namespace if many structures need reflection.
### Reproduction way
### Anything else
possible solution:
```.cpp
#define REFLECTION(T, arg) \
constexpr auto meta_info(T) { \
struct impl { \
constexpr const char* props() const { return #arg; } \
}; \
return impl{}; \
}
REFLECTION(int, age)
REFLECTION(char, pname)
std::cout << meta_info(int{}).props() << std::endl;
std::cout << meta_info(char{}).props() << std::endl;
```
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with thirdparty/iguana/iguana/reflection.hpp at the referenced lines 645-648 and 573-579, then compare the behavior with the sample REFLECTION declarations in the issue. Confirm how many symbols are introduced into the user namespace and define completion as preserving reflection behavior while avoiding unnecessary user-namespace declarations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100